Skip to main content

Contract <Abi>

The class designed to interact with smart contracts on the Ethereum blockchain.

Hierarchy

  • Web3Context<EthExecutionAPI, typeof contractSubscriptions>
    • Contract

Implements

Index

Constructors

publicconstructor

  • new Contract<Abi>(jsonInterface: Abi, context?: Partial<Web3ContextInitOptions<EthExecutionAPI, { logs: typeof LogsSubscription; newBlockHeaders: typeof NewHeadsSubscription; newHeads: typeof NewHeadsSubscription }>>, returnFormat?: DataFormat): Contract<Abi>
  • new Contract<Abi>(jsonInterface: Abi, address: string, contextOrReturnFormat?: DataFormat | Partial<Web3ContextInitOptions<EthExecutionAPI, { logs: typeof LogsSubscription; newBlockHeaders: typeof NewHeadsSubscription; newHeads: typeof NewHeadsSubscription }>>, returnFormat?: DataFormat): Contract<Abi>
  • new Contract<Abi>(jsonInterface: Abi, options?: ContractInitOptions, contextOrReturnFormat?: DataFormat | Partial<Web3ContextInitOptions<EthExecutionAPI, { logs: typeof LogsSubscription; newBlockHeaders: typeof NewHeadsSubscription; newHeads: typeof NewHeadsSubscription }>>, returnFormat?: DataFormat): Contract<Abi>
  • new Contract<Abi>(jsonInterface: Abi, address: string, options: ContractInitOptions, contextOrReturnFormat?: DataFormat | Partial<Web3ContextInitOptions<EthExecutionAPI, { logs: typeof LogsSubscription; newBlockHeaders: typeof NewHeadsSubscription; newHeads: typeof NewHeadsSubscription }>>, returnFormat?: DataFormat): Contract<Abi>
  • Creates a new contract instance with all its methods and events defined in its json interface object.

    new web3.eth.Contract(jsonInterface[, address][, options])

    Type parameters

    • Abi: readonly AbiFragment[]

    Parameters

    • jsonInterface: Abi

      The JSON interface for the contract to instantiate.

    • optionalcontext: Partial<Web3ContextInitOptions<EthExecutionAPI, { logs: typeof LogsSubscription; newBlockHeaders: typeof NewHeadsSubscription; newHeads: typeof NewHeadsSubscription }>>

      The context of the contract used for customizing the behavior of the contract.

    • optionalreturnFormat: DataFormat

    Returns Contract<Abi>

    • The contract instance with all its methods and events.
    var myContract = new web3.eth.Contract([...], '0xde0B295669a9FD93d5F28D9Ec85E40f4cb697BAe', {
    from: '0x1234567890123456789012345678901234567891', // default from address
    gasPrice: '20000000000' // default gas price in wei, 20 gwei in this case
    });

    To use the type safe interface for these contracts you have to include the ABI definitions in your Typescript project and then declare these as const.

    const myContractAbi = [....] as const; // ABI definitions
    const myContract = new web3.eth.Contract(myContractAbi, '0xde0B295669a9FD93d5F28D9Ec85E40f4cb697BAe');

Properties

publicreadonlyoptions

The options object for the contract instance. from, gas and gasPrice are used as fallback values when sending transactions.

myContract.options;
> {
address: '0x1234567890123456789012345678901234567891',
jsonInterface: [...],
from: '0xde0B295669a9FD93d5F28D9Ec85E40f4cb697BAe',
gasPrice: '10000000000000',
gas: 1000000
}

myContract.options.from = '0x1234567890123456789012345678901234567891'; // default from address
myContract.options.gasPrice = '20000000000000'; // default gas price in wei
myContract.options.gas = 5000000; // provide as fallback always 5M gas

readonlyproviders

providers: { HttpProvider: Web3BaseProviderConstructor; IpcProvider: Web3BaseProviderConstructor; WebsocketProvider: Web3BaseProviderConstructor }

Type declaration

  • HttpProvider: Web3BaseProviderConstructor
  • IpcProvider: Web3BaseProviderConstructor
  • WebsocketProvider: Web3BaseProviderConstructor

publicstaticoptionalblockHeaderTimeout

blockHeaderTimeout?: number

Can be used to set Contract.blockHeaderTimeout for all contracts.

publicstaticoptionaldefaultAccount

defaultAccount?: string

Can be used to set Contract.defaultAccount for all contracts.

publicstaticoptionaldefaultBlock

defaultBlock?: BlockNumberOrTag

Can be used to set Contract.defaultBlock for all contracts.

publicstaticoptionaldefaultCommon

defaultCommon?: Common

Can be used to set Contract.defaultCommon for all contracts.

publicstaticoptionaldefaultHardfork

defaultHardfork?: string

Can be used to set Contract.defaultHardfork for all contracts.

staticoptionalgivenProvider

givenProvider?: SupportedProviders<never>

publicstaticoptionalhandleRevert

handleRevert?: boolean

Can be used to set Contract.handleRevert for all contracts.

staticreadonlyproviders

providers: { HttpProvider: Web3BaseProviderConstructor; IpcProvider: Web3BaseProviderConstructor; WebsocketProvider: Web3BaseProviderConstructor }

Type declaration

  • HttpProvider: Web3BaseProviderConstructor
  • IpcProvider: Web3BaseProviderConstructor
  • WebsocketProvider: Web3BaseProviderConstructor

publicstaticoptionaltransactionBlockTimeout

transactionBlockTimeout?: number

Can be used to set Contract.transactionBlockTimeout for all contracts.

publicstaticoptionaltransactionConfirmationBlocks

transactionConfirmationBlocks?: number

Can be used to set Contract.transactionConfirmationBlocks for all contracts.

publicstaticoptionaltransactionConfirmationPollingInterval

transactionConfirmationPollingInterval?: number

Can be used to set Contract.transactionConfirmationPollingInterval for all contracts.

publicstaticoptionaltransactionPollingInterval

transactionPollingInterval?: number

Can be used to set Contract.transactionPollingInterval for all contracts.

publicstaticoptionaltransactionPollingTimeout

transactionPollingTimeout?: number

Can be used to set Contract.transactionPollingTimeout for all contracts.

publicstaticoptionaltransactionReceiptPollingInterval

transactionReceiptPollingInterval?: number

Can be used to set Contract.transactionReceiptPollingInterval for all contracts.

publicstaticoptionaltransactionSendTimeout

transactionSendTimeout?: number

Can be used to set Contract.transactionSendTimeout for all contracts.

Accessors

BatchRequest

  • get BatchRequest(): new () => Web3BatchRequest
  • Returns new () => Web3BatchRequest

      • new (): Web3BatchRequest
      • Returns Web3BatchRequest

accountProvider

  • get accountProvider(): undefined | Web3AccountProvider<Web3BaseWalletAccount>
  • Returns undefined | Web3AccountProvider<Web3BaseWalletAccount>

publicblockHeaderTimeout

  • get blockHeaderTimeout(): number
  • set blockHeaderTimeout(value: number): void
  • Returns number

  • Parameters

    • value: number

    Returns void

currentProvider

  • get currentProvider(): undefined | string | SupportedProviders<API>
  • set currentProvider(provider: undefined | string | SupportedProviders<API>): void
  • Returns undefined | string | SupportedProviders<API>

  • Parameters

    • provider: undefined | string | SupportedProviders<API>

    Returns void

publicdefaultAccount

  • get defaultAccount(): undefined | string
  • set defaultAccount(value: undefined | string): void
  • Returns undefined | string

  • Parameters

    • value: undefined | string

    Returns void

publicdefaultBlock

  • get defaultBlock(): BlockNumberOrTag
  • set defaultBlock(value: BlockNumberOrTag): void
  • Returns BlockNumberOrTag

  • Parameters

    • value: BlockNumberOrTag

    Returns void

defaultChain

  • get defaultChain(): string
  • set defaultChain(val: string): void
  • Returns string

  • Parameters

    • val: string

    Returns void

publicdefaultCommon

  • get defaultCommon(): undefined | Common
  • set defaultCommon(value: undefined | Common): void
  • Returns undefined | Common

  • Parameters

    • value: undefined | Common

    Returns void

publicdefaultHardfork

  • get defaultHardfork(): string
  • set defaultHardfork(value: string): void
  • Returns string

  • Parameters

    • value: string

    Returns void

defaultMaxPriorityFeePerGas

  • get defaultMaxPriorityFeePerGas(): Numbers
  • set defaultMaxPriorityFeePerGas(val: Numbers): void
  • Returns Numbers

  • Parameters

    • val: Numbers

    Returns void

defaultNetworkId

  • get defaultNetworkId(): undefined | Numbers
  • set defaultNetworkId(val: undefined | Numbers): void
  • Returns undefined | Numbers

  • Parameters

    • val: undefined | Numbers

    Returns void

defaultTransactionType

  • get defaultTransactionType(): Numbers
  • set defaultTransactionType(val: Numbers): void
  • Returns Numbers

  • Parameters

    • val: Numbers

    Returns void

enableExperimentalFeatures

  • get enableExperimentalFeatures(): { useRpcCallSpecification: boolean; useSubscriptionWhenCheckingBlockTimeout: boolean }
  • set enableExperimentalFeatures(val: { useRpcCallSpecification: boolean; useSubscriptionWhenCheckingBlockTimeout: boolean }): void
  • Returns { useRpcCallSpecification: boolean; useSubscriptionWhenCheckingBlockTimeout: boolean }

    • useRpcCallSpecification: boolean
    • useSubscriptionWhenCheckingBlockTimeout: boolean
  • Parameters

    • val: { useRpcCallSpecification: boolean; useSubscriptionWhenCheckingBlockTimeout: boolean }

    Returns void

publicevents

  • Subscribe to an event.

    await myContract.events.MyEvent([options])

    There is a special event allEvents that can be used to subscribe all events.

    await myContract.events.allEvents([options])

    Returns ContractEventsInterface<Abi, ContractEvents<Abi>>

givenProvider

  • get givenProvider(): undefined | SupportedProviders<never>
  • Returns undefined | SupportedProviders<never>

publichandleRevert

  • get handleRevert(): boolean
  • set handleRevert(value: boolean): void
  • Returns boolean

  • Parameters

    • value: boolean

    Returns void

maxListenersWarningThreshold

  • get maxListenersWarningThreshold(): number
  • set maxListenersWarningThreshold(val: number): void
  • Returns number

  • Parameters

    • val: number

    Returns void

publicmethods

  • Creates a transaction object for that method, which then can be called, send, estimated, createAccessList , or ABI encoded.

    The methods of this smart contract are available through:

    The name: myContract.methods.myMethod(123) The name with parameters: myContract.methods['myMethod(uint256)'](123) The signature myContract.methods['0x58cf5f10'](123)

    This allows calling functions with same name but different parameters from the JavaScript contract object.

    &gt; The method signature does not provide a type safe interface, so we recommend to use method name instead.

    // calling a method
    const result = await myContract.methods.myMethod(123).call({from: '0xde0B295669a9FD93d5F28D9Ec85E40f4cb697BAe'});

    // or sending and using a promise
    const receipt = await myContract.methods.myMethod(123).send({from: '0xde0B295669a9FD93d5F28D9Ec85E40f4cb697BAe'});

    // or sending and using the events
    const sendObject = myContract.methods.myMethod(123).send({from: '0xde0B295669a9FD93d5F28D9Ec85E40f4cb697BAe'});
    sendObject.on('transactionHash', function(hash){
    ...
    });
    sendObject.on('receipt', function(receipt){
    ...
    });
    sendObject.on('confirmation', function(confirmationNumber, receipt){
    ...
    });
    sendObject.on('error', function(error, receipt) {
    ...
    });

    Returns ContractMethodsInterface<Abi>

provider

  • get provider(): undefined | string | SupportedProviders<API>
  • set provider(provider: undefined | string | SupportedProviders<API>): void
  • Returns undefined | string | SupportedProviders<API>

  • Parameters

    • provider: undefined | string | SupportedProviders<API>

    Returns void

requestManager

  • get requestManager(): Web3RequestManager<API>
  • Returns Web3RequestManager<API>

subscriptionManager

  • get subscriptionManager(): undefined | Web3SubscriptionManager<API, RegisteredSubs>
  • Returns undefined | Web3SubscriptionManager<API, RegisteredSubs>

publictransactionBlockTimeout

  • get transactionBlockTimeout(): number
  • set transactionBlockTimeout(value: number): void
  • Returns number

  • Parameters

    • value: number

    Returns void

transactionBuilder

  • get transactionBuilder(): undefined | TransactionBuilder<unknown>
  • set transactionBuilder(val: undefined | TransactionBuilder<unknown>): void
  • Returns undefined | TransactionBuilder<unknown>

  • Parameters

    • val: undefined | TransactionBuilder<unknown>

    Returns void

publictransactionConfirmationBlocks

  • get transactionConfirmationBlocks(): number
  • set transactionConfirmationBlocks(value: number): void
  • Returns number

  • Parameters

    • value: number

    Returns void

publictransactionConfirmationPollingInterval

  • get transactionConfirmationPollingInterval(): undefined | number
  • set transactionConfirmationPollingInterval(value: undefined | number): void
  • Returns undefined | number

  • Parameters

    • value: undefined | number

    Returns void

publictransactionPollingInterval

  • get transactionPollingInterval(): number
  • set transactionPollingInterval(value: number): void
  • Returns number

  • Parameters

    • value: number

    Returns void

publictransactionPollingTimeout

  • get transactionPollingTimeout(): number
  • set transactionPollingTimeout(value: number): void
  • Returns number

  • Parameters

    • value: number

    Returns void

publictransactionReceiptPollingInterval

  • get transactionReceiptPollingInterval(): undefined | number
  • set transactionReceiptPollingInterval(value: undefined | number): void
  • Returns undefined | number

  • Parameters

    • value: undefined | number

    Returns void

publictransactionSendTimeout

  • get transactionSendTimeout(): number
  • set transactionSendTimeout(value: number): void
  • Returns number

  • Parameters

    • value: number

    Returns void

transactionTypeParser

  • get transactionTypeParser(): undefined | TransactionTypeParser
  • set transactionTypeParser(val: undefined | TransactionTypeParser): void
  • Returns undefined | TransactionTypeParser

  • Parameters

    • val: undefined | TransactionTypeParser

    Returns void

wallet

  • get wallet(): undefined | Web3BaseWallet<Web3BaseWalletAccount>
  • Returns undefined | Web3BaseWallet<Web3BaseWalletAccount>

Methods

publicclone

  • Clones the current contract instance. This doesn’t deploy contract on blockchain and only creates a local clone.


    Returns Contract<Abi>

    • The new contract instance.
    const contract1 = new eth.Contract(abi, address, {gasPrice: '12345678', from: fromAddress});

    const contract2 = contract1.clone();
    contract2.options.address = address2;

    (contract1.options.address !== contract2.options.address);
    > true

publicdeploy

  • deploy(deployOptions?: { arguments?: ContractConstructorArgs<Abi>; data?: string }): { arguments: []; encodeABI: () => string; estimateGas: <ReturnFormat>(options?: PayableCallOptions, returnFormat?: ReturnFormat) => Promise<NumberTypes[ReturnFormat[number]]>; send: (options?: PayableCallOptions) => Web3PromiEvent<Contract<Abi>, SendTransactionEvents<{ bytes: HEX; number: BIGINT }>> }
  • Call this function to deploy the contract to the blockchain. After successful deployment the promise will resolve with a new contract instance.

    myContract.deploy({
    data: '0x12345...',
    arguments: [123, 'My String']
    })
    .send({
    from: '0x1234567890123456789012345678901234567891',
    gas: 1500000,
    gasPrice: '30000000000000'
    }, function(error, transactionHash){ ... })
    .on('error', function(error){ ... })
    .on('transactionHash', function(transactionHash){ ... })
    .on('receipt', function(receipt){
    console.log(receipt.contractAddress) // contains the new contract address
    })
    .on('confirmation', function(confirmationNumber, receipt){ ... })
    .then(function(newContractInstance){
    console.log(newContractInstance.options.address) // instance with the new contract address
    });


    // When the data is already set as an option to the contract itself
    myContract.options.data = '0x12345...';

    myContract.deploy({
    arguments: [123, 'My String']
    })
    .send({
    from: '0x1234567890123456789012345678901234567891',
    gas: 1500000,
    gasPrice: '30000000000000'
    })
    .then(function(newContractInstance){
    console.log(newContractInstance.options.address) // instance with the new contract address
    });


    // Simply encoding
    myContract.deploy({
    data: '0x12345...',
    arguments: [123, 'My String']
    })
    .encodeABI();
    > '0x12345...0000012345678765432'


    // Gas estimation
    myContract.deploy({
    data: '0x12345...',
    arguments: [123, 'My String']
    })
    .estimateGas(function(err, gas){
    console.log(gas);
    });

    Parameters

    • optionaldeployOptions: { arguments?: ContractConstructorArgs<Abi>; data?: string }

    Returns { arguments: []; encodeABI: () => string; estimateGas: <ReturnFormat>(options?: PayableCallOptions, returnFormat?: ReturnFormat) => Promise<NumberTypes[ReturnFormat[number]]>; send: (options?: PayableCallOptions) => Web3PromiEvent<Contract<Abi>, SendTransactionEvents<{ bytes: HEX; number: BIGINT }>> }

    • The transaction object
    • arguments: []
    • encodeABI: () => string
        • (): string
        • Returns string

    • estimateGas: <ReturnFormat>(options?: PayableCallOptions, returnFormat?: ReturnFormat) => Promise<NumberTypes[ReturnFormat[number]]>
        • <ReturnFormat>(options?: PayableCallOptions, returnFormat?: ReturnFormat): Promise<NumberTypes[ReturnFormat[number]]>
        • Type parameters

          • ReturnFormat: DataFormat = { bytes: HEX; number: BIGINT }

          Parameters

          Returns Promise<NumberTypes[ReturnFormat[number]]>

    • send: (options?: PayableCallOptions) => Web3PromiEvent<Contract<Abi>, SendTransactionEvents<{ bytes: HEX; number: BIGINT }>>

emit

  • emit<K>(eventName: K, params: { CONFIG_CHANGE: { name: handleRevert; newValue: boolean; oldValue: boolean } | { name: defaultAccount; newValue: undefined | string; oldValue: undefined | string } | { name: defaultBlock; newValue: BlockNumberOrTag; oldValue: BlockNumberOrTag } | { name: transactionSendTimeout; newValue: number; oldValue: number } | { name: transactionBlockTimeout; newValue: number; oldValue: number } | { name: transactionConfirmationBlocks; newValue: number; oldValue: number } | { name: transactionPollingInterval; newValue: number; oldValue: number } | { name: transactionPollingTimeout; newValue: number; oldValue: number } | { name: transactionReceiptPollingInterval; newValue: undefined | number; oldValue: undefined | number } | { name: transactionConfirmationPollingInterval; newValue: undefined | number; oldValue: undefined | number } | { name: blockHeaderTimeout; newValue: number; oldValue: number } | { name: maxListenersWarningThreshold; newValue: number; oldValue: number } | { name: defaultNetworkId; newValue: undefined | Numbers; oldValue: undefined | Numbers } | { name: defaultChain; newValue: string; oldValue: string } | { name: defaultHardfork; newValue: string; oldValue: string } | { name: defaultCommon; newValue: undefined | Common; oldValue: undefined | Common } | { name: defaultTransactionType; newValue: Numbers; oldValue: Numbers } | { name: defaultMaxPriorityFeePerGas; newValue: Numbers; oldValue: Numbers } | { name: enableExperimentalFeatures; newValue: { useRpcCallSpecification: boolean; useSubscriptionWhenCheckingBlockTimeout: boolean }; oldValue: { useRpcCallSpecification: boolean; useSubscriptionWhenCheckingBlockTimeout: boolean } } | { name: transactionBuilder; newValue: undefined | TransactionBuilder<unknown>; oldValue: undefined | TransactionBuilder<unknown> } | { name: transactionTypeParser; newValue: undefined | TransactionTypeParser; oldValue: undefined | TransactionTypeParser } }[K]): void
  • Type parameters

    • K: CONFIG_CHANGE

    Parameters

    • eventName: K
    • params: { CONFIG_CHANGE: { name: handleRevert; newValue: boolean; oldValue: boolean } | { name: defaultAccount; newValue: undefined | string; oldValue: undefined | string } | { name: defaultBlock; newValue: BlockNumberOrTag; oldValue: BlockNumberOrTag } | { name: transactionSendTimeout; newValue: number; oldValue: number } | { name: transactionBlockTimeout; newValue: number; oldValue: number } | { name: transactionConfirmationBlocks; newValue: number; oldValue: number } | { name: transactionPollingInterval; newValue: number; oldValue: number } | { name: transactionPollingTimeout; newValue: number; oldValue: number } | { name: transactionReceiptPollingInterval; newValue: undefined | number; oldValue: undefined | number } | { name: transactionConfirmationPollingInterval; newValue: undefined | number; oldValue: undefined | number } | { name: blockHeaderTimeout; newValue: number; oldValue: number } | { name: maxListenersWarningThreshold; newValue: number; oldValue: number } | { name: defaultNetworkId; newValue: undefined | Numbers; oldValue: undefined | Numbers } | { name: defaultChain; newValue: string; oldValue: string } | { name: defaultHardfork; newValue: string; oldValue: string } | { name: defaultCommon; newValue: undefined | Common; oldValue: undefined | Common } | { name: defaultTransactionType; newValue: Numbers; oldValue: Numbers } | { name: defaultMaxPriorityFeePerGas; newValue: Numbers; oldValue: Numbers } | { name: enableExperimentalFeatures; newValue: { useRpcCallSpecification: boolean; useSubscriptionWhenCheckingBlockTimeout: boolean }; oldValue: { useRpcCallSpecification: boolean; useSubscriptionWhenCheckingBlockTimeout: boolean } } | { name: transactionBuilder; newValue: undefined | TransactionBuilder<unknown>; oldValue: undefined | TransactionBuilder<unknown> } | { name: transactionTypeParser; newValue: undefined | TransactionTypeParser; oldValue: undefined | TransactionTypeParser } }[K]

    Returns void

eventNames

  • eventNames(): (string | symbol)[]
  • Returns (string | symbol)[]

getConfig

  • getConfig(): Web3ConfigOptions
  • Returns Web3ConfigOptions

getContextObject

  • getContextObject(): Web3ContextObject<EthExecutionAPI, { logs: typeof LogsSubscription; newBlockHeaders: typeof NewHeadsSubscription; newHeads: typeof NewHeadsSubscription }>
  • Returns Web3ContextObject<EthExecutionAPI, { logs: typeof LogsSubscription; newBlockHeaders: typeof NewHeadsSubscription; newHeads: typeof NewHeadsSubscription }>

getMaxListeners

  • getMaxListeners(): number
  • Returns number

publicgetPastEvents

  • getPastEvents<ReturnFormat>(returnFormat?: ReturnFormat): Promise<(string | EventLog)[]>
  • getPastEvents<ReturnFormat>(eventName: allEvents | FilterAbis<Abi, AbiBaseFragment & { anonymous?: boolean; inputs?: readonly AbiParameter[]; name: string; type: string } & { type: event }, Abi[number]>[name], returnFormat?: ReturnFormat): Promise<(string | EventLog)[]>
  • getPastEvents<ReturnFormat>(filter: Omit<Filter, address>, returnFormat?: ReturnFormat): Promise<(string | EventLog)[]>
  • getPastEvents<ReturnFormat>(eventName: allEvents | FilterAbis<Abi, AbiBaseFragment & { anonymous?: boolean; inputs?: readonly AbiParameter[]; name: string; type: string } & { type: event }, Abi[number]>[name], filter: Omit<Filter, address>, returnFormat?: ReturnFormat): Promise<(string | EventLog)[]>
  • Gets past events for this contract.

    const events = await myContract.getPastEvents('MyEvent', {
    filter: {myIndexedParam: [20,23], myOtherIndexedParam: '0x123456789...'}, // Using an array means OR: e.g. 20 or 23
    fromBlock: 0,
    toBlock: 'latest'
    });

    > [{
    returnValues: {
    myIndexedParam: 20,
    myOtherIndexedParam: '0x123456789...',
    myNonIndexParam: 'My String'
    },
    raw: {
    data: '0x7f9fade1c0d57a7af66ab4ead79fade1c0d57a7af66ab4ead7c2c2eb7b11a91385',
    topics: ['0xfd43ade1c09fade1c0d57a7af66ab4ead7c2c2eb7b11a91ffdd57a7af66ab4ead7', '0x7f9fade1c0d57a7af66ab4ead79fade1c0d57a7af66ab4ead7c2c2eb7b11a91385']
    },
    event: 'MyEvent',
    signature: '0xfd43ade1c09fade1c0d57a7af66ab4ead7c2c2eb7b11a91ffdd57a7af66ab4ead7',
    logIndex: 0,
    transactionIndex: 0,
    transactionHash: '0x7f9fade1c0d57a7af66ab4ead79fade1c0d57a7af66ab4ead7c2c2eb7b11a91385',
    blockHash: '0xfd43ade1c09fade1c0d57a7af66ab4ead7c2c2eb7b11a91ffdd57a7af66ab4ead7',
    blockNumber: 1234,
    address: '0xde0B295669a9FD93d5F28D9Ec85E40f4cb697BAe'
    },{
    ...
    }]

    Type parameters

    • ReturnFormat: DataFormat = { bytes: HEX; number: BIGINT }

    Parameters

    • optionalreturnFormat: ReturnFormat

      Return format

    Returns Promise<(string | EventLog)[]>

    • An array with the past event Objects, matching the given event name and filter.

link

  • link<T>(parentContext: T): void
  • Type parameters

    • T: Web3Context<unknown, any, T>

    Parameters

    • parentContext: T

    Returns void

listenerCount

  • listenerCount<K>(eventName: K): number
  • Type parameters

    • K: CONFIG_CHANGE

    Parameters

    • eventName: K

    Returns number

listeners

  • listeners<K>(eventName: K): Function[]
  • Type parameters

    • K: CONFIG_CHANGE

    Parameters

    • eventName: K

    Returns Function[]

off

  • off<K>(eventName: K, fn: Web3EventCallback<{ CONFIG_CHANGE: { name: handleRevert; newValue: boolean; oldValue: boolean } | { name: defaultAccount; newValue: undefined | string; oldValue: undefined | string } | { name: defaultBlock; newValue: BlockNumberOrTag; oldValue: BlockNumberOrTag } | { name: transactionSendTimeout; newValue: number; oldValue: number } | { name: transactionBlockTimeout; newValue: number; oldValue: number } | { name: transactionConfirmationBlocks; newValue: number; oldValue: number } | { name: transactionPollingInterval; newValue: number; oldValue: number } | { name: transactionPollingTimeout; newValue: number; oldValue: number } | { name: transactionReceiptPollingInterval; newValue: undefined | number; oldValue: undefined | number } | { name: transactionConfirmationPollingInterval; newValue: undefined | number; oldValue: undefined | number } | { name: blockHeaderTimeout; newValue: number; oldValue: number } | { name: maxListenersWarningThreshold; newValue: number; oldValue: number } | { name: defaultNetworkId; newValue: undefined | Numbers; oldValue: undefined | Numbers } | { name: defaultChain; newValue: string; oldValue: string } | { name: defaultHardfork; newValue: string; oldValue: string } | { name: defaultCommon; newValue: undefined | Common; oldValue: undefined | Common } | { name: defaultTransactionType; newValue: Numbers; oldValue: Numbers } | { name: defaultMaxPriorityFeePerGas; newValue: Numbers; oldValue: Numbers } | { name: enableExperimentalFeatures; newValue: { useRpcCallSpecification: boolean; useSubscriptionWhenCheckingBlockTimeout: boolean }; oldValue: { useRpcCallSpecification: boolean; useSubscriptionWhenCheckingBlockTimeout: boolean } } | { name: transactionBuilder; newValue: undefined | TransactionBuilder<unknown>; oldValue: undefined | TransactionBuilder<unknown> } | { name: transactionTypeParser; newValue: undefined | TransactionTypeParser; oldValue: undefined | TransactionTypeParser } }[K]>): void
  • Type parameters

    • K: CONFIG_CHANGE

    Parameters

    • eventName: K
    • fn: Web3EventCallback<{ CONFIG_CHANGE: { name: handleRevert; newValue: boolean; oldValue: boolean } | { name: defaultAccount; newValue: undefined | string; oldValue: undefined | string } | { name: defaultBlock; newValue: BlockNumberOrTag; oldValue: BlockNumberOrTag } | { name: transactionSendTimeout; newValue: number; oldValue: number } | { name: transactionBlockTimeout; newValue: number; oldValue: number } | { name: transactionConfirmationBlocks; newValue: number; oldValue: number } | { name: transactionPollingInterval; newValue: number; oldValue: number } | { name: transactionPollingTimeout; newValue: number; oldValue: number } | { name: transactionReceiptPollingInterval; newValue: undefined | number; oldValue: undefined | number } | { name: transactionConfirmationPollingInterval; newValue: undefined | number; oldValue: undefined | number } | { name: blockHeaderTimeout; newValue: number; oldValue: number } | { name: maxListenersWarningThreshold; newValue: number; oldValue: number } | { name: defaultNetworkId; newValue: undefined | Numbers; oldValue: undefined | Numbers } | { name: defaultChain; newValue: string; oldValue: string } | { name: defaultHardfork; newValue: string; oldValue: string } | { name: defaultCommon; newValue: undefined | Common; oldValue: undefined | Common } | { name: defaultTransactionType; newValue: Numbers; oldValue: Numbers } | { name: defaultMaxPriorityFeePerGas; newValue: Numbers; oldValue: Numbers } | { name: enableExperimentalFeatures; newValue: { useRpcCallSpecification: boolean; useSubscriptionWhenCheckingBlockTimeout: boolean }; oldValue: { useRpcCallSpecification: boolean; useSubscriptionWhenCheckingBlockTimeout: boolean } } | { name: transactionBuilder; newValue: undefined | TransactionBuilder<unknown>; oldValue: undefined | TransactionBuilder<unknown> } | { name: transactionTypeParser; newValue: undefined | TransactionTypeParser; oldValue: undefined | TransactionTypeParser } }[K]>

    Returns void

on

  • on<K>(eventName: K, fn: Web3EventCallback<{ CONFIG_CHANGE: { name: handleRevert; newValue: boolean; oldValue: boolean } | { name: defaultAccount; newValue: undefined | string; oldValue: undefined | string } | { name: defaultBlock; newValue: BlockNumberOrTag; oldValue: BlockNumberOrTag } | { name: transactionSendTimeout; newValue: number; oldValue: number } | { name: transactionBlockTimeout; newValue: number; oldValue: number } | { name: transactionConfirmationBlocks; newValue: number; oldValue: number } | { name: transactionPollingInterval; newValue: number; oldValue: number } | { name: transactionPollingTimeout; newValue: number; oldValue: number } | { name: transactionReceiptPollingInterval; newValue: undefined | number; oldValue: undefined | number } | { name: transactionConfirmationPollingInterval; newValue: undefined | number; oldValue: undefined | number } | { name: blockHeaderTimeout; newValue: number; oldValue: number } | { name: maxListenersWarningThreshold; newValue: number; oldValue: number } | { name: defaultNetworkId; newValue: undefined | Numbers; oldValue: undefined | Numbers } | { name: defaultChain; newValue: string; oldValue: string } | { name: defaultHardfork; newValue: string; oldValue: string } | { name: defaultCommon; newValue: undefined | Common; oldValue: undefined | Common } | { name: defaultTransactionType; newValue: Numbers; oldValue: Numbers } | { name: defaultMaxPriorityFeePerGas; newValue: Numbers; oldValue: Numbers } | { name: enableExperimentalFeatures; newValue: { useRpcCallSpecification: boolean; useSubscriptionWhenCheckingBlockTimeout: boolean }; oldValue: { useRpcCallSpecification: boolean; useSubscriptionWhenCheckingBlockTimeout: boolean } } | { name: transactionBuilder; newValue: undefined | TransactionBuilder<unknown>; oldValue: undefined | TransactionBuilder<unknown> } | { name: transactionTypeParser; newValue: undefined | TransactionTypeParser; oldValue: undefined | TransactionTypeParser } }[K]>): void
  • Type parameters

    • K: CONFIG_CHANGE

    Parameters

    • eventName: K
    • fn: Web3EventCallback<{ CONFIG_CHANGE: { name: handleRevert; newValue: boolean; oldValue: boolean } | { name: defaultAccount; newValue: undefined | string; oldValue: undefined | string } | { name: defaultBlock; newValue: BlockNumberOrTag; oldValue: BlockNumberOrTag } | { name: transactionSendTimeout; newValue: number; oldValue: number } | { name: transactionBlockTimeout; newValue: number; oldValue: number } | { name: transactionConfirmationBlocks; newValue: number; oldValue: number } | { name: transactionPollingInterval; newValue: number; oldValue: number } | { name: transactionPollingTimeout; newValue: number; oldValue: number } | { name: transactionReceiptPollingInterval; newValue: undefined | number; oldValue: undefined | number } | { name: transactionConfirmationPollingInterval; newValue: undefined | number; oldValue: undefined | number } | { name: blockHeaderTimeout; newValue: number; oldValue: number } | { name: maxListenersWarningThreshold; newValue: number; oldValue: number } | { name: defaultNetworkId; newValue: undefined | Numbers; oldValue: undefined | Numbers } | { name: defaultChain; newValue: string; oldValue: string } | { name: defaultHardfork; newValue: string; oldValue: string } | { name: defaultCommon; newValue: undefined | Common; oldValue: undefined | Common } | { name: defaultTransactionType; newValue: Numbers; oldValue: Numbers } | { name: defaultMaxPriorityFeePerGas; newValue: Numbers; oldValue: Numbers } | { name: enableExperimentalFeatures; newValue: { useRpcCallSpecification: boolean; useSubscriptionWhenCheckingBlockTimeout: boolean }; oldValue: { useRpcCallSpecification: boolean; useSubscriptionWhenCheckingBlockTimeout: boolean } } | { name: transactionBuilder; newValue: undefined | TransactionBuilder<unknown>; oldValue: undefined | TransactionBuilder<unknown> } | { name: transactionTypeParser; newValue: undefined | TransactionTypeParser; oldValue: undefined | TransactionTypeParser } }[K]>

    Returns void

once

  • once<K>(eventName: K, fn: Web3EventCallback<{ CONFIG_CHANGE: { name: handleRevert; newValue: boolean; oldValue: boolean } | { name: defaultAccount; newValue: undefined | string; oldValue: undefined | string } | { name: defaultBlock; newValue: BlockNumberOrTag; oldValue: BlockNumberOrTag } | { name: transactionSendTimeout; newValue: number; oldValue: number } | { name: transactionBlockTimeout; newValue: number; oldValue: number } | { name: transactionConfirmationBlocks; newValue: number; oldValue: number } | { name: transactionPollingInterval; newValue: number; oldValue: number } | { name: transactionPollingTimeout; newValue: number; oldValue: number } | { name: transactionReceiptPollingInterval; newValue: undefined | number; oldValue: undefined | number } | { name: transactionConfirmationPollingInterval; newValue: undefined | number; oldValue: undefined | number } | { name: blockHeaderTimeout; newValue: number; oldValue: number } | { name: maxListenersWarningThreshold; newValue: number; oldValue: number } | { name: defaultNetworkId; newValue: undefined | Numbers; oldValue: undefined | Numbers } | { name: defaultChain; newValue: string; oldValue: string } | { name: defaultHardfork; newValue: string; oldValue: string } | { name: defaultCommon; newValue: undefined | Common; oldValue: undefined | Common } | { name: defaultTransactionType; newValue: Numbers; oldValue: Numbers } | { name: defaultMaxPriorityFeePerGas; newValue: Numbers; oldValue: Numbers } | { name: enableExperimentalFeatures; newValue: { useRpcCallSpecification: boolean; useSubscriptionWhenCheckingBlockTimeout: boolean }; oldValue: { useRpcCallSpecification: boolean; useSubscriptionWhenCheckingBlockTimeout: boolean } } | { name: transactionBuilder; newValue: undefined | TransactionBuilder<unknown>; oldValue: undefined | TransactionBuilder<unknown> } | { name: transactionTypeParser; newValue: undefined | TransactionTypeParser; oldValue: undefined | TransactionTypeParser } }[K]>): void
  • Type parameters

    • K: CONFIG_CHANGE

    Parameters

    • eventName: K
    • fn: Web3EventCallback<{ CONFIG_CHANGE: { name: handleRevert; newValue: boolean; oldValue: boolean } | { name: defaultAccount; newValue: undefined | string; oldValue: undefined | string } | { name: defaultBlock; newValue: BlockNumberOrTag; oldValue: BlockNumberOrTag } | { name: transactionSendTimeout; newValue: number; oldValue: number } | { name: transactionBlockTimeout; newValue: number; oldValue: number } | { name: transactionConfirmationBlocks; newValue: number; oldValue: number } | { name: transactionPollingInterval; newValue: number; oldValue: number } | { name: transactionPollingTimeout; newValue: number; oldValue: number } | { name: transactionReceiptPollingInterval; newValue: undefined | number; oldValue: undefined | number } | { name: transactionConfirmationPollingInterval; newValue: undefined | number; oldValue: undefined | number } | { name: blockHeaderTimeout; newValue: number; oldValue: number } | { name: maxListenersWarningThreshold; newValue: number; oldValue: number } | { name: defaultNetworkId; newValue: undefined | Numbers; oldValue: undefined | Numbers } | { name: defaultChain; newValue: string; oldValue: string } | { name: defaultHardfork; newValue: string; oldValue: string } | { name: defaultCommon; newValue: undefined | Common; oldValue: undefined | Common } | { name: defaultTransactionType; newValue: Numbers; oldValue: Numbers } | { name: defaultMaxPriorityFeePerGas; newValue: Numbers; oldValue: Numbers } | { name: enableExperimentalFeatures; newValue: { useRpcCallSpecification: boolean; useSubscriptionWhenCheckingBlockTimeout: boolean }; oldValue: { useRpcCallSpecification: boolean; useSubscriptionWhenCheckingBlockTimeout: boolean } } | { name: transactionBuilder; newValue: undefined | TransactionBuilder<unknown>; oldValue: undefined | TransactionBuilder<unknown> } | { name: transactionTypeParser; newValue: undefined | TransactionTypeParser; oldValue: undefined | TransactionTypeParser } }[K]>

    Returns void

registerPlugin

  • registerPlugin(plugin: Web3PluginBase<unknown>): void
  • Parameters

    • plugin: Web3PluginBase<unknown>

    Returns void

removeAllListeners

  • removeAllListeners(): EventEmitter
  • Returns EventEmitter

setConfig

  • setConfig(options: Partial<Web3ConfigOptions>): void
  • Parameters

    • options: Partial<Web3ConfigOptions>

    Returns void

setMaxListenerWarningThreshold

  • setMaxListenerWarningThreshold(maxListenersWarningThreshold: number): void
  • Parameters

    • maxListenersWarningThreshold: number

    Returns void

setProvider

  • setProvider(provider?: string | SupportedProviders<EthExecutionAPI>): boolean
  • Parameters

    • optionalprovider: string | SupportedProviders<EthExecutionAPI>

    Returns boolean

use

  • use<T, T2>(ContextRef: Web3ContextConstructor<T, T2>, ...args: [...T2[]]): T
  • Type parameters

    • T: Web3Context<unknown, any, T>
    • T2: unknown[]

    Parameters

    • ContextRef: Web3ContextConstructor<T, T2>
    • rest...args: [...T2[]]

    Returns T

staticfromContextObject

  • fromContextObject<T, T3>(this: Web3ContextConstructor<T, T3>, ...args: [Web3ContextObject<unknown, any>, ...T3[]]): T
  • Type parameters

    • T: Web3Context<unknown, any, T>
    • T3: unknown[]

    Parameters

    • this: Web3ContextConstructor<T, T3>
    • rest...args: [Web3ContextObject<unknown, any>, ...T3[]]

    Returns T