• Version 4.11.0
  • Published
  • 181 kB
  • 17 dependencies
  • LGPL-3.0 license


npm i web3
yarn add web3
pnpm add web3


Ethereum JavaScript API



class Web3

class Web3<
CustomRegisteredSubscription extends {
[key: string]: Web3SubscriptionConstructor<EthExecutionAPI>;
} = RegisteredSubscription
> extends Web3Context<
CustomRegisteredSubscription & RegisteredSubscription
> {}


    constructor(providerOrContext?: any);

      property eth

      eth: Web3EthInterface;

        property modules

        static modules: { Web3Eth: any; Iban: any; Net: any; ENS: any; Personal: any };

          property onNewProviderDiscovered

          static onNewProviderDiscovered: (
          callback: (
          providerEvent: import('./web3_eip6963.js').EIP6963AnnounceProviderEvent<unknown>
          ) => void
          ) => void;

            property requestEIP6963Providers

            static requestEIP6963Providers: () => Promise<unknown>;

              property utils

              static utils: any;

                property utils

                utils: any;

                  property version

                  static version: string;


                    interface Web3EthInterface

                    interface Web3EthInterface extends Eth {}
                    • The Ethereum interface for main web3 object. It provides extra methods in addition to web3-eth interface.

                      web3_eth.Web3Eth for details about the Eth interface.

                    property abi

                    abi: {
                    encodeEventSignature: typeof encodeFunctionSignature;
                    encodeFunctionCall: typeof encodeFunctionCall;
                    encodeFunctionSignature: typeof encodeFunctionSignature;
                    encodeParameter: typeof encodeParameter;
                    encodeParameters: typeof encodeParameters;
                    decodeParameter: typeof decodeParameter;
                    decodeParameters: typeof decodeParameters;
                    decodeLog: typeof decodeLog;

                      property accounts

                      accounts: {
                      create: () => Web3Account;
                      privateKeyToAccount: (privateKey: Uint8Array | string) => Web3Account;
                      signTransaction: (
                      transaction: Transaction,
                      privateKey: Bytes
                      ) => ReturnType<typeof signTransaction>;
                      recoverTransaction: typeof recoverTransaction;
                      hashMessage: typeof hashMessage;
                      sign: typeof sign;
                      recover: typeof recover;
                      encrypt: typeof encrypt;
                      decrypt: (
                      keystore: string,
                      password: string,
                      options?: Record<string, unknown>
                      ) => Promise<Web3Account>;
                      wallet: Wallet;
                      privateKeyToAddress: (privateKey: Bytes) => string;
                      privateKeyToPublicKey: (privateKey: Bytes, isCompressed: boolean) => string;
                      parseAndValidatePrivateKey: (
                      data: Bytes,
                      ignoreLength?: boolean
                      ) => Uint8Array;

                        property Contract

                        Contract: typeof Contract;
                        • Extended [Contract](/api/web3-eth-contract/class/Contract) constructor for main web3 object. See [Contract](/api/web3-eth-contract/class/Contract) for further details.

                          You can use .setProvider on this constructor to set provider for **all the instances** of the contracts which were created by web3.eth.Contract. Please check the to understand more about setting provider.


                        property ens

                        ens: ENS;

                          property Iban

                          Iban: typeof Iban;

                            property net

                            net: Net;

                              property personal

                              personal: Personal;


                                namespace eth

                                module 'lib/commonjs/eth.exports.d.ts' {}

                                  namespace providers

                                  module 'lib/commonjs/providers.exports.d.ts' {}

                                    variable eip6963ProvidersMap

                                    const eip6963ProvidersMap: Map<string, EIP6963ProviderDetail<Web3APISpec>>;

                                      variable web3ProvidersMapUpdated

                                      const web3ProvidersMapUpdated: string;

                                        function onNewProviderDiscovered

                                        onNewProviderDiscovered: (
                                        callback: (providerEvent: EIP6963AnnounceProviderEvent) => void
                                        ) => void;

                                          function requestEIP6963Providers

                                          requestEIP6963Providers: () => Promise<unknown>;

                                            interface EIP6963AnnounceProviderEvent

                                            interface EIP6963AnnounceProviderEvent<API = Web3APISpec> extends CustomEvent {}

                                              property detail

                                              detail: EIP6963ProviderDetail<API>;

                                                property type

                                                type: Eip6963EventName.eip6963announceProvider;

                                                  interface EIP6963ProviderDetail

                                                  interface EIP6963ProviderDetail<API = Web3APISpec> {}

                                                    property info

                                                    info: EIP6963ProviderInfo;

                                                      property provider

                                                      provider: EIP1193Provider<API>;

                                                        interface EIP6963ProviderInfo

                                                        interface EIP6963ProviderInfo {}

                                                          property icon

                                                          icon: string;

                                                            property name

                                                            name: string;

                                                              property rdns

                                                              rdns: string;

                                                                property uuid

                                                                uuid: string;

                                                                  interface EIP6963ProvidersMapUpdateEvent

                                                                  interface EIP6963ProvidersMapUpdateEvent extends CustomEvent {}

                                                                    property detail

                                                                    detail: Map<string, EIP6963ProviderDetail>;

                                                                      property type

                                                                      type: string;

                                                                        interface EIP6963RequestProviderEvent

                                                                        interface EIP6963RequestProviderEvent extends Event {}

                                                                          property type

                                                                          type: Eip6963EventName.eip6963requestProvider;

                                                                            enum Eip6963EventName

                                                                            enum Eip6963EventName {
                                                                            eip6963announceProvider = 'eip6963:announceProvider',
                                                                            eip6963requestProvider = 'eip6963:requestProvider',

                                                                              member eip6963announceProvider

                                                                              eip6963announceProvider = 'eip6963:announceProvider'

                                                                                member eip6963requestProvider

                                                                                eip6963requestProvider = 'eip6963:requestProvider'

                                                                                  Package Files (6)

                                                                                  Dependencies (17)

                                                                                  Dev Dependencies (20)

                                                                                  Peer Dependencies (0)

                                                                                  No peer dependencies.


                                                                                  To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                                                                                  You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/web3.

                                                                                  • Markdown
                                                                                  • HTML
                                                                                    <a href="https://www.jsdocs.io/package/web3"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>