Skip to main content

web3

This is the main (or ‘umbrella’) class of the web3.js library.

import Web3 from 'web3';

> Web3.utils
> Web3.version
> Web3.givenProvider
> Web3.providers
> Web3.modules

Web3.modules

Web3.modules

Will return an object with the classes of all major sub modules, to be able to instantiate them manually.

Returns

Object A list of module constructors:

  • Eth - Constructor: The Eth module for interacting with the Ethereum network
  • Net - Constructor: The Net module for interacting with network properties.
  • Personal - constructor: The Personal module for interacting with the Ethereum accounts (web3.eth.personal).

Example

Web3.modules
> {
Eth: Eth(provider),
Net: Net(provider),
Personal: Personal(provider),
}

See details: Web3.modules

Web3 Instance

The Web3 class is an umbrella package to house all Ethereum related modules.

import Web3 from 'web3';

// "Web3.givenProvider" will be set if in an Ethereum supported browser.
const web3 = new Web3(Web3.givenProvider || 'ws://some.local-or-remote.node:8546');

> web3.eth
> web3.utils
> web3.version

version

Contains the current package version of the web3.js library.

Returns

//todo enable when functionality added // @see Web3.version

utils

Static accessible property of the Web3 class and property of the instance as well.

Web3.utils
web3.utils

Utility functions are also exposed on the Web3 class object diretly.

//todo enable when implemented //See details: Web3.utils

setProvider

web3.setProvider(myProvider)
web3.eth.setProvider(myProvider)
...

Will change the provider for its module.

NOTE: When called on the umbrella package web3 it will also set the provider for all sub modules web3.eth etc.

Parameters

Object - myProvider: a valid provider.

Returns

Boolean

See details: Web3.setProvider

Example: Local Geth Node

import Web3 from "web3";
let web3: Web3 = new Web3('http://localhost:8545');
// or
let web3: Web3 = new Web3(new Web3.providers.HttpProvider('http://localhost:8545'));

// change provider
web3.setProvider('ws://localhost:8546');
// or
web3.setProvider(new Web3.providers.WebsocketProvider('ws://localhost:8546'));

//todo add IPC provider

Example: Remote Geth Node

// Using a remote node provider, like Alchemy (https://www.alchemyapi.io/supernode), is simple.
import Web3 from "web3";
let web3: Web3 = new Web3("https://eth-mainnet.alchemyapi.io/v2/your-api-key");

providers

web3.providers
web3.eth.providers

Contains the current available providers.

Returns

Object with the following providers:

  • Object - HttpProvider: HTTP provider, does not support subscriptions.
  • Object - WebSocketProvider: The WebSocket provider is the standard for usage in legacy browsers.
  • Object - IpcProvider: The IPC provider is used in node.js dapps when running a local node. Gives the most secure connection.

Example

import Web3 from 'web3';
// use the given Provider or instantiate a new websocket provider
let web3 = new Web3(Web3.givenProvider || 'ws://remotenode.com:8546');
// or
let web3 = new Web3(Web3.givenProvider || new Web3.providers.WebsocketProvider('ws://remotenode.com:8546'));

// Using the IPC provider in node.js
var web3 = new Web3(new Web3.providers.IpcProvider('/Users/myuser/Library/Ethereum/geth.ipc')); // mac os path
// on windows the path is: "\\\\.\\pipe\\geth.ipc"
// on linux the path is: "/users/myuser/.ethereum/geth.ipc"

Configuration


//===
//Http
//===

import Web3HttpProvider, { HttpProviderOptions } from "web3-providers-http";

let options: HttpProviderOptions = {
providerOptions: {
keepalive: true,
credentials: "omit",
headers: {
"Access-Control-Allow-Origin": "*",
},
},
};


var provider = new Web3HttpProvider("http://localhost:8545", options);
web3.setProvider(provider);

//===
//WebSockets
//===
import Web3WsProvider, {
ClientOptions,
ClientRequestArgs,
ReconnectOptions,
} from "web3-providers-ws";


let clientOptions: ClientOptions = {
// Useful for credentialed urls, e.g: ws://username:password@localhost:8546
headers: {
authorization: "Basic username:password",
},
maxPayload: 100000000,
};

// Enable auto reconnection
let reconnectOptions: ReconnectOptions = {
autoReconnect: true,
delay: 5000, // ms
maxAttempts: 5,
};

//clientOptions and reconnectOptions are optional
//clientOptions: ClientOptions | ClientRequestArgs
let ws = new Web3WsProvider(
"ws://localhost:8546",
clientOptions,
reconnectOptions
);
web3.setProvider(ws);

More information for the Http and Websocket provider modules can be found here:

See details: Web3.providers

givenProvider

web3.givenProvider
web3.eth.givenProvider
...

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

Object - The given provider set or undefined.

See details: Web3.givenProvider

currentProvider

web3.currentProvider
web3.eth.currentProvider
...

Will return the current provider, otherwise undefined.

Returns

Object: The current provider, otherwise undefined.

See details: Web3.currentProvider

BatchRequest

new web3.BatchRequest()
new web3.BatchRequest()
...

Class to create and execute batch requests.

Parameters

none

Returns

Object: With the following methods:

  • add(request): To add a request object to the batch call.
  • execute() : To execute the batch request.

Example

let request1: JsonRpcOptionalRequest = {
id: 10,
method: 'eth_getBalance',
params: ["0xdc6bad79dab7ea733098f66f6c6f9dd008da3258", 'latest'],
};
let request2: JsonRpcOptionalRequest = {
id: 11,
method: 'eth_getBalance',
params: ["0x962f9a9c2a6c092474d24def35eccb3d9363265e", 'latest'],
};

const batch = new web3.BatchRequest();

batch.add(request1);
batch.add(request2);
// add returns a deferred promise which can be used to run specific code after completion of each respective request.
//const request2Promise = batch.add(request2);

const response = await batch.execute();

See details: Web3.BatchRequest

Index

Classes

Enumerations

Interfaces

Namespaces

References

Type Aliases

Variables

References

default

Renames and re-exports Web3

Type Aliases

AbiBaseFragment

AbiBaseFragment: { type: string | FragmentTypes }

Type declaration

  • readonlytype: string | FragmentTypes

AbiConstructorFragment

AbiConstructorFragment: AbiBaseFragment & { inputs?: ReadonlyArray<AbiParameter>; stateMutability: string | nonpayable | payable; type: string | constructor }

AbiErrorFragment

AbiErrorFragment: AbiBaseFragment & { inputs?: ReadonlyArray<AbiParameter>; name: string; type: string | error }

AbiEventFragment

AbiEventFragment: AbiBaseFragment & { anonymous?: boolean; inputs?: ReadonlyArray<AbiParameter>; name: string; type: string | event }

AbiFallbackFragment

AbiFallbackFragment: AbiBaseFragment & { constant?: boolean; inputs: never; name: never; outputs: never; payable?: boolean; stateMutability: string | nonpayable | payable | pure | view; type: string | fallback }

AbiFragment

AbiFunctionFragment

AbiFunctionFragment: AbiBaseFragment & { constant?: boolean; inputs?: ReadonlyArray<AbiParameter>; name: string; outputs?: ReadonlyArray<AbiParameter>; payable?: boolean; stateMutability?: string | nonpayable | payable | pure | view; type: string | function }

AbiInput

AbiInput: string | AbiParameter | { components?: Components; index?: boolean; internalType?: string; name: string; type: string } | {}

AbiParameter

AbiParameter: { arrayChildren?: ReadonlyArray<AbiParameter>; arrayLength?: number; baseType?: string; components?: ReadonlyArray<AbiParameter>; indexed?: boolean; name: string; type: string }

Type declaration

  • optionalreadonlyarrayChildren?: ReadonlyArray<AbiParameter>
  • optionalreadonlyarrayLength?: number
  • optionalreadonlybaseType?: string
  • optionalreadonlycomponents?: ReadonlyArray<AbiParameter>
  • optionalreadonlyindexed?: boolean
  • readonlyname: string
  • readonlytype: string

AccessList

AccessList: AccessListEntry[]

AccessListResult

AccessListResult: { accessList?: AccessList; gasUsed?: Numbers }

Type declaration

Address

Address: HexString

ArrayToIndexObject

ArrayToIndexObject<T>: { [ K in IndexKeysForArray<T> ]: T[K] }

Type parameters

  • T: ReadonlyArray<unknown>

Block

BlockAPI

BlockNumberOrTag

BlockNumberOrTag: Numbers | BlockTag

BlockTag

BlockTag: `${BlockTags}`

Bytes

Bytes: Buffer | Uint8Array | ArrayBuffer | HexString

Cipher

Cipher: aes-128-ctr | aes-128-cbc | aes-256-cbc

CipherOptions

CipherOptions: { c?: number; dklen?: number; iv?: Buffer | string; kdf?: scrypt | pbkdf2; n?: number; p?: number; r?: number; salt?: Buffer | string }

Type declaration

  • optionalc?: number
  • optionaldklen?: number
  • optionaliv?: Buffer | string
  • optionalkdf?: scrypt | pbkdf2
  • optionaln?: number
  • optionalp?: number
  • optionalr?: number
  • optionalsalt?: Buffer | string

Components

Components: { components?: Components[]; indexed?: boolean; name: string; type: string }

Type declaration

  • optionalcomponents?: Components[]
  • optionalindexed?: boolean
  • name: string
  • type: string

ConnectionEvent

ConnectionEvent: { code: number; reason: string; wasClean?: boolean }

Type declaration

  • code: number
  • reason: string
  • optionalwasClean?: boolean

ContractAbi

ContractAbi: ReadonlyArray<AbiFragment>

ContractConstructor

ContractConstructor<Abis>: { [ Abi in FilterAbis<Abis, AbiConstructorFragment & { type: constructor }> as constructor ]: { Abi: Abi; Inputs: ContractMethodInputParameters<Abi[inputs]> } }[constructor]

Type parameters

ContractConstructorArgs

ContractConstructorArgs<Abis>: { [ Abi in FilterAbis<Abis, AbiConstructorFragment & { type: constructor }> as constructor ]: ContractMethodInputParameters<Abi[inputs]> }[constructor]

Type parameters

ContractEvent

ContractEvent<Abi>: { Abi: Abi; Inputs: ContractMethodInputParameters<Abi[inputs]> }

Type parameters

Type declaration

ContractEvents

ContractEvents<Abis>: { [ Abi in FilterAbis<Abis, AbiEventFragment & { type: event }> as Abi[name] ]: ContractEvent<Abi> }

Type parameters

ContractMethod

ContractMethod<Abi>: { Abi: Abi; Inputs: ContractMethodInputParameters<Abi[inputs]>; Outputs: ContractMethodOutputParameters<Abi[outputs]> }

Type parameters

Type declaration

ContractMethodInputParameters

ContractMethodInputParameters<Params>: Params extends readonly [] ? [] : Params extends readonly [infer H, ...infer R] ? H extends AbiParameter ? [MatchPrimitiveType<H[type], H[components]>, ...ContractMethodInputParameters<R>] : ContractMethodInputParameters<R> : Params extends undefined | unknown ? [] : Params

Type parameters

  • Params: ReadonlyArray<unknown> | undefined

ContractMethodOutputParameters

ContractMethodOutputParameters<Params>: Params extends readonly [] ? void : Params extends readonly [infer H, ...infer R] ? R extends readonly [] ? H extends AbiParameter ? MatchPrimitiveType<H[type], H[components]> : [] : ArrToObjectWithFunctions<[...ContractMethodOutputParametersRecursiveArray<Params>]> & ContractMethodOutputParametersRecursiveRecord<Params> : []

Type parameters

  • Params: ReadonlyArray<unknown> | undefined

ContractMethods

ContractMethods<Abis>: { [ Abi in FilterAbis<Abis, AbiFunctionFragment & { type: function }> as Abi[name] ]: ContractMethod<Abi> }

Type parameters

ConvertToNumber

ConvertToNumber<T, Range>: Range extends unknown ? `${Range}` extends T ? Range : never : never

Type parameters

  • T: string
  • Range: number = _SolidityIndexRange

EncodingTypes

EncodingTypes: Numbers | boolean | Numbers[] | boolean[]

EthExecutionAPI

EthExecutionAPI: { eth_accounts: any; eth_blockNumber: any; eth_call: any; eth_clearSubscriptions: any; eth_coinbase: any; eth_compileLLL: any; eth_compileSerpent: any; eth_compileSolidity: any; eth_estimateGas: any; eth_feeHistory: any; eth_gasPrice: any; eth_getBalance: any; eth_getBlockByHash: any; eth_getBlockByNumber: any; eth_getBlockTransactionCountByHash: any; eth_getBlockTransactionCountByNumber: any; eth_getCode: any; eth_getCompilers: any; eth_getFilterChanges: any; eth_getFilterLogs: any; eth_getLogs: any; eth_getStorageAt: any; eth_getTransactionByBlockHashAndIndex: any; eth_getTransactionByBlockNumberAndIndex: any; eth_getTransactionByHash: any; eth_getTransactionCount: any; eth_getTransactionReceipt: any; eth_getUncleByBlockHashAndIndex: any; eth_getUncleByBlockNumberAndIndex: any; eth_getUncleCountByBlockHash: any; eth_getUncleCountByBlockNumber: any; eth_getWork: any; eth_hashrate: any; eth_mining: any; eth_newBlockFilter: any; eth_newFilter: any; eth_newPendingTransactionFilter: any; eth_protocolVersion: any; eth_sendRawTransaction: any; eth_sendTransaction: any; eth_sign: any; eth_signTransaction: any; eth_submitHashrate: any; eth_submitWork: any; eth_subscribe: any; eth_syncing: any; eth_uninstallFilter: any; eth_unsubscribe: any }

Type declaration

  • eth_accounts: function
    • eth_accounts(): string[]

    • Returns string[]

  • eth_blockNumber: function
    • eth_blockNumber(): string

    • Returns string

  • eth_call: function

  • eth_clearSubscriptions: function
    • eth_clearSubscriptions(keepSyncing?: boolean): void

    • Parameters

      • optionalkeepSyncing: boolean

      Returns void

  • eth_coinbase: function
    • eth_coinbase(): string

    • Returns string

  • eth_compileLLL: function
    • eth_compileLLL(code: string): string

    • Parameters

      • code: string

      Returns string

  • eth_compileSerpent: function
    • eth_compileSerpent(code: string): string

    • Parameters

      • code: string

      Returns string

  • eth_compileSolidity: function

  • eth_estimateGas: function

  • eth_feeHistory: function

  • eth_gasPrice: function
    • eth_gasPrice(): string

    • Returns string

  • eth_getBalance: function

  • eth_getBlockByHash: function
    • eth_getBlockByHash(blockHash: string, hydrated: boolean): BlockAPI

    • Parameters

      • blockHash: string
      • hydrated: boolean

      Returns BlockAPI

  • eth_getBlockByNumber: function

  • eth_getBlockTransactionCountByHash: function
    • eth_getBlockTransactionCountByHash(blockHash: string): string

    • Parameters

      • blockHash: string

      Returns string

  • eth_getBlockTransactionCountByNumber: function

  • eth_getCode: function

  • eth_getCompilers: function
    • eth_getCompilers(): string[]

    • Returns string[]

  • eth_getFilterChanges: function

  • eth_getFilterLogs: function

  • eth_getLogs: function

  • eth_getStorageAt: function
    • eth_getStorageAt(address: string, storageSlot: string, blockNumber: BlockNumberOrTag): string

    • Parameters

      Returns string

  • eth_getTransactionByBlockHashAndIndex: function
    • eth_getTransactionByBlockHashAndIndex(blockHash: string, transactionIndex: string): undefined | TransactionInfoAPI

  • eth_getTransactionByBlockNumberAndIndex: function

  • eth_getTransactionByHash: function

  • eth_getTransactionCount: function

  • eth_getTransactionReceipt: function

  • eth_getUncleByBlockHashAndIndex: function
    • eth_getUncleByBlockHashAndIndex(blockHash: string, uncleIndex: string): BlockAPI

    • Parameters

      • blockHash: string
      • uncleIndex: string

      Returns BlockAPI

  • eth_getUncleByBlockNumberAndIndex: function

  • eth_getUncleCountByBlockHash: function
    • eth_getUncleCountByBlockHash(blockHash: string): string

    • Parameters

      • blockHash: string

      Returns string

  • eth_getUncleCountByBlockNumber: function

  • eth_getWork: function
    • eth_getWork(): [string, string, string]

    • Returns [string, string, string]

  • eth_hashrate: function
    • eth_hashrate(): string

    • Returns string

  • eth_mining: function
    • eth_mining(): boolean

    • Returns boolean

  • eth_newBlockFilter: function
    • eth_newBlockFilter(): string

    • Returns string

  • eth_newFilter: function
    • eth_newFilter(filter: Filter): string

    • Parameters

      Returns string

  • eth_newPendingTransactionFilter: function
    • eth_newPendingTransactionFilter(): string

    • Returns string

  • eth_protocolVersion: function
    • eth_protocolVersion(): string

    • Returns string

  • eth_sendRawTransaction: function
    • eth_sendRawTransaction(transaction: string): string

    • Parameters

      • transaction: string

      Returns string

  • eth_sendTransaction: function

  • eth_sign: function
    • eth_sign(address: string, message: string): string

    • Parameters

      • address: string
      • message: string

      Returns string

  • eth_signTransaction: function

  • eth_submitHashrate: function
    • eth_submitHashrate(hashRate: string, id: string): boolean

    • Parameters

      • hashRate: string
      • id: string

      Returns boolean

  • eth_submitWork: function
    • eth_submitWork(nonce: string, hash: string, digest: string): boolean

    • Parameters

      • nonce: string
      • hash: string
      • digest: string

      Returns boolean

  • eth_subscribe: function
    • eth_subscribe(...params: [newPendingTransactions] | [newHeads] | [syncing] | [logs, { address?: HexString; topics?: HexString[] }]): string

    • Parameters

      • rest...params: [newPendingTransactions] | [newHeads] | [syncing] | [logs, { address?: HexString; topics?: HexString[] }]

      Returns string

  • eth_syncing: function

  • eth_uninstallFilter: function
    • eth_uninstallFilter(filterIdentifier: string): boolean

    • Parameters

      • filterIdentifier: string

      Returns boolean

  • eth_unsubscribe: function
    • eth_unsubscribe(subscriptionId: string): string

    • Parameters

      • subscriptionId: string

      Returns string

EthPersonalAPI

EthPersonalAPI: { personal_ecRecover: any; personal_importRawKey: any; personal_listAccounts: any; personal_lockAccount: any; personal_newAccount: any; personal_sendTransaction: any; personal_sign: any; personal_signTransaction: any; personal_unlockAccount: any }

Type declaration

  • personal_ecRecover: function
    • personal_ecRecover(signedData: string, signature: string): string

    • Parameters

      • signedData: string
      • signature: string

      Returns string

  • personal_importRawKey: function
    • personal_importRawKey(keyData: string, passphrase: string): string

    • Parameters

      • keyData: string
      • passphrase: string

      Returns string

  • personal_listAccounts: function
    • personal_listAccounts(): string[]

    • Returns string[]

  • personal_lockAccount: function
    • personal_lockAccount(address: string): boolean

    • Parameters

      • address: string

      Returns boolean

  • personal_newAccount: function
    • personal_newAccount(password: string): string

    • Parameters

      • password: string

      Returns string

  • personal_sendTransaction: function
    • personal_sendTransaction(tx: Transaction, passphrase: string): string

    • Parameters

      Returns string

  • personal_sign: function
    • personal_sign(data: string, address: string, passphrase: string): string

    • Parameters

      • data: string
      • address: string
      • passphrase: string

      Returns string

  • personal_signTransaction: function
    • personal_signTransaction(tx: Transaction, passphrase: string): string

    • Parameters

      Returns string

  • personal_unlockAccount: function
    • personal_unlockAccount(address: string, password: string, unlockDuration: number): boolean

    • Parameters

      • address: string
      • password: string
      • unlockDuration: number

      Returns boolean

FeeHistory

FeeHistory: FeeHistoryBase<Numbers>

FeeHistoryResultAPI

FeeHistoryResultAPI: FeeHistoryBase<Uint>

FilterAbis

FilterAbis<Abis, Filter, Abi>: Abi extends Filter ? Abi : never

Type parameters

FilterResultsAPI

FilterResultsAPI: HexString32Bytes[] | LogAPI[]

FixedSizeArray

FixedSizeArray<T, N>: GrowToSize<T, [], N>

Type parameters

  • T
  • N: number

GrowToSize

GrowToSize<T, A, N>: { 0: A; 1: GrowToSize<T, _Grow<T, A>, N> }[A[length] extends N ? 0 : 1]

Type parameters

  • T
  • A: T[]
  • N: number

Hardfork

Hardfork: arrowGlacier | berlin | byzantium | chainstart | constantinople | dao | homestead | istanbul | london | merge | muirGlacier | petersburg | shanghai | spuriousDragon | tangerineWhistle

HexString

HexString: string

HexString16Bytes

HexString16Bytes: HexString

HexString256Bytes

HexString256Bytes: HexString

HexString32Bytes

HexString32Bytes: HexString

HexString8Bytes

HexString8Bytes: HexString

HexStringBytes

HexStringBytes: HexString

HexStringSingleByte

HexStringSingleByte: HexString

IndexKeysForArray

IndexKeysForArray<A>: Exclude<keyof A, keyof []>

Type parameters

  • A: readonly unknown[]

JsonEventInterface

JsonEventInterface: { anonymous: boolean; indexed: boolean; inputs: Components[]; name: string; type: event }

Type declaration

  • anonymous: boolean
  • indexed: boolean
  • inputs: Components[]
  • name: string
  • type: event

JsonFunctionInterface

JsonFunctionInterface: { inputs: Components[]; name: string; outputs?: AbiInput[]; stateMutability?: string; type: function }

Type declaration

  • inputs: Components[]
  • name: string
  • optionaloutputs?: AbiInput[]
  • optionalstateMutability?: string
  • type: function

JsonRpcBatchRequest

JsonRpcBatchRequest: JsonRpcRequest[]

JsonRpcBatchResponse

JsonRpcBatchResponse<Result, Error>: (JsonRpcResponseWithError<Error> | JsonRpcResponseWithResult<Result>)[]

Type parameters

JsonRpcId

JsonRpcId: string | number | undefined

JsonRpcIdentifier

JsonRpcIdentifier: string & (2.0 | 1.0)

JsonRpcPayload

JsonRpcPayload<Param>: JsonRpcRequest<Param> | JsonRpcBatchRequest

Type parameters

  • Param = unknown[]

JsonRpcResponse

JsonRpcResponse<Result, Error>: JsonRpcResponseWithError<Error> | JsonRpcResponseWithResult<Result> | JsonRpcBatchResponse<Result, Error>

Type parameters

JsonRpcResult

JsonRpcResult: string | number | boolean | Record<string, unknown>

KeyStore

KeyStore: { address: string; crypto: { cipher: Cipher; cipherparams: { iv: string }; ciphertext: string; kdf: pbkdf2 | scrypt; kdfparams: ScryptParams | PBKDF2SHA256Params; mac: HexString }; id: string; version: 3 }

Type declaration

LogAPI

MatchPrimitiveType

MatchPrimitiveType<Type, TypeComponents>: PrimitiveAddressType<Type> | PrimitiveStringType<Type> | PrimitiveBooleanType<Type> | PrimitiveIntegerType<Type> | PrimitiveBytesType<Type> | PrimitiveTupleType<Type, TypeComponents> | never

Type parameters

  • Type: string
  • TypeComponents: ReadonlyArray<AbiParameter> | undefined

Mutable

Mutable<T>: { -readonly [ P in keyof T ]: T[P] }

Type parameters

  • T

Numbers

Numbers: number | bigint | string | HexString

Optional

Optional<T, K>: Pick<Partial<T>, K> & Omit<T, K>

Type parameters

  • T
  • K: keyof T

PBKDF2SHA256Params

PBKDF2SHA256Params: { c: number; dklen: number; prf: hmac-sha256; salt: Buffer | string }

Type declaration

  • c: number
  • dklen: number
  • prf: hmac-sha256
  • salt: Buffer | string

PopulatedUnsignedTransaction

PrimitiveAddressType

PrimitiveAddressType<Type>: Type extends `address[${infer Size}]` ? _TypedArray<Address, Size> : Type extends address ? Address : never

Type parameters

  • Type: string

PrimitiveBooleanType

PrimitiveBooleanType<Type>: Type extends `bool[${infer Size}]` ? _TypedArray<boolean, Size> : Type extends bool ? boolean : never

Type parameters

  • Type: string

PrimitiveBytesType

PrimitiveBytesType<Type>: Type extends `bytes${string}[${infer Size}]` ? _TypedArray<Bytes, Size> : Type extends bytes | `bytes${string}` ? Bytes : never

Type parameters

  • Type: string

PrimitiveIntegerType

PrimitiveIntegerType<Type>: Type extends `uint${string}[${infer Size}]` | `int${string}[${infer Size}]` ? _TypedArray<Numbers, Size> : Type extends uint | int | `int${string}` | `uint${string}` ? Numbers : never

Type parameters

  • Type: string

PrimitiveStringType

PrimitiveStringType<Type>: Type extends `string${string}[${infer Size}]` ? _TypedArray<string, Size> : Type extends string | `string${string}` ? string : never

Type parameters

  • Type: string

PrimitiveTupleType

PrimitiveTupleType<Type, TypeComponents>: TypeComponents extends ReadonlyArray<AbiParameter> ? Type extends tuple ? { [ Param in TypeComponents[number] as Param[name] ]: MatchPrimitiveType<Param[type], Param[components]> } : Type extends `tuple[${infer Size}]` ? _TypedArray<{ [ Param in TypeComponents[number] as Param[name] ]: MatchPrimitiveType<Param[type], Param[components]> }, Size> : never : never

Type parameters

  • Type: string
  • TypeComponents: ReadonlyArray<AbiParameter> | undefined = []

Receipt

Receipt: Record<string, unknown>

ScryptParams

ScryptParams: { dklen: number; n: number; p: number; r: number; salt: Buffer | string }

Type declaration

  • dklen: number
  • n: number
  • p: number
  • r: number
  • salt: Buffer | string

Sha3Input

Sha3Input: TypedObject | TypedObjectAbbreviated | Numbers | boolean | object

SupportedProviders

Type parameters

SyncingStatusAPI

SyncingStatusAPI: { currentBlock: Uint; highestBlock: Uint; startingBlock: Uint } | boolean

Topic

TransactionHash

TransactionHash: HexString

TransactionInfoAPI

TransactionInfoAPI: TransactionSignedAPI & { blockHash?: HexString32Bytes; blockNumber?: Uint; from: Address; hash: HexString32Bytes; transactionIndex?: Uint }

TransactionOutput

TransactionOutput: { blockNumber?: Numbers; from?: HexString; gas?: Numbers; gasLimit?: string; input: string; nonce: Numbers; to?: HexString; transactionIndex?: Numbers; value: Numbers } & ({ gasPrice?: never; maxFeePerGas: Numbers; maxPriorityFeePerGas: Numbers } | { gasPrice: Numbers; maxFeePerGas?: never; maxPriorityFeePerGas?: never })

TransactionReceipt

TransactionReceipt: TransactionReceiptBase<Numbers, Bytes, Bytes, Log>

TransactionReceiptAPI

TransactionSignedAPI

TransactionUnsignedAPI

TransactionWithSenderAPI

TransactionWithSenderAPI: TransactionUnsignedAPI & { from: Address }

TypedObject

TypedObject: { type: string; value: EncodingTypes }

Type declaration

TypedObjectAbbreviated

TypedObjectAbbreviated: { t: string; v: EncodingTypes }

Type declaration

Uint

Uint: HexString

Uint256

Uint256: HexString

Uncles

ValidChains

ValidChains: goerli | kovan | mainnet | rinkeby | ropsten | sepolia

ValueTypes

ValueTypes: address | bool | string | int256 | uint256 | bytes | bigint

Web3APIMethod

Web3APIMethod<T>: string & keyof Exclude<T, unknown>

Type parameters

Web3APIParams

Web3APIParams<API, Method>: API extends Exclude<Web3APISpec, unknown> ? Parameters<API[Method]> : unknown

Type parameters

Web3APIReturnType

Web3APIReturnType<API, Method>: API extends Record<string, (...params: any) => any> ? ReturnType<API[Method]> : any

Type parameters

Web3APISpec

Web3APISpec: Record<string, (...params: any) => any> | unknown

Web3BaseProviderConstructor

Web3BaseProviderConstructor: new <API>(url: string, net?: Socket) => Web3BaseProvider<API>

Type declaration

Web3EthExecutionAPI

Web3EthExecutionAPI: EthExecutionAPI & { eth_chainId: any; eth_getProof: any; eth_pendingTransactions: any; eth_requestAccounts: any; web3_clientVersion: any }

Web3NetAPI

Web3NetAPI: { net_listening: any; net_peerCount: any; net_version: any }

Type declaration

  • net_listening: function
    • net_listening(): boolean

    • Returns boolean

  • net_peerCount: function
    • net_peerCount(): string

    • Returns string

  • net_version: function
    • net_version(): string

    • Returns string

Web3ProviderEventCallback

Web3ProviderEventCallback<T>: (error: Error | ProviderRpcError | undefined, result?: JsonRpcSubscriptionResult | JsonRpcNotification<T>) => void

Type parameters

Type declaration

Web3ProviderRequestCallback

Web3ProviderRequestCallback<ResultType>: (err?: Error | Web3Error | null | JsonRpcResponseWithError<Error>, response?: JsonRpcResponseWithResult<ResultType>) => void

Type parameters

  • ResultType = unknown

Type declaration

Web3ProviderStatus

Web3ProviderStatus: connecting | connected | disconnected

Variables

constERR_ABI_ENCODING

ERR_ABI_ENCODING: 205 = 205

constERR_CONN

ERR_CONN: 500 = 500

constERR_CONN_CLOSE

ERR_CONN_CLOSE: 504 = 504

constERR_CONN_INVALID

ERR_CONN_INVALID: 501 = 501

constERR_CONN_MAX_ATTEMPTS

ERR_CONN_MAX_ATTEMPTS: 505 = 505

constERR_CONN_NOT_OPEN

ERR_CONN_NOT_OPEN: 503 = 503

constERR_CONN_PENDING_REQUESTS

ERR_CONN_PENDING_REQUESTS: 506 = 506

constERR_CONN_TIMEOUT

ERR_CONN_TIMEOUT: 502 = 502

constERR_CONTRACT

ERR_CONTRACT: 300 = 300

constERR_CONTRACT_ABI_MISSING

ERR_CONTRACT_ABI_MISSING: 302 = 302

constERR_CONTRACT_EVENT_NOT_EXISTS

ERR_CONTRACT_EVENT_NOT_EXISTS: 304 = 304

constERR_CONTRACT_EXECUTION_REVERTED

ERR_CONTRACT_EXECUTION_REVERTED: 310 = 310

constERR_CONTRACT_INSTANTIATION

ERR_CONTRACT_INSTANTIATION: 309 = 309

constERR_CONTRACT_MISSING_ADDRESS

ERR_CONTRACT_MISSING_ADDRESS: 307 = 307

constERR_CONTRACT_MISSING_DEPLOY_DATA

ERR_CONTRACT_MISSING_DEPLOY_DATA: 306 = 306

constERR_CONTRACT_MISSING_FROM_ADDRESS

ERR_CONTRACT_MISSING_FROM_ADDRESS: 308 = 308

constERR_CONTRACT_REQUIRED_CALLBACK

ERR_CONTRACT_REQUIRED_CALLBACK: 303 = 303

constERR_CONTRACT_RESERVED_EVENT

ERR_CONTRACT_RESERVED_EVENT: 305 = 305

constERR_CONTRACT_RESOLVER_MISSING

ERR_CONTRACT_RESOLVER_MISSING: 301 = 301

constERR_CONTRACT_TX_DATA_AND_INPUT

ERR_CONTRACT_TX_DATA_AND_INPUT: 311 = 311

constERR_CORE_CHAIN_MISMATCH

ERR_CORE_CHAIN_MISMATCH: 1102 = 1102

constERR_CORE_HARDFORK_MISMATCH

ERR_CORE_HARDFORK_MISMATCH: 1101 = 1101

constERR_ENS_CHECK_INTERFACE_SUPPORT

ERR_ENS_CHECK_INTERFACE_SUPPORT: 901 = 901

constERR_ENS_NETWORK_NOT_SYNCED

ERR_ENS_NETWORK_NOT_SYNCED: 903 = 903

constERR_ENS_UNSUPPORTED_NETWORK

ERR_ENS_UNSUPPORTED_NETWORK: 902 = 902

constERR_EXISTING_PLUGIN_NAMESPACE

ERR_EXISTING_PLUGIN_NAMESPACE: 206 = 206

constERR_FORMATTERS

ERR_FORMATTERS: 201 = 201

constERR_INVALID_ADDRESS

ERR_INVALID_ADDRESS: 1005 = 1005

constERR_INVALID_BLOCK

ERR_INVALID_BLOCK: 1012 = 1012

constERR_INVALID_BOOLEAN

ERR_INVALID_BOOLEAN: 1008 = 1008

constERR_INVALID_BYTES

ERR_INVALID_BYTES: 1002 = 1002

constERR_INVALID_CLIENT

ERR_INVALID_CLIENT: 602 = 602

constERR_INVALID_HEX

ERR_INVALID_HEX: 1006 = 1006

constERR_INVALID_KEYSTORE

ERR_INVALID_KEYSTORE: 708 = 708

constERR_INVALID_LARGE_VALUE

ERR_INVALID_LARGE_VALUE: 1011 = 1011

constERR_INVALID_METHOD_PARAMS

ERR_INVALID_METHOD_PARAMS: 207 = 207

constERR_INVALID_NIBBLE_WIDTH

ERR_INVALID_NIBBLE_WIDTH: 1014 = 1014

constERR_INVALID_NUMBER

ERR_INVALID_NUMBER: 1003 = 1003

constERR_INVALID_PASSWORD

ERR_INVALID_PASSWORD: 706 = 706

constERR_INVALID_PRIVATE_KEY

ERR_INVALID_PRIVATE_KEY: 702 = 702

constERR_INVALID_PROVIDER

ERR_INVALID_PROVIDER: 601 = 601

constERR_INVALID_RESPONSE

ERR_INVALID_RESPONSE: 101 = 101

constERR_INVALID_SIGNATURE

ERR_INVALID_SIGNATURE: 802 = 802

constERR_INVALID_SIZE

ERR_INVALID_SIZE: 1010 = 1010

constERR_INVALID_STRING

ERR_INVALID_STRING: 1001 = 1001

constERR_INVALID_TYPE

ERR_INVALID_TYPE: 1007 = 1007

constERR_INVALID_TYPE_ABI

ERR_INVALID_TYPE_ABI: 1013 = 1013

constERR_INVALID_UNIT

ERR_INVALID_UNIT: 1004 = 1004

constERR_INVALID_UNSIGNED_INTEGER

ERR_INVALID_UNSIGNED_INTEGER: 1009 = 1009

constERR_IV_LENGTH

ERR_IV_LENGTH: 707 = 707

constERR_KEY_DERIVATION_FAIL

ERR_KEY_DERIVATION_FAIL: 704 = 704

constERR_KEY_VERSION_UNSUPPORTED

ERR_KEY_VERSION_UNSUPPORTED: 705 = 705

constERR_METHOD_NOT_IMPLEMENTED

ERR_METHOD_NOT_IMPLEMENTED: 202 = 202

constERR_OPERATION_ABORT

ERR_OPERATION_ABORT: 204 = 204

constERR_OPERATION_TIMEOUT

ERR_OPERATION_TIMEOUT: 203 = 203

constERR_PARAM

ERR_PARAM: 200 = 200

constERR_PBKDF2_ITERATIONS

ERR_PBKDF2_ITERATIONS: 709 = 709

constERR_PRIVATE_KEY_LENGTH

ERR_PRIVATE_KEY_LENGTH: 701 = 701

constERR_PROVIDER

ERR_PROVIDER: 600 = 600

constERR_RAW_TX_UNDEFINED

ERR_RAW_TX_UNDEFINED: 407 = 407

constERR_REQ_ALREADY_SENT

ERR_REQ_ALREADY_SENT: 507 = 507

constERR_RESPONSE

ERR_RESPONSE: 100 = 100

constERR_RPC_INTERNAL_ERROR

ERR_RPC_INTERNAL_ERROR: -32603 = -32603

constERR_RPC_INVALID_INPUT

ERR_RPC_INVALID_INPUT: -32000 = -32000

constERR_RPC_INVALID_JSON

ERR_RPC_INVALID_JSON: -32700 = -32700

constERR_RPC_INVALID_METHOD

ERR_RPC_INVALID_METHOD: -32601 = -32601

constERR_RPC_INVALID_PARAMS

ERR_RPC_INVALID_PARAMS: -32602 = -32602

constERR_RPC_INVALID_REQUEST

ERR_RPC_INVALID_REQUEST: -32600 = -32600

constERR_RPC_LIMIT_EXCEEDED

ERR_RPC_LIMIT_EXCEEDED: -32005 = -32005

constERR_RPC_MISSING_RESOURCE

ERR_RPC_MISSING_RESOURCE: -32001 = -32001

constERR_RPC_NOT_SUPPORTED

ERR_RPC_NOT_SUPPORTED: -32006 = -32006

constERR_RPC_TRANSACTION_REJECTED

ERR_RPC_TRANSACTION_REJECTED: -32003 = -32003

constERR_RPC_UNAVAILABLE_RESOURCE

ERR_RPC_UNAVAILABLE_RESOURCE: -32002 = -32002

constERR_RPC_UNSUPPORTED_METHOD

ERR_RPC_UNSUPPORTED_METHOD: -32004 = -32004

constERR_SIGNATURE_FAILED

ERR_SIGNATURE_FAILED: 801 = 801

constERR_SUBSCRIPTION

ERR_SUBSCRIPTION: 603 = 603

constERR_TX

ERR_TX: 400 = 400

constERR_TX_BLOCK_TIMEOUT

ERR_TX_BLOCK_TIMEOUT: 432 = 432

constERR_TX_CHAIN_ID_MISMATCH

ERR_TX_CHAIN_ID_MISMATCH: 412 = 412

constERR_TX_CHAIN_MISMATCH

ERR_TX_CHAIN_MISMATCH: 435 = 435

constERR_TX_CONTRACT_NOT_STORED

ERR_TX_CONTRACT_NOT_STORED: 404 = 404

constERR_TX_DATA_AND_INPUT

ERR_TX_DATA_AND_INPUT: 425 = 425

constERR_TX_GAS_MISMATCH

ERR_TX_GAS_MISMATCH: 434 = 434

constERR_TX_HARDFORK_MISMATCH

ERR_TX_HARDFORK_MISMATCH: 436 = 436

constERR_TX_INVALID_CALL

ERR_TX_INVALID_CALL: 409 = 409

constERR_TX_INVALID_CHAIN_INFO

ERR_TX_INVALID_CHAIN_INFO: 413 = 413

constERR_TX_INVALID_FEE_MARKET_GAS

ERR_TX_INVALID_FEE_MARKET_GAS: 417 = 417

constERR_TX_INVALID_FEE_MARKET_GAS_PRICE

ERR_TX_INVALID_FEE_MARKET_GAS_PRICE: 418 = 418

constERR_TX_INVALID_LEGACY_FEE_MARKET

ERR_TX_INVALID_LEGACY_FEE_MARKET: 419 = 419

constERR_TX_INVALID_LEGACY_GAS

ERR_TX_INVALID_LEGACY_GAS: 416 = 416

constERR_TX_INVALID_NONCE_OR_CHAIN_ID

ERR_TX_INVALID_NONCE_OR_CHAIN_ID: 421 = 421

constERR_TX_INVALID_OBJECT

ERR_TX_INVALID_OBJECT: 420 = 420

constERR_TX_INVALID_RECEIVER

ERR_TX_INVALID_RECEIVER: 437 = 437

constERR_TX_INVALID_SENDER

ERR_TX_INVALID_SENDER: 408 = 408

constERR_TX_LOCAL_WALLET_NOT_AVAILABLE

ERR_TX_LOCAL_WALLET_NOT_AVAILABLE: 429 = 429

constERR_TX_MISSING_CHAIN_INFO

ERR_TX_MISSING_CHAIN_INFO: 414 = 414

constERR_TX_MISSING_CUSTOM_CHAIN

ERR_TX_MISSING_CUSTOM_CHAIN: 410 = 410

constERR_TX_MISSING_CUSTOM_CHAIN_ID

ERR_TX_MISSING_CUSTOM_CHAIN_ID: 411 = 411

constERR_TX_MISSING_GAS

ERR_TX_MISSING_GAS: 415 = 415

constERR_TX_NOT_FOUND

ERR_TX_NOT_FOUND: 430 = 430

constERR_TX_NO_CONTRACT_ADDRESS

ERR_TX_NO_CONTRACT_ADDRESS: 403 = 403

constERR_TX_OUT_OF_GAS

ERR_TX_OUT_OF_GAS: 406 = 406

constERR_TX_POLLING_TIMEOUT

ERR_TX_POLLING_TIMEOUT: 426 = 426

constERR_TX_RECEIPT_MISSING_BLOCK_NUMBER

ERR_TX_RECEIPT_MISSING_BLOCK_NUMBER: 428 = 428

constERR_TX_RECEIPT_MISSING_OR_BLOCKHASH_NULL

ERR_TX_RECEIPT_MISSING_OR_BLOCKHASH_NULL: 427 = 427

constERR_TX_REVERT_INSTRUCTION

ERR_TX_REVERT_INSTRUCTION: 401 = 401

constERR_TX_REVERT_TRANSACTION

ERR_TX_REVERT_TRANSACTION: 402 = 402

constERR_TX_REVERT_TRANSACTION_CUSTOM_ERROR

ERR_TX_REVERT_TRANSACTION_CUSTOM_ERROR: 438 = 438

constERR_TX_REVERT_WITHOUT_REASON

ERR_TX_REVERT_WITHOUT_REASON: 405 = 405

constERR_TX_SEND_TIMEOUT

ERR_TX_SEND_TIMEOUT: 431 = 431

constERR_TX_SIGNING

ERR_TX_SIGNING: 433 = 433

constERR_TX_UNABLE_TO_POPULATE_NONCE

ERR_TX_UNABLE_TO_POPULATE_NONCE: 422 = 422

constERR_TX_UNSUPPORTED_EIP_1559

ERR_TX_UNSUPPORTED_EIP_1559: 423 = 423

constERR_TX_UNSUPPORTED_TYPE

ERR_TX_UNSUPPORTED_TYPE: 424 = 424

constERR_UNSUPPORTED_KDF

ERR_UNSUPPORTED_KDF: 703 = 703

constERR_VALIDATION

ERR_VALIDATION: 1100 = 1100

constERR_WS_PROVIDER

ERR_WS_PROVIDER: 604 = 604

constGENESIS_BLOCK_NUMBER

GENESIS_BLOCK_NUMBER: 0x0 = "0x0"

constJSONRPC_ERR_CHAIN_DISCONNECTED

JSONRPC_ERR_CHAIN_DISCONNECTED: 4901 = 4901

constJSONRPC_ERR_DISCONNECTED

JSONRPC_ERR_DISCONNECTED: 4900 = 4900

constJSONRPC_ERR_REJECTED_REQUEST

JSONRPC_ERR_REJECTED_REQUEST: 4001 = 4001

constJSONRPC_ERR_UNAUTHORIZED

JSONRPC_ERR_UNAUTHORIZED: 4100 = 4100

constJSONRPC_ERR_UNSUPPORTED_METHOD

JSONRPC_ERR_UNSUPPORTED_METHOD: 4200 = 4200

constTypedArray

TypedArray: any

constrpcErrorsMap

rpcErrorsMap: Map<number, { error: typeof RpcError }>