You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to replicate some code made on Ionic, which uses web3.js.
At a certain point, it calls web3.eth.abi.encodeFunctionCall but as far as I've looked throught the library it doesn't contain any similar feature.
Here's the snippet I'm trying to mirror:
So far I have this, trying to replicate the first encodeFunctionCall:
let walletAddress = EthereumAddress(walletAddress)! // Your wallet address
let contractMethod = "addKey" // Contract method you want to write
let contractABI = """
<JSON with ABI>
"""
let contractAddress = EthereumAddress("<Address>")!
let abiVersion = 2 // Contract ABI version
let parameters : [AnyObject] = [publicKey.toHexString() as AnyObject] // Parameters for contract method
let extraData: Data = Data() // Extra data for contract method
let contract = w3.contract(contractABI, at: contractAddress, abiVersion: abiVersion)!
var options = TransactionOptions.defaultOptions
options.from = walletAddress
options.gasPrice = .manual(BigUInt(0))
options.gasLimit = .manual(BigUInt(600000))
let tx = contract.method(contractMethod, parameters: parameters, extraData: extraData, transactionOptions: options)
if let ethTransaction = try? tx?.assemble(), let hashSignature = ethTransaction.encode(forSignature: true, chainID: nil)?.toHexString(){
print(hashSignature)
return hashSignature
}else {
throw Error.pubKeyData
}
I've tried to use assemble and encode the transaction trying to replicate encodeFunctionCall, which then I need to add as parameter to the second method, but this fails with "Failed to fetch gas estimate" and I'm clueless wether this is an issue with how I coded that function or with the Ionic - Swift translation I'm developing.
Can you elaborate on how to use web3.eth.abi.encodeFunctionCall on this library or if it's not supported at all?
The text was updated successfully, but these errors were encountered:
I'm trying to replicate some code made on Ionic, which uses web3.js.
At a certain point, it calls
web3.eth.abi.encodeFunctionCall
but as far as I've looked throught the library it doesn't contain any similar feature.Here's the snippet I'm trying to mirror:
So far I have this, trying to replicate the first encodeFunctionCall:
I've tried to use assemble and encode the transaction trying to replicate encodeFunctionCall, which then I need to add as parameter to the second method, but this fails with "Failed to fetch gas estimate" and I'm clueless wether this is an issue with how I coded that function or with the Ionic - Swift translation I'm developing.
Can you elaborate on how to use web3.eth.abi.encodeFunctionCall on this library or if it's not supported at all?
The text was updated successfully, but these errors were encountered: