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
-
Web3Context
<EthExecutionAPI
&Web3NetAPI
>↳
ENS
Constructors
constructor
• new ENS(registryAddr?
, provider?
): ENS
Use to create an instance of ENS
Parameters
Name | Type | Description |
---|---|---|
registryAddr? | string | (Optional) The address of the ENS registry (default: mainnet registry address) |
provider? | string | LegacyRequestProvider | LegacySendProvider | LegacySendAsyncProvider | EIP1193Provider <EthExecutionAPI & Web3NetAPI > | Web3BaseProvider <EthExecutionAPI & Web3NetAPI > | SimpleProvider <EthExecutionAPI & Web3NetAPI > | MetaMaskProvider <EthExecutionAPI & Web3NetAPI > | Web3ContextObject <EthExecutionAPI & Web3NetAPI , any > | (Optional) The provider to use for the ENS instance |
Returns
Example
const ens = new ENS(
"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",
"http://localhost:8545"
);
console.log( ens.defaultChain);
> mainnet
Overrides
Web3Context<EthExecutionAPI & Web3NetAPI>.constructor
Properties
registryAddress
• 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.
Accessors
BatchRequest
• get
BatchRequest(): Object
Will return the Web3BatchRequest constructor.
Returns
Object
Inherited from
Web3Context.BatchRequest
blockHeaderTimeout
• get
blockHeaderTimeout(): number
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
Inherited from
Web3Context.blockHeaderTimeout
• set
blockHeaderTimeout(val
): void
Will set the blockHeaderTimeout
Parameters
Name | Type |
---|---|
val | number |
Returns
void
Inherited from
Web3Context.blockHeaderTimeout
contractDataInputFill
• get
contractDataInputFill(): "data"
| "input"
| "both"
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 input
.
Returns
"data"
| "input"
| "both"
Inherited from
Web3Context.contractDataInputFill
• set
contractDataInputFill(val
): void
Will set the contractDataInputFill
Parameters
Name | Type |
---|---|
val | "data" | "input" | "both" |
Returns
void
Inherited from
Web3Context.contractDataInputFill
currentProvider
• get
currentProvider(): undefined
| Web3BaseProvider
<API
>
Will return the current provider. (The same as provider
)
Returns
undefined
| Web3BaseProvider
<API
>
Returns the current provider
Example
const web3Context = new Web3Context("http://localhost:8545");
console.log(web3Context.provider);
> HttpProvider {
clientUrl: 'http://localhost:8545',
httpProviderOptions: undefined
}
Inherited from
Web3Context.currentProvider
• set
currentProvider(provider
): void
Will set the current provider. (The same as provider
)
Parameters
Name | Type | Description |
---|---|---|
provider | undefined | string | LegacyRequestProvider | LegacySendProvider | LegacySendAsyncProvider | EIP1193Provider <API > | Web3BaseProvider <API > | SimpleProvider <API > | MetaMaskProvider <API > | SupportedProviders The provider to set |
Returns
void
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,
...
}
Inherited from
Web3Context.currentProvider
defaultAccount
• get
defaultAccount(): undefined
| string
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
Inherited from
Web3Context.defaultAccount
• set
defaultAccount(val
): void
Will set the default account.
Parameters
Name | Type |
---|---|
val | undefined | string |
Returns
void
Inherited from
Web3Context.defaultAccount
defaultBlock
• get
defaultBlock(): BlockNumberOrTag
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
Inherited from
Web3Context.defaultBlock
• set
defaultBlock(val
): void
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
Name | Type |
---|---|
val | BlockNumberOrTag |
Returns
void
Inherited from
Web3Context.defaultBlock
defaultCommon
• get
defaultCommon(): undefined
| Common
Will get the default common property The default common property does contain the following Common object:
customChain
-Object
: The custom chain propertiesname
-string
: (optional) The name of the chainnetworkId
-number
: Network ID of the custom chainchainId
-number
: Chain ID of the custom chain
baseChain
-string
: (optional) mainnet, goerli, kovan, rinkeby, or ropstenhardfork
-string
: (optional) chainstart, homestead, dao, tangerineWhistle, spuriousDragon, byzantium, constantinople, petersburg, istanbul, berlin, or london Default isundefined
.
Returns
undefined
| Common
Inherited from
Web3Context.defaultCommon
• set
defaultCommon(val
): void
Will set the default common property
Parameters
Name | Type |
---|---|
val | undefined | Common |
Returns
void
Inherited from
Web3Context.defaultCommon
defaultHardfork
• get
defaultHardfork(): string
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
Inherited from
Web3Context.defaultHardfork
• set
defaultHardfork(val
): void
Will set the default hardfork.
Parameters
Name | Type |
---|---|
val | string |
Returns
void
Inherited from
Web3Context.defaultHardfork
enableExperimentalFeatures
• get
enableExperimentalFeatures(): Object
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
Object
Name | Type |
---|---|
useRpcCallSpecification | boolean |
useSubscriptionWhenCheckingBlockTimeout | boolean |
Inherited from
Web3Context.enableExperimentalFeatures
• set
enableExperimentalFeatures(val
): void
Will set the enableExperimentalFeatures
Parameters
Name | Type |
---|---|
val | Object |
val.useRpcCallSpecification | boolean |
val.useSubscriptionWhenCheckingBlockTimeout | boolean |
Returns
void
Inherited from
Web3Context.enableExperimentalFeatures
events
• get
events(): ContractEventsInterface
<readonly [{ anonymous
: false
= false; inputs
: readonly [{ indexed
: true
= true; internalType
: "bytes32"
= 'bytes32'; name
: "node"
= 'node'; type
: "bytes32"
= 'bytes32' }, { indexed
: true
= true; internalType
: "bytes32"
= 'bytes32'; name
: "label"
= 'label'; type
: "bytes32"
= 'bytes32' }, { indexed
: false
= false; internalType
: "address"
= 'address'; name
: "owner"
= 'owner'; type
: "address"
= 'address' }] ; name
: "NewOwner"
= 'NewOwner'; type
: "event"
= 'event' }, { anonymous
: false
= false; inputs
: readonly [{ indexed
: true
= true; internalType
: "bytes32"
= 'bytes32'; name
: "node"
= 'node'; type
: "bytes32"
= 'bytes32' }, { indexed
: false
= false; internalType
: "address"
= 'address'; name
: "resolver"
= 'resolver'; type
: "address"
= 'address' }] ; name
: "NewResolver"
= 'NewResolver'; type
: "event"
= 'event' }, { anonymous
: false
= false; inputs
: readonly [{ indexed
: true
= true; internalType
: "bytes32"
= 'bytes32'; name
: "node"
= 'node'; type
: "bytes32"
= 'bytes32' }, { indexed
: false
= false; internalType
: "address"
= 'address'; name
: "owner"
= 'owner'; type
: "address"
= 'address' }] ; name
: "Transfer"
= 'Transfer'; type
: "event"
= 'event' }, { inputs
: readonly [{ internalType
: "address"
= 'address'; name
: "owner"
= 'owner'; type
: "address"
= 'address' }, { internalType
: "address"
= 'address'; name
: "operator"
= 'operator'; type
: "address"
= 'address' }] ; name
: "isApprovedForAll"
= 'isApprovedForAll'; outputs
: readonly [{ internalType
: "bool"
= 'bool'; name
: ""
= ''; type
: "bool"
= 'bool' }] ; stateMutability
: "view"
= 'view'; type
: "function"
= 'function' }, { inputs
: readonly [{ internalType
: "bytes32"
= 'bytes32'; name
: "node"
= 'node'; type
: "bytes32"
= 'bytes32' }] ; name
: "owner"
= 'owner'; outputs
: readonly [{ internalType
: "address"
= 'address'; name
: ""
= ''; type
: "address"
= 'address' }] ; stateMutability
: "view"
= 'view'; type
: "function"
= 'function' }, { inputs
: readonly [{ internalType
: "bytes32"
= 'bytes32'; name
: "node"
= 'node'; type
: "bytes32"
= 'bytes32' }] ; name
: "recordExists"
= 'recordExists'; outputs
: readonly [{ internalType
: "bool"
= 'bool'; name
: ""
= ''; type
: "bool"
= 'bool' }] ; stateMutability
: "view"
= 'view'; type
: "function"
= 'function' }, { inputs
: readonly [{ internalType
: "bytes32"
= 'bytes32'; name
: "node"
= 'node'; type
: "bytes32"
= 'bytes32' }] ; name
: "resolver"
= 'resolver'; outputs
: readonly [{ internalType
: "address"
= 'address'; name
: ""
= ''; type
: "address"
= 'address' }] ; stateMutability
: "view"
= 'view'; type
: "function"
= 'function' }, { inputs
: readonly [{ internalType
: "bytes32"
= 'bytes32'; name
: "node"
= 'node'; type
: "bytes32"
= 'bytes32' }] ; name
: "ttl"
= 'ttl'; outputs
: readonly [{ internalType
: "uint64"
= 'uint64'; name
: ""
= ''; type
: "uint64"
= 'uint64' }] ; stateMutability
: "view"
= 'view'; type
: "function"
= 'function' }], ContractEvents
<readonly [{ anonymous
: false
= false; inputs
: readonly [{ indexed
: true
= true; internalType
: "bytes32"
= 'bytes32'; name
: "node"
= 'node'; type
: "bytes32"
= 'bytes32' }, { indexed
: true
= true; internalType
: "bytes32"
= 'bytes32'; name
: "label"
= 'label'; type
: "bytes32"
= 'bytes32' }, { indexed
: false
= false; internalType
: "address"
= 'address'; name
: "owner"
= 'owner'; type
: "address"
= 'address' }] ; name
: "NewOwner"
= 'NewOwner'; type
: "event"
= 'event' }, { anonymous
: false
= false; inputs
: readonly [{ indexed
: true
= true; internalType
: "bytes32"
= 'bytes32'; name
: "node"
= 'node'; type
: "bytes32"
= 'bytes32' }, { indexed
: false
= false; internalType
: "address"
= 'address'; name
: "resolver"
= 'resolver'; type
: "address"
= 'address' }] ; name
: "NewResolver"
= 'NewResolver'; type
: "event"
= 'event' }, { anonymous
: false
= false; inputs
: readonly [{ indexed
: true
= true; internalType
: "bytes32"
= 'bytes32'; name
: "node"
= 'node'; type
: "bytes32"
= 'bytes32' }, { indexed
: false
= false; internalType
: "address"
= 'address'; name
: "owner"
= 'owner'; type
: "address"
= 'address' }] ; name
: "Transfer"
= 'Transfer'; type
: "event"
= 'event' }, { inputs
: readonly [{ internalType
: "address"
= 'address'; name
: "owner"
= 'owner'; type
: "address"
= 'address' }, { internalType
: "address"
= 'address'; name
: "operator"
= 'operator'; type
: "address"
= 'address' }] ; name
: "isApprovedForAll"
= 'isApprovedForAll'; outputs
: readonly [{ internalType
: "bool"
= 'bool'; name
: ""
= ''; type
: "bool"
= 'bool' }] ; stateMutability
: "view"
= 'view'; type
: "function"
= 'function' }, { inputs
: readonly [{ internalType
: "bytes32"
= 'bytes32'; name
: "node"
= 'node'; type
: "bytes32"
= 'bytes32' }] ; name
: "owner"
= 'owner'; outputs
: readonly [{ internalType
: "address"
= 'address'; name
: ""
= ''; type
: "address"
= 'address' }] ; stateMutability
: "view"
= 'view'; type
: "function"
= 'function' }, { inputs
: readonly [{ internalType
: "bytes32"
= 'bytes32'; name
: "node"
= 'node'; type
: "bytes32"
= 'bytes32' }] ; name
: "recordExists"
= 'recordExists'; outputs
: readonly [{ internalType
: "bool"
= 'bool'; name
: ""
= ''; type
: "bool"
= 'bool' }] ; stateMutability
: "view"
= 'view'; type
: "function"
= 'function' }, { inputs
: readonly [{ internalType
: "bytes32"
= 'bytes32'; name
: "node"
= 'node'; type
: "bytes32"
= 'bytes32' }] ; name
: "resolver"
= 'resolver'; outputs
: readonly [{ internalType
: "address"
= 'address'; name
: ""
= ''; type
: "address"
= 'address' }] ; stateMutability
: "view"
= 'view'; type
: "function"
= 'function' }, { inputs
: readonly [{ internalType
: "bytes32"
= 'bytes32'; name
: "node"
= 'node'; type
: "bytes32"
= 'bytes32' }] ; name
: "ttl"
= 'ttl'; outputs
: readonly [{ internalType
: "uint64"
= 'uint64'; name
: ""
= ''; type
: "uint64"
= 'uint64' }] ; stateMutability
: "view"
= 'view'; type
: "function"
= 'function' }]>>
Returns
ContractEventsInterface
<readonly [{ anonymous
: false
= false; inputs
: readonly [{ indexed
: true
= true; internalType
: "bytes32"
= 'bytes32'; name
: "node"
= 'node'; type
: "bytes32"
= 'bytes32' }, { indexed
: true
= true; internalType
: "bytes32"
= 'bytes32'; name
: "label"
= 'label'; type
: "bytes32"
= 'bytes32' }, { indexed
: false
= false; internalType
: "address"
= 'address'; name
: "owner"
= 'owner'; type
: "address"
= 'address' }] ; name
: "NewOwner"
= 'NewOwner'; type
: "event"
= 'event' }, { anonymous
: false
= false; inputs
: readonly [{ indexed
: true
= true; internalType
: "bytes32"
= 'bytes32'; name
: "node"
= 'node'; type
: "bytes32"
= 'bytes32' }, { indexed
: false
= false; internalType
: "address"
= 'address'; name
: "resolver"
= 'resolver'; type
: "address"
= 'address' }] ; name
: "NewResolver"
= 'NewResolver'; type
: "event"
= 'event' }, { anonymous
: false
= false; inputs
: readonly [{ indexed
: true
= true; internalType
: "bytes32"
= 'bytes32'; name
: "node"
= 'node'; type
: "bytes32"
= 'bytes32' }, { indexed
: false
= false; internalType
: "address"
= 'address'; name
: "owner"
= 'owner'; type
: "address"
= 'address' }] ; name
: "Transfer"
= 'Transfer'; type
: "event"
= 'event' }, { inputs
: readonly [{ internalType
: "address"
= 'address'; name
: "owner"
= 'owner'; type
: "address"
= 'address' }, { internalType
: "address"
= 'address'; name
: "operator"
= 'operator'; type
: "address"
= 'address' }] ; name
: "isApprovedForAll"
= 'isApprovedForAll'; outputs
: readonly [{ internalType
: "bool"
= 'bool'; name
: ""
= ''; type
: "bool"
= 'bool' }] ; stateMutability
: "view"
= 'view'; type
: "function"
= 'function' }, { inputs
: readonly [{ internalType
: "bytes32"
= 'bytes32'; name
: "node"
= 'node'; type
: "bytes32"
= 'bytes32' }] ; name
: "owner"
= 'owner'; outputs
: readonly [{ internalType
: "address"
= 'address'; name
: ""
= ''; type
: "address"
= 'address' }] ; stateMutability
: "view"
= 'view'; type
: "function"
= 'function' }, { inputs
: readonly [{ internalType
: "bytes32"
= 'bytes32'; name
: "node"
= 'node'; type
: "bytes32"
= 'bytes32' }] ; name
: "recordExists"
= 'recordExists'; outputs
: readonly [{ internalType
: "bool"
= 'bool'; name
: ""
= ''; type
: "bool"
= 'bool' }] ; stateMutability
: "view"
= 'view'; type
: "function"
= 'function' }, { inputs
: readonly [{ internalType
: "bytes32"
= 'bytes32'; name
: "node"
= 'node'; type
: "bytes32"
= 'bytes32' }] ; name
: "resolver"
= 'resolver'; outputs
: readonly [{ internalType
: "address"
= 'address'; name
: ""
= ''; type
: "address"
= 'address' }] ; stateMutability
: "view"
= 'view'; type
: "function"
= 'function' }, { inputs
: readonly [{ internalType
: "bytes32"
= 'bytes32'; name
: "node"
= 'node'; type
: "bytes32"
= 'bytes32' }] ; name
: "ttl"
= 'ttl'; outputs
: readonly [{ internalType
: "uint64"
= 'uint64'; name
: ""
= ''; type
: "uint64"
= 'uint64' }] ; stateMutability
: "view"
= 'view'; type
: "function"
= 'function' }], ContractEvents
<readonly [{ anonymous
: false
= false; inputs
: readonly [{ indexed
: true
= true; internalType
: "bytes32"
= 'bytes32'; name
: "node"
= 'node'; type
: "bytes32"
= 'bytes32' }, { indexed
: true
= true; internalType
: "bytes32"
= 'bytes32'; name
: "label"
= 'label'; type
: "bytes32"
= 'bytes32' }, { indexed
: false
= false; internalType
: "address"
= 'address'; name
: "owner"
= 'owner'; type
: "address"
= 'address' }] ; name
: "NewOwner"
= 'NewOwner'; type
: "event"
= 'event' }, { anonymous
: false
= false; inputs
: readonly [{ indexed
: true
= true; internalType
: "bytes32"
= 'bytes32'; name
: "node"
= 'node'; type
: "bytes32"
= 'bytes32' }, { indexed
: false
= false; internalType
: "address"
= 'address'; name
: "resolver"
= 'resolver'; type
: "address"
= 'address' }] ; name
: "NewResolver"
= 'NewResolver'; type
: "event"
= 'event' }, { anonymous
: false
= false; inputs
: readonly [{ indexed
: true
= true; internalType
: "bytes32"
= 'bytes32'; name
: "node"
= 'node'; type
: "bytes32"
= 'bytes32' }, { indexed
: false
= false; internalType
: "address"
= 'address'; name
: "owner"
= 'owner'; type
: "address"
= 'address' }] ; name
: "Transfer"
= 'Transfer'; type
: "event"
= 'event' }, { inputs
: readonly [{ internalType
: "address"
= 'address'; name
: "owner"
= 'owner'; type
: "address"
= 'address' }, { internalType
: "address"
= 'address'; name
: "operator"
= 'operator'; type
: "address"
= 'address' }] ; name
: "isApprovedForAll"
= 'isApprovedForAll'; outputs
: readonly [{ internalType
: "bool"
= 'bool'; name
: ""
= ''; type
: "bool"
= 'bool' }] ; stateMutability
: "view"
= 'view'; type
: "function"
= 'function' }, { inputs
: readonly [{ internalType
: "bytes32"
= 'bytes32'; name
: "node"
= 'node'; type
: "bytes32"
= 'bytes32' }] ; name
: "owner"
= 'owner'; outputs
: readonly [{ internalType
: "address"
= 'address'; name
: ""
= ''; type
: "address"
= 'address' }] ; stateMutability
: "view"
= 'view'; type
: "function"
= 'function' }, { inputs
: readonly [{ internalType
: "bytes32"
= 'bytes32'; name
: "node"
= 'node'; type
: "bytes32"
= 'bytes32' }] ; name
: "recordExists"
= 'recordExists'; outputs
: readonly [{ internalType
: "bool"
= 'bool'; name
: ""
= ''; type
: "bool"
= 'bool' }] ; stateMutability
: "view"
= 'view'; type
: "function"
= 'function' }, { inputs
: readonly [{ internalType
: "bytes32"
= 'bytes32'; name
: "node"
= 'node'; type
: "bytes32"
= 'bytes32' }] ; name
: "resolver"
= 'resolver'; outputs
: readonly [{ internalType
: "address"
= 'address'; name
: ""
= ''; type
: "address"
= 'address' }] ; stateMutability
: "view"
= 'view'; type
: "function"
= 'function' }, { inputs
: readonly [{ internalType
: "bytes32"
= 'bytes32'; name
: "node"
= 'node'; type
: "bytes32"
= 'bytes32' }] ; name
: "ttl"
= 'ttl'; outputs
: readonly [{ internalType
: "uint64"
= 'uint64'; name
: ""
= ''; type
: "uint64"
= 'uint64' }] ; stateMutability
: "view"
= 'view'; type
: "function"
= 'function' }]>>
- Returns all events that can be emitted by the ENS registry.
givenProvider
• get
givenProvider(): undefined
| LegacyRequestProvider
| LegacySendProvider
| LegacySendAsyncProvider
| EIP1193Provider
<never
> | Web3BaseProvider
<never
> | SimpleProvider
<never
> | MetaMaskProvider
<never
>
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
| LegacyRequestProvider
| LegacySendProvider
| LegacySendAsyncProvider
| EIP1193Provider
<never
> | Web3BaseProvider
<never
> | SimpleProvider
<never
> | MetaMaskProvider
<never
>
Inherited from
Web3Context.givenProvider
handleRevert
• get
handleRevert(): boolean
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
Inherited from
Web3Context.handleRevert
• set
handleRevert(val
): void
Will set the handleRevert
Parameters
Name | Type |
---|---|
val | boolean |
Returns
void
Inherited from
Web3Context.handleRevert
provider
• get
provider(): undefined
| Web3BaseProvider
<API
>
Will return the current provider.
Returns
undefined
| Web3BaseProvider
<API
>
Returns the current provider
Example
const web3 = new Web3Context("http://localhost:8545");
console.log(web3.provider);
> HttpProvider {
clientUrl: 'http://localhost:8545',
httpProviderOptions: undefined
}
Inherited from
Web3Context.provider
• set
provider(provider
): void
Will set the current provider.
Parameters
Name | Type | Description |
---|---|---|
provider | undefined | string | LegacyRequestProvider | LegacySendProvider | LegacySendAsyncProvider | EIP1193Provider <API > | Web3BaseProvider <API > | SimpleProvider <API > | MetaMaskProvider <API > | The provider to set Accepted providers are of type SupportedProviders |
Returns
void
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,
...
}
Inherited from
Web3Context.provider
subscriptionManager
• get
subscriptionManager(): Web3SubscriptionManager
<API
, RegisteredSubs
>
Will return the current subscriptionManager (Web3SubscriptionManager)
Returns
Web3SubscriptionManager
<API
, RegisteredSubs
>
Inherited from
Web3Context.subscriptionManager
transactionBlockTimeout
• get
transactionBlockTimeout(): number
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
Inherited from
Web3Context.transactionBlockTimeout
• set
transactionBlockTimeout(val
): void
Will set the transactionBlockTimeout.
Parameters
Name | Type |
---|---|
val | number |
Returns
void
Inherited from
Web3Context.transactionBlockTimeout
transactionConfirmationBlocks
• get
transactionConfirmationBlocks(): number
This defines the number of blocks it requires until a transaction is considered confirmed.
Default is 24
.
Returns
number
Inherited from
Web3Context.transactionConfirmationBlocks
• set
transactionConfirmationBlocks(val
): void
Will set the transactionConfirmationBlocks.
Parameters
Name | Type |
---|---|
val | number |
Returns
void
Inherited from
Web3Context.transactionConfirmationBlocks
transactionPollingInterval
• get
transactionPollingInterval(): number
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
Inherited from
Web3Context.transactionPollingInterval
• set
transactionPollingInterval(val
): void
Will set the transactionPollingInterval.
Parameters
Name | Type |
---|---|
val | number |