TevmContract
TevmContract: <
TAbi
,TFunctionName
>(client
,params
) =>Promise
<ContractResult
<TAbi
,TFunctionName
>>
A type representing the handler for a TEVM contract procedure.
This type reuses the viem contractRead
/contractWrite
API to encode ABI, function name, and arguments.
Type Parameters
• TAbi extends Abi
| readonly unknown
[] = Abi
The ABI of the contract.
• TFunctionName extends ContractFunctionName
<TAbi
> = ContractFunctionName
<TAbi
>
The name of the contract function.
Parameters
• client: Client
<TevmTransport
<string
>>
The viem client configured with TEVM transport.
• params: ContractParams
<TAbi
, TFunctionName
>
Parameters for the contract method call, including ABI, function name, and arguments.
Returns
Promise
<ContractResult
<TAbi
, TFunctionName
>>
The result of the contract method call.
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.