Will return the Web3BatchRequest constructor.
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.
Will set the blockHeaderTimeout
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
.
Will set the contractDataInputFill
Will return the current provider. (The same as provider
)
Returns the current provider
const web3Context = new Web3Context("http://localhost:8545");
console.log(web3Context.provider);
> HttpProvider {
clientUrl: 'http://localhost:8545',
httpProviderOptions: undefined
}
Will set the current provider. (The same as provider
)
SupportedProviders The provider to set
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,
...
}
This default address is used as the default from
property, if no from
property is specified in for the following methods:
Will set the default account.
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"
.
Will set the default block.
"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.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 chainbaseChain
- string
: (optional) mainnet, goerli, kovan, rinkeby, or ropstenhardfork
- string
: (optional) chainstart, homestead, dao, tangerineWhistle, spuriousDragon, byzantium, constantinople, petersburg, istanbul, berlin, or london
Default is undefined
.Will set the default common property
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
Will set the default hardfork.
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.
Will set the enableExperimentalFeatures
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
.
The handleRevert
options property returns the revert reason string if enabled for the following methods:
false
.Note
: At the moment handleRevert
is only supported for sendTransaction
and not for sendSignedTransaction
Will set the handleRevert
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.
Will return the current provider.
Returns the current provider
const web3 = new Web3Context("http://localhost:8545");
console.log(web3.provider);
> HttpProvider {
clientUrl: 'http://localhost:8545',
httpProviderOptions: undefined
}
Will set the current provider.
The provider to set
Accepted providers are of type SupportedProviders
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,
...
}
Will return the current subscriptionManager (Web3SubscriptionManager)
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
.
Will set the transactionBlockTimeout.
This defines the number of blocks it requires until a transaction is considered confirmed.
Default is 24
.
Will set the transactionConfirmationBlocks.
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.
Will set the transactionPollingInterval.
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).
Will set the transactionPollingTimeout.
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
Will set the transactionReceiptPollingInterval
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).
Will set the transactionSendTimeout.
Optional
providerOrContext: string | SupportedProviders<unknown> | Web3ContextInitOptions<unknown, any>This method creates Superfluid's CFAV1 Contract instance of connected chain
CFAV1 Contract Address of connected chain
CFAV1 Contract instance
Error if address is not a valid address
const web3 = new Web3("http://127.0.0.1:8545");
web3.registerPlugin(new SuperfluidPlugin());
const cfav1 = web3.superfluid.cfav1(cfav1Address);
This method creates Superfluid's CFAV1Forwarder Contract instance of connected chain
CFAV1Forwarder Contract Address of connected chain
CFAV1Forwarder Contract instance
Error if address is not a valid address
const web3 = new Web3("http://127.0.0.1:8545");
web3.registerPlugin(new SuperfluidPlugin());
const cfav1Forwarder = web3.superfluid.cfav1Forwarder(cfav1ForwarderAddress);
This method returns Superfluid protocol contract addresses of given chainId
ChainId of the network to get contract addresses of
Protocol contract addresses object
Error if chainId is not supported
const web3 = new Web3("https://rpc-mumbai.maticvigil.com");
web3.registerPlugin(new SuperfluidPlugin());
const addresses = web3.superfluid.contractAddresses(80001);
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.
This method creates Superfluid's Host Contract instance of connected chain
Host Contract Address of connected chain
Host Contract instance
Error if address is not a valid address
const web3 = new Web3("http://127.0.0.1:8545");
web3.registerPlugin(new SuperfluidPlugin());
const host = web3.superfluid.host(hostAddress);
This method creates Superfluid's IDAV1 Contract instance of connected chain
IDAV1 Contract Address of connected chain
IDAV1 Contract instance
Error if address is not a valid address
const web3 = new Web3("http://127.0.0.1:8545");
web3.registerPlugin(new SuperfluidPlugin());
const idav1 = web3.superfluid.idav1(idav1Address);
Protected
registerWill set the provider.
Optional
provider: string | SupportedProviders<unknown>SupportedProviders The provider to set
Returns true if the provider was set
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
.
Rest
...args: [...T2[]]Static
fromRest
...args: [Web3ContextObject<unknown, any>, ...T3[]]Protected
Optional
_accountProtected
_requestProtected
_subscriptionProtected
Optional
_walletReadonly
providersStatic
Optional
givenStatic
Readonly
providers
Extend this class when creating a plugin that either doesn't require EthExecutionAPI, or interacts with a RPC node that doesn't fully implement EthExecutionAPI.
To add type support for RPC methods to the Web3RequestManager, define a Web3APISpec and pass it as a generic to Web3PluginBase like so:
Example