This Web3.js plugin adds support for various wallet-related RPC methods.

Initialize the plugin

import { Web3 } from "web3";
import { WalletRpcPlugin } from "web3-plugin-wallet-rpc";

const web3 = new Web3("https://eth.llamarpc.com");
web3.registerPlugin(new WalletRpcPlugin());

Hierarchy

  • Web3PluginBase<WalletRpcApi>
    • WalletRpcPlugin

Constructors

Properties

_accountProvider?: Web3AccountProvider<Web3BaseWalletAccount>
_requestManager: Web3RequestManager<WalletRpcApi>
_subscriptionManager: Web3SubscriptionManager<WalletRpcApi, any>
_wallet?: Web3BaseWallet<Web3BaseWalletAccount>
config: Web3ConfigOptions
pluginNamespace: string = 'walletRpc'
providers: {
    HttpProvider: Web3BaseProviderConstructor;
    WebsocketProvider: Web3BaseProviderConstructor;
}
walletRpc: WalletRpcPlugin
givenProvider?: SupportedProviders<never>
providers: {
    HttpProvider: Web3BaseProviderConstructor;
    WebsocketProvider: Web3BaseProviderConstructor;
}

Accessors

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

  • get BatchRequest(): (new () => Web3BatchRequest)
  • Will return the Web3BatchRequest constructor.

    Returns (new () => Web3BatchRequest)

      • new (): Web3BatchRequest
      • Returns Web3BatchRequest

  • 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

  • set blockHeaderTimeout(val): void
  • Will set the blockHeaderTimeout

    Parameters

    • val: number

    Returns void

  • get contractDataInputFill(): "input" | "data" | "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 data.

    Returns "input" | "data" | "both"

  • set contractDataInputFill(val): void
  • Will set the contractDataInputFill

    Parameters

    • val: "input" | "data" | "both"

    Returns void

  • get currentProvider(): undefined | Web3BaseProvider<API>
  • Will return the current provider. (The same as provider)

    Returns undefined | Web3BaseProvider<API>

    Returns the current provider

    const web3Context = new Web3Context("http://localhost:8545");
    console.log(web3Context.provider);
    > HttpProvider {
    clientUrl: 'http://localhost:8545',
    httpProviderOptions: undefined
    }
  • set currentProvider(provider): void
  • Will set the current provider. (The same as provider)

    Parameters

    • provider: undefined | string | SupportedProviders<API>

      SupportedProviders The provider to set

    Returns void

     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,
    ...
    }
  • get customTransactionSchema(): undefined | CustomTransactionSchema
  • Returns undefined | CustomTransactionSchema

  • set customTransactionSchema(schema): void
  • Parameters

    • schema: undefined | CustomTransactionSchema

    Returns void

  • 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

  • set defaultAccount(val): void
  • Will set the default account.

    Parameters

    • val: undefined | string

    Returns void

  • 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

  • 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

    • val: BlockNumberOrTag

    Returns void

  • get defaultChain(): string
  • Returns string

  • set defaultChain(val): void
  • Parameters

    • val: string

    Returns void

  • 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 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

  • set defaultCommon(val): void
  • Will set the default common property

    Parameters

    • val: undefined | Common

    Returns void

  • 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

  • set defaultHardfork(val): void
  • Will set the default hardfork.

    Parameters

    • val: string

    Returns void

  • get defaultMaxPriorityFeePerGas(): Numbers
  • Returns Numbers

  • set defaultMaxPriorityFeePerGas(val): void
  • Parameters

    • val: Numbers

    Returns void

  • get defaultNetworkId(): undefined | Numbers
  • Returns undefined | Numbers

  • set defaultNetworkId(val): void
  • Parameters

    • val: undefined | Numbers

    Returns void

  • get defaultReturnFormat(): DataFormat
  • Returns DataFormat

  • set defaultReturnFormat(val): void
  • Parameters

    • val: DataFormat

    Returns void

  • get defaultTransactionType(): Numbers
  • Returns Numbers

  • set defaultTransactionType(val): void
  • Parameters

    • val: Numbers

    Returns void

  • get enableExperimentalFeatures(): {
        useRpcCallSpecification: boolean;
        useSubscriptionWhenCheckingBlockTimeout: boolean;
    }
  • 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
  • set enableExperimentalFeatures(val): void
  • Will set the enableExperimentalFeatures

    Parameters

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

    Returns void

  • get givenProvider(): undefined | SupportedProviders<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 | SupportedProviders<never>

  • 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

  • set handleRevert(val): void
  • Will set the handleRevert

    Parameters

    • val: boolean

    Returns void

  • get ignoreGasPricing(): boolean
  • 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

  • set ignoreGasPricing(val): void
  • Parameters

    • val: boolean

    Returns void

  • get maxListenersWarningThreshold(): number
  • Returns number

  • set maxListenersWarningThreshold(val): void
  • Parameters

    • val: number

    Returns void

  • get provider(): undefined | Web3BaseProvider<API>
  • Will return the current provider.

    Returns undefined | Web3BaseProvider<API>

    Returns the current provider

    const web3 = new Web3Context("http://localhost:8545");
    console.log(web3.provider);
    > HttpProvider {
    clientUrl: 'http://localhost:8545',
    httpProviderOptions: undefined
    }
  • set provider(provider): void
  • Will set the current provider.

    Parameters

    • provider: undefined | string | SupportedProviders<API>

      The provider to set

      Accepted providers are of type SupportedProviders

    Returns void

     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,
    ...
    }
  • get requestManager(): Web3RequestManager<API>
  • Returns Web3RequestManager<API>

  • get subscriptionManager(): Web3SubscriptionManager<API, RegisteredSubs>
  • Will return the current subscriptionManager (Web3SubscriptionManager)

    Returns Web3SubscriptionManager<API, RegisteredSubs>

  • 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

  • set transactionBlockTimeout(val): void
  • Will set the transactionBlockTimeout.

    Parameters

    • val: number

    Returns void

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

  • set transactionBuilder(val): void
  • Parameters

    • val: undefined | TransactionBuilder<unknown>

    Returns void

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

    Returns number

  • set transactionConfirmationBlocks(val): void
  • Will set the transactionConfirmationBlocks.

    Parameters

    • val: number

    Returns void

  • get transactionConfirmationPollingInterval(): undefined | number
  • Returns undefined | number

  • set transactionConfirmationPollingInterval(val): void
  • Parameters

    • val: undefined | number

    Returns void

  • 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

  • set transactionPollingInterval(val): void
  • Will set the transactionPollingInterval.

    Parameters

    • val: number

    Returns void

  • get transactionPollingTimeout(): number
  • 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

  • set transactionPollingTimeout(val): void
  • Will set the transactionPollingTimeout.

    Parameters

    • val: number

    Returns void

  • get transactionReceiptPollingInterval(): undefined | number
  • 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

  • set transactionReceiptPollingInterval(val): void
  • Will set the transactionReceiptPollingInterval

    Parameters

    • val: undefined | number

    Returns void

  • get transactionSendTimeout(): number
  • 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

  • set transactionSendTimeout(val): void
  • Will set the transactionSendTimeout.

    Parameters

    • val: number

    Returns void

  • get transactionTypeParser(): undefined | TransactionTypeParser
  • Returns undefined | TransactionTypeParser

  • set transactionTypeParser(val): void
  • Parameters

    • val: undefined | TransactionTypeParser

    Returns void

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

Methods

  • Request to add a new chain to the user's wallet.

    See EIP-3085 for more details.

    Parameters

    Returns Promise<null>

    A Promise that resolves if the request is successful.

    await web3.walletRpc.addEthereumChain({
    chainId: 5000,
    blockExplorerUrls: ["https://mantlescan.xyz"],
    chainName: "Mantle",
    iconUrls: ["https://icons.llamao.fi/icons/chains/rsz_mantle.jpg"],
    nativeCurrency: {
    name: "Mantle",
    symbol: "MNT",
    decimals: 18,
    },
    rpcUrls: ["https://rpc.mantle.xyz"],
    });
  • Type Parameters

    • K extends Web3ConfigEvent

    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;
                  oldValue: undefined | TransactionBuilder;
              }
              | {
                  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

  • Returns (string | symbol)[]

  • 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

    • extendObj: ExtensionObject

    Returns this

  • Returns Web3ContextObject<WalletRpcApi, any>

  • Returns number

  • Link current context to another context.

    Type Parameters

    • T extends Web3Context<unknown, any>

    Parameters

    • parentContext: T

    Returns void

  • Type Parameters

    • K extends Web3ConfigEvent

    Parameters

    • eventName: K

    Returns number

  • Type Parameters

    • K extends Web3ConfigEvent

    Parameters

    • eventName: K

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

  • Type Parameters

    • K extends Web3ConfigEvent

    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;
                  oldValue: undefined | TransactionBuilder;
              }
              | {
                  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

  • Type Parameters

    • K extends Web3ConfigEvent

    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;
                  oldValue: undefined | TransactionBuilder;
              }
              | {
                  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

  • Type Parameters

    • K extends Web3ConfigEvent

    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;
                  oldValue: undefined | TransactionBuilder;
              }
              | {
                  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

  • Type Parameters

    • NewTxTypeClass extends typeof BaseTransaction

    Parameters

    Returns void

  • Parameters

    • plugin: Web3PluginBase<unknown>

    Returns void

  • Returns EventEmitter

  • Parameters

    • options: Partial<Web3ConfigOptions>

    Returns void

  • Parameters

    • maxListenersWarningThreshold: number

    Returns void

  • Will set the provider.

    Parameters

    • Optionalprovider: string | SupportedProviders<WalletRpcApi>

      SupportedProviders The provider to set

    Returns boolean

    Returns true if the provider was set

  • Parameters

    • requestManagerMiddleware: RequestManagerMiddleware<WalletRpcApi>

    Returns void

  • Switch the wallet's currently active chain.

    If the specified chain does not exist in the wallet, an error will be thrown. To prevent errors, ensure the chain has been added first or handle the call within a try/catch block.

    See EIP-3326 for more details.

    Parameters

    • chainId: Numbers

      The ID of the chain to switch to.

    Returns Promise<null>

    A Promise that resolves if the chain switch is successful.

    await web3.walletRpc.switchEthereumChain(5000);
    
  • 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

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

    Parameters

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

    Returns T

  • Add an asset to the user's wallet.

    See EIP-747 for more details.

    Parameters

    Returns Promise<boolean>

    A Promise that resolves to true if the request is successful.

    await web3.walletRpc.watchAsset({
    type: "ERC20",
    options: {
    address: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
    symbol: "USDC",
    },
    });
  • Type Parameters

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

    Parameters

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

    Returns T