getContract
Action for creating a type-safe Contract instance.
import { getContract } from '@wagmi/core'
Usage
The following examples use the ENS Registry contract.
import { getContract } from '@wagmi/core'
const contract = getContract({
address: '0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e',
abi: ensRegistryABI,
})
Return Value
ethers.Contract | null
Configuration
address
Contract address.
import { getContract } from '@wagmi/core'
const contract = getContract({
address: '0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e',
abi: ensRegistryABI,
})
abi
Contract ABI.
By defining inline or adding a const assertion to abi
, TypeScript will infer the correct types for properties and methods on the contract object. See the wagmi TypeScript docs for more information.
import { getContract } from '@wagmi/core'
const contract = getContract({
address: '0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e',
abi: ensRegistryABI,
})
signerOrProvider (optional)
import { getContract, getProvider } from '@wagmi/core'
const provider = getProvider()
const contract = getContract({
address: '0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e',
abi: ensRegistryABI,
signerOrProvider: provider,
})