Skip to main content

ENS

This class is designed to interact with the ENS system on the Ethereum blockchain. For using ENS package, first install Web3 package using: npm i web3 or yarn add web3 based on your package manager, after that ENS features can be used as mentioned in following snippet.


import { Web3 } from 'web3';

const web3 = new Web3('https://127.0.0.1:4545');

console.log(await web3.eth.ens.getAddress('ethereum.eth'))

For using individual package install web3-eth-ens packages using: npm i web3-eth-ens or yarn add web3-eth-ens. This is more efficient approach for building lightweight applications.

import { ENS } from 'web3-eth-ens';

const ens = new ENS(undefined,'https://127.0.0.1:4545');

console.log(await ens.getAddress('vitalik.eth'));

Hierarchy

Index

Constructors

publicconstructor

  • Use to create an instance of ENS

    @example
    const ens = new ENS(
    "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",
    "http://localhost:8545"
    );

    console.log( ens.defaultChain);
    > mainnet

    Parameters

    Returns ENS

Properties

config

readonlyproviders

providers: { HttpProvider: Web3BaseProviderConstructor; WebsocketProvider: Web3BaseProviderConstructor }

Type declaration

publicregistryAddress

registryAddress: string

The registryAddress property can be used to define a custom registry address when you are connected to an unknown chain. It defaults to the main registry address.

staticoptionalgivenProvider

givenProvider?: SupportedProviders<never>

staticreadonlyproviders

providers: { HttpProvider: Web3BaseProviderConstructor; WebsocketProvider: Web3BaseProviderConstructor }

Type declaration

Accessors

BatchRequest

accountProvider

blockHeaderTimeout

  • get blockHeaderTimeout(): number
  • set blockHeaderTimeout(val: number): void
  • The blockHeaderTimeout is used over socket-based connections. This option defines the amount seconds it should wait for 'newBlockHeaders' event before falling back to polling to fetch transaction receipt. Default is 10 seconds.


    Returns number

  • Will set the blockHeaderTimeout


    Parameters

    • val: number

    Returns void

contractDataInputFill

  • get contractDataInputFill(): input | data | both
  • set contractDataInputFill(val: input | data | both): void
  • The contractDataInputFill options property will allow you to set the hash of the method signature and encoded parameters to the property either data, input or both within your contract. This will affect the contracts send, call and estimateGas methods Default is data.


    Returns input | data | both

  • Will set the contractDataInputFill


    Parameters

    • val: input | data | both

    Returns void

currentProvider

  • Will return the current provider. (The same as provider)

    @example
    const web3Context = new Web3Context("http://localhost:8545");
    console.log(web3Context.provider);
    > HttpProvider {
    clientUrl: 'http://localhost:8545',
    httpProviderOptions: undefined
    }

    Returns undefined | Web3BaseProvider<API>

    Returns the current provider

  • Will set the current provider. (The same as provider)

    @example
     const web3Context = new Web3Context("http://localhost:8545");
    web3Context.currentProvider = "ws://localhost:8545";
    console.log(web3Context.provider);
    > WebSocketProvider {
    _eventEmitter: EventEmitter {
    _events: [Object: null prototype] {},
    _eventsCount: 0,
    ...
    }

    Parameters

    Returns void

customTransactionSchema

defaultAccount

  • get defaultAccount(): undefined | string
  • set defaultAccount(val: undefined | string): void
  • This default address is used as the default from property, if no from property is specified in for the following methods:

    • web3.eth.sendTransaction()
    • web3.eth.call()
    • myContract.methods.myMethod().call()
    • myContract.methods.myMethod().send()

    Returns undefined | string

  • Will set the default account.


    Parameters

    • val: undefined | string

    Returns void

defaultBlock

  • The default block is used for certain methods. You can override it by passing in the defaultBlock as last parameter. The default value is "latest".

    • web3.eth.getBalance()
    • web3.eth.getCode()
    • web3.eth.getTransactionCount()
    • web3.eth.getStorageAt()
    • web3.eth.call()
    • myContract.methods.myMethod().call()

    Returns BlockNumberOrTag

  • Will set the default block.

    • A block number
    • "earliest" - String: The genesis block
    • "latest" - String: The latest block (current head of the blockchain)
    • "pending" - String: The currently mined block (including pending transactions)
    • "finalized" - String: (For POS networks) The finalized block is one which has been accepted as canonical by greater than 2/3 of validators
    • "safe" - String: (For POS networks) The safe head block is one which under normal network conditions, is expected to be included in the canonical chain. Under normal network conditions the safe head and the actual tip of the chain will be equivalent (with safe head trailing only by a few seconds). Safe heads will be less likely to be reorged than the proof of work network's latest blocks.

    Parameters

    Returns void

defaultChain

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

  • Parameters

    • val: string

    Returns void

defaultCommon

  • get defaultCommon(): undefined | Common
  • set defaultCommon(val: undefined | Common): void
  • Will get the default common property The default common property does contain the following Common object:

    • customChain - Object: The custom chain properties
      • name - string: (optional) The name of the chain
      • networkId - number: Network ID of the custom chain
      • chainId - number: Chain ID of the custom chain
    • baseChain - string: (optional) mainnet, goerli, kovan, rinkeby, or ropsten
    • hardfork - string: (optional) chainstart, homestead, dao, tangerineWhistle, spuriousDragon, byzantium, constantinople, petersburg, istanbul, berlin, or london Default is undefined.

    Returns undefined | Common

  • Will set the default common property


    Parameters

    Returns void

defaultHardfork

  • get defaultHardfork(): string
  • set defaultHardfork(val: string): void
  • Will return the default hardfork. Default is london The default hardfork property can be one of the following:

    • chainstart
    • homestead
    • dao
    • tangerineWhistle
    • spuriousDragon
    • byzantium
    • constantinople
    • petersburg
    • istanbul
    • berlin
    • london
    • 'arrowGlacier',
    • 'tangerineWhistle',
    • 'muirGlacier'

    Returns string

  • Will set the default hardfork.


    Parameters

    • val: string

    Returns void

defaultMaxPriorityFeePerGas

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

  • Parameters

    Returns void

defaultNetworkId

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

  • Parameters

    Returns void

defaultReturnFormat

  • Returns DataFormat

  • Parameters

    Returns void

defaultTransactionType

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

  • Parameters

    Returns void

enableExperimentalFeatures

  • get enableExperimentalFeatures(): { useRpcCallSpecification: boolean; useSubscriptionWhenCheckingBlockTimeout: boolean }
  • set enableExperimentalFeatures(val: { useRpcCallSpecification: boolean; useSubscriptionWhenCheckingBlockTimeout: boolean }): void
  • The enableExperimentalFeatures is used to enable trying new experimental features that are still not fully implemented or not fully tested or still have some related issues. Default is false for every feature.


    Returns { useRpcCallSpecification: boolean; useSubscriptionWhenCheckingBlockTimeout: boolean }

    • useRpcCallSpecification: boolean
    • useSubscriptionWhenCheckingBlockTimeout: boolean
  • Will set the enableExperimentalFeatures


    Parameters

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

    Returns void

publicevents

  • get events(): ContractEventsInterface<readonly [{ anonymous: false; inputs: readonly [{ indexed: true; internalType: bytes32; name: node; type: bytes32 }, { indexed: true; internalType: bytes32; name: label; type: bytes32 }, { indexed: false; internalType: address; name: owner; type: address }]; name: NewOwner; type: event }, { anonymous: false; inputs: readonly [{ indexed: true; internalType: bytes32; name: node; type: bytes32 }, { indexed: false; internalType: address; name: resolver; type: address }]; name: NewResolver; type: event }, { anonymous: false; inputs: readonly [{ indexed: true; internalType: bytes32; name: node; type: bytes32 }, { indexed: false; internalType: address; name: owner; type: address }]; name: Transfer; type: event }, { inputs: readonly [{ internalType: address; name: owner; type: address }, { internalType: address; name: operator; type: address }]; name: isApprovedForAll; outputs: readonly [{ internalType: bool; name: ; type: bool }]; stateMutability: view; type: function }, { inputs: readonly [{ internalType: bytes32; name: node; type: bytes32 }]; name: owner; outputs: readonly [{ internalType: address; name: ; type: address }]; stateMutability: view; type: function }, { inputs: readonly [{ internalType: bytes32; name: node; type: bytes32 }]; name: recordExists; outputs: readonly [{ internalType: bool; name: ; type: bool }]; stateMutability: view; type: function }, { inputs: readonly [{ internalType: bytes32; name: node; type: bytes32 }]; name: resolver; outputs: readonly [{ internalType: address; name: ; type: address }]; stateMutability: view; type: function }, { inputs: readonly [{ internalType: bytes32; name: node; type: bytes32 }]; name: ttl; outputs: readonly [{ internalType: uint64; name: ; type: uint64 }]; stateMutability: view; type: function }], ContractEvents<readonly [{ anonymous: false; inputs: readonly [{ indexed: true; internalType: bytes32; name: node; type: bytes32 }, { indexed: true; internalType: bytes32; name: label; type: bytes32 }, { indexed: false; internalType: address; name: owner; type: address }]; name: NewOwner; type: event }, { anonymous: false; inputs: readonly [{ indexed: true; internalType: bytes32; name: node; type: bytes32 }, { indexed: false; internalType: address; name: resolver; type: address }]; name: NewResolver; type: event }, { anonymous: false; inputs: readonly [{ indexed: true; internalType: bytes32; name: node; type: bytes32 }, { indexed: false; internalType: address; name: owner; type: address }]; name: Transfer; type: event }, { inputs: readonly [{ internalType: address; name: owner; type: address }, { internalType: address; name: operator; type: address }]; name: isApprovedForAll; outputs: readonly [{ internalType: bool; name: ; type: bool }]; stateMutability: view; type: function }, { inputs: readonly [{ internalType: bytes32; name: node; type: bytes32 }]; name: owner; outputs: readonly [{ internalType: address; name: ; type: address }]; stateMutability: view; type: function }, { inputs: readonly [{ internalType: bytes32; name: node; type: bytes32 }]; name: recordExists; outputs: readonly [{ internalType: bool; name: ; type: bool }]; stateMutability: view; type: function }, { inputs: readonly [{ internalType: bytes32; name: node; type: bytes32 }]; name: resolver; outputs: readonly [{ internalType: address; name: ; type: address }]; stateMutability: view; type: function }, { inputs: readonly [{ internalType: bytes32; name: node; type: bytes32 }]; name: ttl; outputs: readonly [{ internalType: uint64; name: ; type: uint64 }]; stateMutability: view; type: function }]>>

  • Returns ContractEventsInterface<readonly [{ anonymous: false; inputs: readonly [{ indexed: true; internalType: bytes32; name: node; type: bytes32 }, { indexed: true; internalType: bytes32; name: label; type: bytes32 }, { indexed: false; internalType: address; name: owner; type: address }]; name: NewOwner; type: event }, { anonymous: false; inputs: readonly [{ indexed: true; internalType: bytes32; name: node; type: bytes32 }, { indexed: false; internalType: address; name: resolver; type: address }]; name: NewResolver; type: event }, { anonymous: false; inputs: readonly [{ indexed: true; internalType: bytes32; name: node; type: bytes32 }, { indexed: false; internalType: address; name: owner; type: address }]; name: Transfer; type: event }, { inputs: readonly [{ internalType: address; name: owner; type: address }, { internalType: address; name: operator; type: address }]; name: isApprovedForAll; outputs: readonly [{ internalType: bool; name: ; type: bool }]; stateMutability: view; type: function }, { inputs: readonly [{ internalType: bytes32; name: node; type: bytes32 }]; name: owner; outputs: readonly [{ internalType: address; name: ; type: address }]; stateMutability: view; type: function }, { inputs: readonly [{ internalType: bytes32; name: node; type: bytes32 }]; name: recordExists; outputs: readonly [{ internalType: bool; name: ; type: bool }]; stateMutability: view; type: function }, { inputs: readonly [{ internalType: bytes32; name: node; type: bytes32 }]; name: resolver; outputs: readonly [{ internalType: address; name: ; type: address }]; stateMutability: view; type: function }, { inputs: readonly [{ internalType: bytes32; name: node; type: bytes32 }]; name: ttl; outputs: readonly [{ internalType: uint64; name: ; type: uint64 }]; stateMutability: view; type: function }], ContractEvents<readonly [{ anonymous: false; inputs: readonly [{ indexed: true; internalType: bytes32; name: node; type: bytes32 }, { indexed: true; internalType: bytes32; name: label; type: bytes32 }, { indexed: false; internalType: address; name: owner; type: address }]; name: NewOwner; type: event }, { anonymous: false; inputs: readonly [{ indexed: true; internalType: bytes32; name: node; type: bytes32 }, { indexed: false; internalType: address; name: resolver; type: address }]; name: NewResolver; type: event }, { anonymous: false; inputs: readonly [{ indexed: true; internalType: bytes32; name: node; type: bytes32 }, { indexed: false; internalType: address; name: owner; type: address }]; name: Transfer; type: event }, { inputs: readonly [{ internalType: address; name: owner; type: address }, { internalType: address; name: operator; type: address }]; name: isApprovedForAll; outputs: readonly [{ internalType: bool; name: ; type: bool }]; stateMutability: view; type: function }, { inputs: readonly [{ internalType: bytes32; name: node; type: bytes32 }]; name: owner; outputs: readonly [{ internalType: address; name: ; type: address }]; stateMutability: view; type: function }, { inputs: readonly [{ internalType: bytes32; name: node; type: bytes32 }]; name: recordExists; outputs: readonly [{ internalType: bool; name: ; type: bool }]; stateMutability: view; type: function }, { inputs: readonly [{ internalType: bytes32; name: node; type: bytes32 }]; name: resolver; outputs: readonly [{ internalType: address; name: ; type: address }]; stateMutability: view; type: function }, { inputs: readonly [{ internalType: bytes32; name: node; type: bytes32 }]; name: ttl; outputs: readonly [{ internalType: uint64; name: ; type: uint64 }]; stateMutability: view; type: function }]>>

    • Returns all events that can be emitted by the ENS registry.

givenProvider

  • Will return the givenProvider if available.

    When using web3.js in an Ethereum compatible browser, it will set with the current native provider by that browser. Will return the given provider by the (browser) environment, otherwise undefined.


    Returns undefined | SupportedProviders<never>

handleRevert

  • get handleRevert(): boolean
  • set handleRevert(val: boolean): void
  • The handleRevert options property returns the revert reason string if enabled for the following methods:

    • web3.eth.sendTransaction()
    • web3.eth.call()
    • myContract.methods.myMethod().call()
    • myContract.methods.myMethod().send() Default is false.

    Note: At the moment handleRevert is only supported for sendTransaction and not for sendSignedTransaction


    Returns boolean

  • Will set the handleRevert


    Parameters

    • val: boolean

    Returns void

ignoreGasPricing

  • get ignoreGasPricing(): boolean
  • set ignoreGasPricing(val: boolean): void
  • Will get the ignoreGasPricing property. When true, the gasPrice, maxPriorityFeePerGas, and maxFeePerGas will not be autofilled in the transaction object. Useful when you want wallets to handle gas pricing.


    Returns boolean

  • Parameters

    • val: boolean

    Returns void

maxListenersWarningThreshold

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

  • Parameters

    • val: number

    Returns void

provider

  • Will return the current provider.

    @example
    const web3 = new Web3Context("http://localhost:8545");
    console.log(web3.provider);
    > HttpProvider {
    clientUrl: 'http://localhost:8545',
    httpProviderOptions: undefined
    }

    Returns undefined | Web3BaseProvider<API>

    Returns the current provider

  • Will set the current provider.

    @example
     const web3Context = new web3ContextContext("http://localhost:8545");
    web3Context.provider = "ws://localhost:8545";
    console.log(web3Context.provider);
    > WebSocketProvider {
    _eventEmitter: EventEmitter {
    _events: [Object: null prototype] {},
    _eventsCount: 0,
    ...
    }

    Parameters

    Returns void

requestManager

subscriptionManager

transactionBlockTimeout

  • get transactionBlockTimeout(): number
  • set transactionBlockTimeout(val: number): void
  • The transactionBlockTimeout is used over socket-based connections. This option defines the amount of new blocks it should wait until the first confirmation happens, otherwise the PromiEvent rejects with a timeout error. Default is 50.


    Returns number

  • Will set the transactionBlockTimeout.


    Parameters

    • val: number

    Returns void

transactionBuilder

  • Returns undefined | TransactionBuilder<unknown>

  • Parameters

    Returns void

transactionConfirmationBlocks

  • get transactionConfirmationBlocks(): number
  • set transactionConfirmationBlocks(val: number): void
  • This defines the number of blocks it requires until a transaction is considered confirmed. Default is 24.


    Returns number

  • Will set the transactionConfirmationBlocks.


    Parameters

    • val: number

    Returns void

transactionConfirmationPollingInterval

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

  • Parameters

    • val: undefined | number

    Returns void

transactionPollingInterval

  • get transactionPollingInterval(): number
  • set transactionPollingInterval(val: number): void
  • Used over HTTP connections. This option defines the number of seconds between Web3 calls for a receipt which confirms that a transaction was mined by the network. Default is 1000 ms.


    Returns number

  • Will set the transactionPollingInterval.


    Parameters

    • val: number

    Returns void

transactionPollingTimeout

  • get transactionPollingTimeout(): number
  • set transactionPollingTimeout(val: number): void
  • Used over HTTP connections. This option defines the number of seconds Web3 will wait for a receipt which confirms that a transaction was mined by the network. Note: If this method times out, the transaction may still be pending. Default is 750 seconds (12.5 minutes).


    Returns number

  • Will set the transactionPollingTimeout.


    Parameters

    • val: number

    Returns void

transactionReceiptPollingInterval

  • get transactionReceiptPollingInterval(): undefined | number
  • set transactionReceiptPollingInterval(val: undefined | number): void
  • The transactionPollingInterval is used over HTTP connections. This option defines the number of seconds between Web3 calls for a receipt which confirms that a transaction was mined by the network. Default is undefined


    Returns undefined | number

  • Will set the transactionReceiptPollingInterval


    Parameters

    • val: undefined | number

    Returns void

transactionSendTimeout

  • get transactionSendTimeout(): number
  • set transactionSendTimeout(val: number): void
  • The time used to wait for Ethereum Node to return the sent transaction result. Note: If the RPC call stuck at the Node and therefor timed-out, the transaction may still be pending or even mined by the Network. We recommend checking the pending transactions in such a case. Default is 750 seconds (12.5 minutes).


    Returns number

  • Will set the transactionSendTimeout.


    Parameters

    • val: number

    Returns void

transactionTypeParser

wallet

Methods

publiccheckNetwork

  • checkNetwork(): Promise<string>
  • Checks if the current used network is synced and looks for ENS support there. Throws an error if not.

    @example
    console.log(await web3.eth.ens.checkNetwork());
    > '0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e'

    Returns Promise<string>

    • The address of the ENS registry if the network has been detected successfully

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: contractDataInputFill; newValue: input | data | both; oldValue: input | data | both } | { name: defaultNetworkId; newValue: undefined | Numbers; oldValue: undefined | Numbers } | { name: defaultChain; newValue: string; oldValue: string } | { name: defaultHardfork; newValue: string; oldValue: string } | { name: ignoreGasPricing; newValue: boolean; oldValue: boolean } | { 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 } | { name: customTransactionSchema; newValue: undefined | CustomTransactionSchema; oldValue: undefined | CustomTransactionSchema } | { name: defaultReturnFormat; newValue: DataFormat; oldValue: DataFormat } }[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: contractDataInputFill; newValue: input | data | both; oldValue: input | data | both } | { name: defaultNetworkId; newValue: undefined | Numbers; oldValue: undefined | Numbers } | { name: defaultChain; newValue: string; oldValue: string } | { name: defaultHardfork; newValue: string; oldValue: string } | { name: ignoreGasPricing; newValue: boolean; oldValue: boolean } | { 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 } | { name: customTransactionSchema; newValue: undefined | CustomTransactionSchema; oldValue: undefined | CustomTransactionSchema } | { name: defaultReturnFormat; newValue: DataFormat; oldValue: DataFormat } }[K]

    Returns void

eventNames

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

extend

  • This method allows extending the web3 modules. Note: This method is only for backward compatibility, and It is recommended to use Web3 v4 Plugin feature for extending web3.js functionality if you are developing something new.


    Parameters

    Returns this

publicgetAddress

  • getAddress(ENSName: string, coinType?: number): Promise<MatchPrimitiveType<bytes, unknown>>
  • Resolves an ENS name to an Ethereum address.


    Parameters

    • ENSName: string

      The ENS name to resolve

    • coinType: number = 60

      (Optional) The coin type, defaults to 60 (ETH)

    Returns Promise<MatchPrimitiveType<bytes, unknown>>

    • The Ethereum address of the given name
    const address = await web3.eth.ens.getAddress('ethereum.eth');
    console.log(address);
    > '0xfB6916095ca1df60bB79Ce92cE3Ea74c37c5d359'

publicgetContenthash

  • Returns the content hash object associated with an ENS node.

    @example
    const hash = await web3.eth.ens.getContenthash('ethereum.eth');
    console.log(hash);
    > 'QmaEBknbGT4bTQiQoe2VNgBJbRfygQGktnaW5TbuKixjYL'

    Parameters

    • ENSName: string

      The ENS name

    Returns Promise<MatchPrimitiveType<bytes, unknown>>

    • The content hash object associated with an ENS node

getContextObject

getMaxListeners

  • getMaxListeners(): number
  • Returns number

publicgetName

  • getName(ENSName: string, checkInterfaceSupport?: boolean): Promise<string>
  • Resolves the name of an ENS node.


    Parameters

    • ENSName: string

      The node to resolve

    • checkInterfaceSupport: boolean = true

    Returns Promise<string>

    • The name

publicgetOwner

  • getOwner(name: string): Promise<unknown>
  • Returns the owner by the given name and current configured or detected Registry

    @example
    const owner = await web3.eth.ens.getOwner('ethereum.eth');

    Parameters

    • name: string

      The ENS name

    Returns Promise<unknown>

    • Returns the address of the owner of the name.

publicgetPubkey

  • Returns the X and Y coordinates of the curve point for the public key.

    @example
    const key = await web3.eth.ens.getPubkey('ethereum.eth');
    console.log(key);
    > {
    "0": "0x0000000000000000000000000000000000000000000000000000000000000000",
    "1": "0x0000000000000000000000000000000000000000000000000000000000000000",
    "x": "0x0000000000000000000000000000000000000000000000000000000000000000",
    "y": "0x0000000000000000000000000000000000000000000000000000000000000000"
    }

    Parameters

    • ENSName: string

      The ENS name

    Returns Promise<unknown[] & Record<1, MatchPrimitiveType<bytes32, unknown>> & Record<0, MatchPrimitiveType<bytes32, unknown>> & [] & Record<x, MatchPrimitiveType<bytes32, unknown>> & Record<y, MatchPrimitiveType<bytes32, unknown>>>

    • The X and Y coordinates of the curve point for the public key

publicgetResolver

  • getResolver(name: string): Promise<Contract<readonly [{ anonymous: false; inputs: readonly [{ indexed: true; internalType: bytes32; name: node; type: bytes32 }, { indexed: false; internalType: address; name: a; type: address }]; name: AddrChanged; type: event }, { anonymous: false; inputs: readonly [{ indexed: true; internalType: bytes32; name: node; type: bytes32 }, { indexed: false; internalType: uint256; name: coinType; type: uint256 }, { indexed: false; internalType: bytes; name: newAddress; type: bytes }]; name: AddressChanged; type: event }, { anonymous: false; inputs: readonly [{ indexed: true; internalType: address; name: owner; type: address }, { indexed: true; internalType: address; name: operator; type: address }, { indexed: false; internalType: bool; name: approved; type: bool }]; name: ApprovalForAll; type: event }, { anonymous: false; inputs: readonly [{ indexed: true; internalType: bytes32; name: node; type: bytes32 }, { indexed: false; internalType: bytes; name: hash; type: bytes }]; name: ContenthashChanged; type: event }, { anonymous: false; inputs: readonly [{ indexed: true; internalType: bytes32; name: node; type: bytes32 }, { indexed: false; internalType: bytes; name: name; type: bytes }, { indexed: false; internalType: uint16; name: resource; type: uint16 }, { indexed: false; internalType: bytes; name: record; type: bytes }]; name: DNSRecordChanged; type: event }, { anonymous: false; inputs: readonly [{ indexed: true; internalType: bytes32; name: node; type: bytes32 }, { indexed: false; internalType: bytes; name: name; type: bytes }, { indexed: false; internalType: uint16; name: resource; type: uint16 }]; name: DNSRecordDeleted; type: event }, { anonymous: false; inputs: readonly [{ indexed: true; internalType: bytes32; name: node; type: bytes32 }]; name: DNSZoneCleared; type: event }, { anonymous: false; inputs: readonly [{ indexed: true; internalType: bytes32; name: node; type: bytes32 }, { indexed: false; internalType: bytes; name: lastzonehash; type: bytes }, { indexed: false; internalType: bytes; name: zonehash; type: bytes }]; name: DNSZonehashChanged; type: event }, { anonymous: false; inputs: readonly [{ indexed: true; internalType: bytes32; name: node; type: bytes32 }, { indexed: true; internalType: bytes4; name: interfaceID; type: bytes4 }, { indexed: false; internalType: address; name: implementer; type: address }]; name: InterfaceChanged; type: event }, { anonymous: false; inputs: readonly [{ indexed: true; internalType: bytes32; name: node; type: bytes32 }, { indexed: false; internalType: string; name: name; type: string }]; name: NameChanged; type: event }, { anonymous: false; inputs: readonly [{ indexed: true; internalType: bytes32; name: node; type: bytes32 }, { indexed: false; internalType: bytes32; name: x; type: bytes32 }, { indexed: false; internalType: bytes32; name: y; type: bytes32 }]; name: PubkeyChanged; type: event }, { anonymous: false; inputs: readonly [{ indexed: true; internalType: bytes32; name: node; type: bytes32 }, { indexed: true; internalType: string; name: indexedKey; type: string }, { indexed: false; internalType: string; name: key; type: string }]; name: TextChanged; type: event }, { inputs: readonly [{ internalType: bytes32; name: node; type: bytes32 }, { internalType: uint256; name: contentTypes; type: uint256 }]; name: ABI; outputs: readonly [{ internalType: uint256; name: ; type: uint256 }, { internalType: bytes; name: ; type: bytes }]; stateMutability: view; type: function }, { inputs: readonly [{ internalType: bytes32; name: node; type: bytes32 }]; name: addr; outputs: readonly [{ internalType: address payable; name: ; type: address }]; stateMutability: view; type: function }, { inputs: readonly [{ internalType: bytes32; name: node; type: bytes32 }, { internalType: uint256; name: coinType; type: uint256 }]; name: addr; outputs: readonly [{ internalType: bytes; name: ; type: bytes }]; stateMutability: view; type: function }, { inputs: readonly [{ internalType: bytes32; name: node; type: bytes32 }]; name: contenthash; outputs: readonly [{ internalType: bytes; name: ; type: bytes }]; stateMutability: view; type: function }, { inputs: readonly [{ internalType: bytes32; name: node; type: bytes32 }, { internalType: bytes32; name: name; type: bytes32 }, { internalType: uint16; name: resource; type: uint16 }]; name: dnsRecord; outputs: readonly [{ internalType: bytes; name: ; type: bytes }]; stateMutability: view; type: function }, { inputs: readonly [{ internalType: bytes32; name: node; type: bytes32 }, { internalType: bytes32; name: name; type: bytes32 }]; name: hasDNSRecords; outputs: readonly [{ internalType: bool; name: ; type: bool }]; stateMutability: view; type: function }, { inputs: readonly [{ internalType: bytes32; name: node; type: bytes32 }, { internalType: bytes4; name: interfaceID; type: bytes4 }]; name: interfaceImplementer; outputs: readonly [{ internalType: address; name: ; type: address }]; stateMutability: view; type: function }, { inputs: readonly [{ internalType: address; name: account; type: address }, { internalType: address; name: operator; type: address }]; name: isApprovedForAll; outputs: readonly [{ internalType: bool; name: ; type: bool }]; stateMutability: view; type: function }, { inputs: readonly [{ internalType: bytes32; name: node; type: bytes32 }]; name: name; outputs: readonly [{ internalType: string; name: ; type: string }]; stateMutability: view; type: function }, { inputs: readonly [{ internalType: bytes32; name: node; type: bytes32 }]; name: pubkey; outputs: readonly [{ internalType: bytes32; name: x; type: bytes32 }, { internalType: bytes32; name: y; type: bytes32 }]; stateMutability: view; type: function }, { inputs: readonly [{ internalType: bytes4; name: interfaceID; type: bytes4 }]; name: supportsInterface; outputs: readonly [{ internalType: bool; name: ; type: bool }]; stateMutability: view; type: function }, { inputs: readonly [{ internalType: bytes32; name: node; type: bytes32 }, { internalType: string; name: key; type: string }]; name: text; outputs: readonly [{ internalType: string; name: ; type: string }]; stateMutability: view; type: function }, { inputs: readonly [{ internalType: bytes32; name: node; type: bytes32 }]; name: zonehash; outputs: readonly [{ internalType: bytes; name: ; type: bytes }]; stateMutability: view; type: function }, { inputs: readonly [{ internalType: bytes32; name: node; type: bytes32 }, { internalType: address; name: a; type: address }]; name: setAddr; outputs: readonly []; stateMutability: nonpayable; type: function }]>>
  • Returns the Resolver by the given address

    @example
    const resolver = await ens.getResolver('resolver');

    console.log(resolver.options.address);
    > '0x1234567890123456789012345678901234567890'

    Parameters

    • name: string

      The name of the ENS domain

    Returns Promise<Contract<readonly [{ anonymous: false; inputs: readonly [{ indexed: true; internalType: bytes32; name: node; type: bytes32 }, { indexed: false; internalType: address; name: a; type: address }]; name: AddrChanged; type: event }, { anonymous: false; inputs: readonly [{ indexed: true; internalType: bytes32; name: node; type: bytes32 }, { indexed: false; internalType: uint256; name: coinType; type: uint256 }, { indexed: false; internalType: bytes; name: newAddress; type: bytes }]; name: AddressChanged; type: event }, { anonymous: false; inputs: readonly [{ indexed: true; internalType: address; name: owner; type: address }, { indexed: true; internalType: address; name: operator; type: address }, { indexed: false; internalType: bool; name: approved; type: bool }]; name: ApprovalForAll; type: event }, { anonymous: false; inputs: readonly [{ indexed: true; internalType: bytes32; name: node; type: bytes32 }, { indexed: false; internalType: bytes; name: hash; type: bytes }]; name: ContenthashChanged; type: event }, { anonymous: false; inputs: readonly [{ indexed: true; internalType: bytes32; name: node; type: bytes32 }, { indexed: false; internalType: bytes; name: name; type: bytes }, { indexed: false; internalType: uint16; name: resource; type: uint16 }, { indexed: false; internalType: bytes; name: record; type: bytes }]; name: DNSRecordChanged; type: event }, { anonymous: false; inputs: readonly [{ indexed: true; internalType: bytes32; name: node; type: bytes32 }, { indexed: false; internalType: bytes; name: name; type: bytes }, { indexed: false; internalType: uint16; name: resource; type: uint16 }]; name: DNSRecordDeleted; type: event }, { anonymous: false; inputs: readonly [{ indexed: true; internalType: bytes32; name: node; type: bytes32 }]; name: DNSZoneCleared; type: event }, { anonymous: false; inputs: readonly [{ indexed: true; internalType: bytes32; name: node; type: bytes32 }, { indexed: false; internalType: bytes; name: lastzonehash; type: bytes }, { indexed: false; internalType: bytes; name: zonehash; type: bytes }]; name: DNSZonehashChanged; type: event }, { anonymous: false; inputs: readonly [{ indexed: true; internalType: bytes32; name: node; type: bytes32 }, { indexed: true; internalType: bytes4; name: interfaceID; type: bytes4 }, { indexed: false; internalType: address; name: implementer; type: address }]; name: InterfaceChanged; type: event }, { anonymous: false; inputs: readonly [{ indexed: true; internalType: bytes32; name: node; type: bytes32 }, { indexed: false; internalType: string; name: name; type: string }]; name: NameChanged; type: event }, { anonymous: false; inputs: readonly [{ indexed: true; internalType: bytes32; name: node; type: bytes32 }, { indexed: false; internalType: bytes32; name: x; type: bytes32 }, { indexed: false; internalType: bytes32; name: y; type: bytes32 }]; name: PubkeyChanged; type: event }, { anonymous: false; inputs: readonly [{ indexed: true; internalType: bytes32; name: node; type: bytes32 }, { indexed: true; internalType: string; name: indexedKey; type: string }, { indexed: false; internalType: string; name: key; type: string }]; name: TextChanged; type: event }, { inputs: readonly [{ internalType: bytes32; name: node; type: bytes32 }, { internalType: uint256; name: contentTypes; type: uint256 }]; name: ABI; outputs: readonly [{ internalType: uint256; name: ; type: uint256 }, { internalType: bytes; name: ; type: bytes }]; stateMutability: view; type: function }, { inputs: readonly [{ internalType: bytes32; name: node; type: bytes32 }]; name: addr; outputs: readonly [{ internalType: address payable; name: ; type: address }]; stateMutability: view; type: function }, { inputs: readonly [{ internalType: bytes32; name: node; type: bytes32 }, { internalType: uint256; name: coinType; type: uint256 }]; name: addr; outputs: readonly [{ internalType: bytes; name: ; type: bytes }]; stateMutability: view; type: function }, { inputs: readonly [{ internalType: bytes32; name: node; type: bytes32 }]; name: contenthash; outputs: readonly [{ internalType: bytes; name: ; type: bytes }]; stateMutability: view; type: function }, { inputs: readonly [{ internalType: bytes32; name: node; type: bytes32 }, { internalType: bytes32; name: name; type: bytes32 }, { internalType: uint16; name: resource; type: uint16 }]; name: dnsRecord; outputs: readonly [{ internalType: bytes; name: ; type: bytes }]; stateMutability: view; type: function }, { inputs: readonly [{ internalType: bytes32; name: node; type: bytes32 }, { internalType: bytes32; name: name; type: bytes32 }]; name: hasDNSRecords; outputs: readonly [{ internalType: bool; name: ; type: bool }]; stateMutability: view; type: function }, { inputs: readonly [{ internalType: bytes32; name: node; type: bytes32 }, { internalType: bytes4; name: interfaceID; type: bytes4 }]; name: interfaceImplementer; outputs: readonly [{ internalType: address; name: ; type: address }]; stateMutability: view; type: function }, { inputs: readonly [{ internalType: address; name: account; type: address }, { internalType: address; name: operator; type: address }]; name: isApprovedForAll; outputs: readonly [{ internalType: bool; name: ; type: bool }]; stateMutability: view; type: function }, { inputs: readonly [{ internalType: bytes32; name: node; type: bytes32 }]; name: name; outputs: readonly [{ internalType: string; name: ; type: string }]; stateMutability: view; type: function }, { inputs: readonly [{ internalType: bytes32; name: node; type: bytes32 }]; name: pubkey; outputs: readonly [{ internalType: bytes32; name: x; type: bytes32 }, { internalType: bytes32; name: y; type: bytes32 }]; stateMutability: view; type: function }, { inputs: readonly [{ internalType: bytes4; name: interfaceID; type: bytes4 }]; name: supportsInterface; outputs: readonly [{ internalType: bool; name: ; type: bool }]; stateMutability: view; type: function }, { inputs: readonly [{ internalType: bytes32; name: node; type: bytes32 }, { internalType: string; name: key; type: string }]; name: text; outputs: readonly [{ internalType: string; name: ; type: string }]; stateMutability: view; type: function }, { inputs: readonly [{ internalType: bytes32; name: node; type: bytes32 }]; name: zonehash; outputs: readonly [{ internalType: bytes; name: ; type: bytes }]; stateMutability: view; type: function }, { inputs: readonly [{ internalType: bytes32; name: node; type: bytes32 }, { internalType: address; name: a; type: address }]; name: setAddr; outputs: readonly []; stateMutability: nonpayable; type: function }]>>

    • An contract instance of the resolver

publicgetTTL

  • getTTL(name: string): Promise<unknown>
  • Returns the caching TTL (time-to-live) of an ENS name.

    @example
    const owner = await web3.eth.ens.getTTL('ethereum.eth');

    Parameters

    • name: string

      The ENS name

    Returns Promise<unknown>

    • Returns the caching TTL (time-to-live) of a name.

publicgetText

  • getText(ENSNameOrAddr: string, key: string): Promise<string>

link

  • link<T>(parentContext: T): void
  • Link current context to another context.


    Type parameters

    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): (...args: any[]) => void[]
  • Type parameters

    • K: CONFIG_CHANGE

    Parameters

    • eventName: K

    Returns (...args: any[]) => void[]

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: contractDataInputFill; newValue: input | data | both; oldValue: input | data | both } | { name: defaultNetworkId; newValue: undefined | Numbers; oldValue: undefined | Numbers } | { name: defaultChain; newValue: string; oldValue: string } | { name: defaultHardfork; newValue: string; oldValue: string } | { name: ignoreGasPricing; newValue: boolean; oldValue: boolean } | { 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 } | { name: customTransactionSchema; newValue: undefined | CustomTransactionSchema; oldValue: undefined | CustomTransactionSchema } | { name: defaultReturnFormat; newValue: DataFormat; oldValue: DataFormat } }[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: contractDataInputFill; newValue: input | data | both; oldValue: input | data | both } | { name: defaultNetworkId; newValue: undefined | Numbers; oldValue: undefined | Numbers } | { name: defaultChain; newValue: string; oldValue: string } | { name: defaultHardfork; newValue: string; oldValue: string } | { name: ignoreGasPricing; newValue: boolean; oldValue: boolean } | { 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 } | { name: customTransactionSchema; newValue: undefined | CustomTransactionSchema; oldValue: undefined | CustomTransactionSchema } | { name: defaultReturnFormat; newValue: DataFormat; oldValue: DataFormat } }[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: contractDataInputFill; newValue: input | data | both; oldValue: input | data | both } | { name: defaultNetworkId; newValue: undefined | Numbers; oldValue: undefined | Numbers } | { name: defaultChain; newValue: string; oldValue: string } | { name: defaultHardfork; newValue: string; oldValue: string } | { name: ignoreGasPricing; newValue: boolean; oldValue: boolean } | { 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 } | { name: customTransactionSchema; newValue: undefined | CustomTransactionSchema; oldValue: undefined | CustomTransactionSchema } | { name: defaultReturnFormat; newValue: DataFormat; oldValue: DataFormat } }[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: contractDataInputFill; newValue: input | data | both; oldValue: input | data | both } | { name: defaultNetworkId; newValue: undefined | Numbers; oldValue: undefined | Numbers } | { name: defaultChain; newValue: string; oldValue: string } | { name: defaultHardfork; newValue: string; oldValue: string } | { name: ignoreGasPricing; newValue: boolean; oldValue: boolean } | { 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 } | { name: customTransactionSchema; newValue: undefined | CustomTransactionSchema; oldValue: undefined | CustomTransactionSchema } | { name: defaultReturnFormat; newValue: DataFormat; oldValue: DataFormat } }[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: contractDataInputFill; newValue: input | data | both; oldValue: input | data | both } | { name: defaultNetworkId; newValue: undefined | Numbers; oldValue: undefined | Numbers } | { name: defaultChain; newValue: string; oldValue: string } | { name: defaultHardfork; newValue: string; oldValue: string } | { name: ignoreGasPricing; newValue: boolean; oldValue: boolean } | { 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 } | { name: customTransactionSchema; newValue: undefined | CustomTransactionSchema; oldValue: undefined | CustomTransactionSchema } | { name: defaultReturnFormat; newValue: DataFormat; oldValue: DataFormat } }[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: contractDataInputFill; newValue: input | data | both; oldValue: input | data | both } | { name: defaultNetworkId; newValue: undefined | Numbers; oldValue: undefined | Numbers } | { name: defaultChain; newValue: string; oldValue: string } | { name: defaultHardfork; newValue: string; oldValue: string } | { name: ignoreGasPricing; newValue: boolean; oldValue: boolean } | { 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 } | { name: customTransactionSchema; newValue: undefined | CustomTransactionSchema; oldValue: undefined | CustomTransactionSchema } | { name: defaultReturnFormat; newValue: DataFormat; oldValue: DataFormat } }[K]>

    Returns void

publicrecordExists

  • recordExists(name: string): Promise<unknown>
  • Returns true if the record exists

    @example
    const exists = await web3.eth.ens.recordExists('ethereum.eth');

    Parameters

    • name: string

      The ENS name

    Returns Promise<unknown>

    • Returns true if node exists in this ENS registry. This will return false for records that are in the legacy ENS registry but have not yet been migrated to the new one.

registerPlugin

  • Parameters

    Returns void

removeAllListeners

  • Returns EventEmitter

publicsetAddress

  • Sets the address of an ENS name in his resolver.


    Parameters

    • name: string

      The ENS name

    • address: string

      The address to set

    • txConfig: PayableCallOptions

      (Optional) The transaction config

    Returns Promise<TransactionReceipt | RevertInstructionError>

    • The transaction receipt
    const receipt = await ens.setAddress('web3js.eth','0xe2597eb05cf9a87eb1309e86750c903ec38e527e');

setConfig

  • Parameters

    Returns void

setMaxListenerWarningThreshold

  • setMaxListenerWarningThreshold(maxListenersWarningThreshold: number): void
  • Parameters

    • maxListenersWarningThreshold: number

    Returns void

setProvider

setRequestManagerMiddleware

publicsupportsInterface

  • supportsInterface(ENSName: string, interfaceId: string): Promise<MatchPrimitiveType<bool, unknown>>
  • Returns true if the related Resolver does support the given signature or interfaceId.

    @example
    const supports = await web3.eth.ens.supportsInterface('ethereum.eth', 'addr(bytes32');
    console.log(supports);
    > true

    Parameters

    • ENSName: string

      The ENS name

    • interfaceId: string

      The signature of the function or the interfaceId as described in the ENS documentation

    Returns Promise<MatchPrimitiveType<bool, unknown>>

    • true if the related Resolver does support the given signature or interfaceId.

use

  • Use to create new object of any type extended by Web3Context and link it to current context. This can be used to initiate a global context object and then use it to create new objects of any type extended by Web3Context.


    Type parameters

    Parameters

    Returns T

staticfromContextObject