contractHandler
contractHandler(
client
,options
?):ContractHandler
Creates a tree-shakable instance of contractHandler
for handling contract interactions with the Ethereumjs EVM.
This function uses callHandler
under the hood to execute contract calls.
Note: This is the internal logic used by higher-level APIs such as tevmContract
.
Parameters
• client: TevmNode
<"fork"
| "normal"
, object
>
The TEVM base client instance.
• options? = {}
Optional parameters.
• options.throwOnFail?: undefined
| boolean
= true
Whether to throw an error on failure.
Returns
The contract handler function.
Throws
If throwOnFail
is true, returns TevmCallError
as value.
Example
import { createTevmNode } from 'tevm/node'import { contractHandler } from 'tevm/actions'
const client = createTevmNode()
const contract = contractHandler(client)
const res = await contract({ to: `0x${'69'.repeat(20)}`, abi: [{...}], // ABI array functionName: 'myFunction', args: [1, 2, 3],})