Skip to content

createContract

createContract<TName, THumanReadableAbi>(__namedParameters): Contract<TName, THumanReadableAbi>

Creates a tevm Contract instance from human readable abi

Type parameters

TName extends string

THumanReadableAbi extends readonly string[]

Parameters

__namedParameters: CreateContractParams<TName, THumanReadableAbi>

Returns

Contract<TName, THumanReadableAbi>

Examples

import { type Contract, createContract} from 'tevm/contract'
const contract: Contract = createContract({
name: 'MyContract',
abi: [
...
],
})

To use a json abi first pass it into formatAbi to turn it into human readable

import { type Contract, createContract} from 'tevm/contract'
const contract = createContract({
name: 'MyContract',
abi: [
...
],
})

Source

createContract.js:34