State override support for eth_call and eth_estimateGas #1418
Replies: 2 comments 1 reply
-
Can look at getting this into the first-class APIs ( |
Beta Was this translation helpful? Give feedback.
-
I've had to add a workaround in a project that needed state overrides in Overrides would be an optional Object with an arbitrary key => value mapping. /**
* @description Executes a new message call immediately without submitting a transaction to the network
*
* @example
* provider.request({ method: 'eth_call', params: [{ to: '0x...', data: '0x...' }] })
* // => '0x...'
*/
{
Method: 'eth_call'
Parameters:
| [transaction: Partial<TransactionRequest>]
| [
transaction: Partial<TransactionRequest>,
block: BlockNumber | BlockTag | BlockIdentifier,
]
| [
transaction: Partial<TransactionRequest>,
block: BlockNumber | BlockTag | BlockIdentifier,
overrides: any,
]
ReturnType: Hex
}, We will possibly need to account for another case without One possible concern is that it is considered a non-standard feature of Geth, Erigon and Reth but an incredibly useful one, especially for frontends. Happy to contribute / collaborate on a PR if there is interest in the feature. |
Beta Was this translation helpful? Give feedback.
-
Currently, the next scenarios are impossible to implement using Viem:
from
doesn't meet the contract`s requirements (like the user is not whitelisted, or the token balance is insufficient)This is quite sad, because Ethers supports it, and in the case of Viem I needed to write a custom implementation of the provider.call() method just to be able to make a static call to function without making an approval before
That can be achieved by passing the state override parameter in
eth_call
and ineth_estimateGas
RPC methodshttps://geth.ethereum.org/docs/interacting-with-geth/rpc/ns-eth#eth-call
Beta Was this translation helpful? Give feedback.
All reactions