tevmContract
tevmContract<
TAbi,TFunctionName>(client,params):Promise<ContractResult<TAbi,TFunctionName>>
A tree-shakeable version of the tevmContract action for viem.
Interacts with a contract method call using TEVM.
Internally, tevmContract wraps tevmCall. It automatically encodes and decodes the contract call parameters and results, as well as any revert messages.
Type Parameters
• TAbi extends readonly unknown[] | Abi = Abi
• TFunctionName extends string = ContractFunctionName<TAbi>
Parameters
• client: Client<TevmTransport<string>>
• params: ContractParams<TAbi, TFunctionName>
Returns
Promise<ContractResult<TAbi, TFunctionName>>
Example
import { tevmContract } from 'tevm/actions'import { createClient, http } from 'viem'import { optimism } from 'tevm/common'import { createTevmTransport } from 'tevm'
const client = createClient({ transport: createTevmTransport({ fork: { transport: http('https://mainnet.optimism.io')({}) } }), chain: optimism,})
async function example() { const res = await tevmContract(client, { abi: [...], functionName: 'myFunction', args: [...], }) console.log(res)}
example()See
- ContractParams for options reference.
- ContractResult for return values reference.
- BaseCallParams for the base call parameters.
- TEVM Actions Guide