Types
import type {
BaseContractMethod,
ContractMethodArgs,
TypesafeEthersContract,
} from '@tevm/ethers'TypesafeEthersContract<TAbi>
An ethers BaseContract with methods and events derived from a const ABI.
pure/viewfunctions resolve to the decoded return value. A single output is unwrapped; multiple outputs become an ethersResultintersected with the output tuple.nonpayable/payablefunctions resolve to aContractTransactionResponse; use.staticCall()for the decoded return value.queryFilternarrows the logargsfor any event name present in the ABI, and falls back toEventLog | Logfor unknown names.
import { , , type } from '@tevm/ethers'
const = [
{
: 'function',
: 'transfer',
: 'nonpayable',
: [
{ : 'to', : 'address' },
{ : 'amount', : 'uint256' },
],
: [{ : '', : 'bool' }],
},
{
: 'event',
: 'Transfer',
: [
{ : true, : 'from', : 'address' },
{ : true, : 'to', : 'address' },
{ : false, : 'value', : 'uint256' },
],
},
] as
const = await .createMemoryProvider({})
const : <typeof > = new (
'0x0000000000000000000000000000000000000001',
,
,
)
// `ok` is boolean — the decoded return value of a write method
const = await .transfer.staticCall('0x0000000000000000000000000000000000000002', 1n)
// `logs[n].args` is typed from the Transfer event
const = await .queryFilter('Transfer', 0, 'latest')Solidity → TypeScript mapping
| Solidity | TypeScript |
|---|---|
uintN / intN | bigint |
bool | boolean |
address, string, bytesN | string |
T[] / T[N] | Array<mapped T> |
tuple | ethers Result intersected with the mapped components |
| no outputs | void |
BaseContractMethod<TArguments, TReturnType, TExtendedReturnType>
The shape of a single typed contract method: callable, plus the ethers method helpers.
type BaseContractMethod<
TArguments extends ReadonlyArray<any> = ReadonlyArray<any>,
TReturnType = any,
TExtendedReturnType extends TReturnType | ContractTransactionResponse = ContractTransactionResponse,
> = {
(...args: ContractMethodArgs<TArguments>): Promise<TReturnType | TExtendedReturnType>
name: string
_contract: BaseContract
_key: string
getFragment: (...args: ContractMethodArgs<TArguments>) => FunctionFragment
estimateGas: (...args: ContractMethodArgs<TArguments>) => Promise<bigint>
populateTransaction: (...args: ContractMethodArgs<TArguments>) => Promise<ContractTransaction>
send: (...args: ContractMethodArgs<TArguments>) => Promise<ContractTransactionResponse>
staticCall: (...args: ContractMethodArgs<TArguments>) => Promise<TReturnType>
staticCallResult: (...args: ContractMethodArgs<TArguments>) => Promise<Result>
readonly fragment: FunctionFragment
}import { , , type } from '@tevm/ethers'
const = [
{
: 'function',
: 'transfer',
: 'nonpayable',
: [
{ : 'to', : 'address' },
{ : 'amount', : 'uint256' },
],
: [{ : '', : 'bool' }],
},
] as
const = await .createMemoryProvider({})
const = new ('0x0000000000000000000000000000000000000001', , )
const : <[string, bigint], boolean> = .transfer
.(.name) // 'transfer'ContractMethodArgs<A>
type ContractMethodArgs<A extends ReadonlyArray<any>> = [...A, Overrides] | AThe argument tuple a contract method accepts: the ABI-derived arguments, optionally followed by an
ethers Overrides object (gasLimit, value, from, nonce, ...).
import type { } from '@tevm/ethers'
type = <[string, bigint]>
const : = ['0x0000000000000000000000000000000000000001', 1n]
const : = [
'0x0000000000000000000000000000000000000001',
1n,
{ : 100_000n },
]TypesafeEthersContractConstructor / TypesafeEthersInterfaceConstructor
The constructor types behind the Contract and Interface exports. You rarely
reference these directly; they exist so the exported values can carry both the typed and the
untyped overloads.

