contract.callStatic.METHOD_NAME Using input/data hex
See original GitHub issueWhen using the contract.callStatic.METHOD_NAME
method, is it possible to use the input or data hex value provided by the transaction object to populate the method parameters instead of manually providing the parameters of the METHOD_NAME one by one?
i.e. Instead of:
await wethContract.deposit({value: _amount, gasPrice: await helpers.getGasPriceFastest(), gasLimit: '1000000'})
Is it possible to do something along the lines of: contract.callStatic('0xd0e30db0')
where the hexadecimal string 0xd0e30db0
includes the method_name and any other parameters needed?
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:6 (2 by maintainers)
Top Results From Across the Web
How To Decipher A Smart Contract Method Call - Medium
A smart contract can choose to simulate a method call by processing the input data in a structured way, as shown in the...
Read more >Creating the input data for an Ethereum contract function call
The first input is dynamic so this line will describe where the data is to be found. It will be found 64 bytes...
Read more >Ethers pass method name with parameters instead of hexdata
Is it possible to just pass method name from contract and parameters to it instead of passing this hex value? Maybe there is...
Read more >How to mimic ethers.js callStatic with JsonRCP - Questions
I am directly constructing view/read only contract queries successfully with eth_call, now I am wondering how to call a contract state ...
Read more >Decoding an Ethereum Transaction.
We're going to start with a Gnosis Safe contract and a transaction a user would ... This hex value is derived from taking...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Will confirm in the next few days!
If you have already called
populateTransaction
, you can skip the contract step entirely for thecallStatic
and just use theprovider.call
. Then you can use thecontract.interface.decodeFunctionResult
to interpret the result. For example:I think that should work for you if you don’t want to just call the two separate methods on the contract.
I would normally just suggest you use
contract.callStatic.transfer(addr, value)
followed by acontract.populateTransaction.transfer(address, value)
though…Let me know if that works for you. 😃