Hierarchy

  • Web3ZkSync
    • Web3ZKsyncL2

Constructors

Properties

Accessors

Methods

Constructors

Properties

_accountProvider?: Web3AccountProvider<Web3BaseWalletAccount>
_contractAddresses: {
    baseToken?: string;
    bridgehubContract?: string;
    erc20BridgeL1?: string;
    erc20BridgeL2?: string;
    mainContract?: string;
    sharedBridgeL1?: string;
    sharedBridgeL2?: string;
    wethBridgeL1?: string;
    wethBridgeL2?: string;
}
_requestManager: Web3RequestManager<EthExecutionAPI>
_subscriptionManager: Web3SubscriptionManager<EthExecutionAPI, RegisteredSubscription>
_wallet?: Web3BaseWallet<Web3BaseWalletAccount>
config: Web3ConfigOptions
eth: Web3EthInterface
providers: {
    HttpProvider: Web3BaseProviderConstructor;
    WebsocketProvider: Web3BaseProviderConstructor;
}
utils: __module
ZKsync: ZKsyncPlugin
givenProvider?: SupportedProviders<never>
modules: {
    ENS: typeof ENS;
    Iban: typeof Iban;
    Net: typeof Net;
    Personal: typeof Personal;
    Web3Eth: typeof Web3Eth;
}
onNewProviderDiscovered: ((callback: ((providerEvent: EIP6963AnnounceProviderEvent<unknown>) => void)) => void)
providers: {
    HttpProvider: Web3BaseProviderConstructor;
    WebsocketProvider: Web3BaseProviderConstructor;
}
requestEIP6963Providers: (() => Promise<unknown>)
utils: __module
version: string

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

    Returns void

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

  • set defaultNetworkId(val): void
  • Parameters

    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

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

  • Parameters

    • txHash: string
    • index: number = 0

    Returns Promise<{
        l1BatchTxId: string | number | bigint;
        l2ToL1Log: {
            blockHash: string;
            blockNumber: string | number | bigint;
            isService: boolean;
            key: string;
            l1BatchNumber: string | number | bigint;
            logIndex: string | number | bigint;
            sender: string;
            shardId: string | number | bigint;
            transactionHash: string;
            transactionIndex: string | number | bigint;
            value: string;
        };
        l2ToL1LogIndex: number;
    }>

  • Returns {
        baseToken?: string;
        bridgehubContract?: string;
        erc20BridgeL1?: string;
        erc20BridgeL2?: string;
        mainContract?: string;
        sharedBridgeL1?: string;
        sharedBridgeL2?: string;
        wethBridgeL1?: string;
        wethBridgeL2?: string;
    }

    • OptionalbaseToken?: string
    • OptionalbridgehubContract?: string
    • Optionalerc20BridgeL1?: string
    • Optionalerc20BridgeL2?: string
    • OptionalmainContract?: string
    • OptionalsharedBridgeL1?: string
    • OptionalsharedBridgeL2?: string
    • OptionalwethBridgeL1?: string
    • OptionalwethBridgeL2?: string
  • 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: "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: "defaultReturnFormat";
                  newValue: DataFormat;
                  oldValue: DataFormat;
              };
      }[K]

    Returns void

  • Returns the fee for the transaction.

    Parameters

    • transaction: Partial<TransactionWithSenderAPI>

      Transaction object.

    • returnFormat: DataFormat = DEFAULT_RETURN_FORMAT

      The format of the return value.

    Returns Promise<EstimateFee>

  • Returns an estimate of the gas required for a L1 to L2 transaction.

    Parameters

    • transaction: Partial<DeepWriteable<Transaction & {
          customData?: null | Eip712Meta;
          type?: Numbers;
      }>>

      Transaction object.

    • returnFormat: DataFormat = DEFAULT_RETURN_FORMAT

      The format of the return value.

    Returns Promise<Numbers>

  • 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 all balances for confirmed tokens given by an account address.

    Parameters

    • address: string

      The account address.

    • returnFormat: DataFormat = DEFAULT_RETURN_FORMAT

      The format of the return value.

    Returns Promise<WalletBalances>

  • Parameters

    • address: string
    • OptionalblockTag: BlockNumberOrTag
    • OptionaltokenAddress: string

    Returns Promise<bigint>

  • Returns the L1 base token address.

    Returns Promise<string>

  • Returns additional ZKsync-specific information about the L2 block.

    committed: The batch is closed and the state transition it creates exists on layer 1. proven: The batch proof has been created, submitted, and accepted on layer 1. executed: The batch state transition has been executed on L1; meaning the root state has been updated.

    Parameters

    • number: Numbers

      The number of the block.

    • returnFormat: DataFormat = DEFAULT_RETURN_FORMAT

      The format of the return value.

    Returns Promise<BlockDetails>

  • Returns the address of the BridgeHub contract.

    Parameters

    • returnFormat: DataFormat = DEFAULT_RETURN_FORMAT

      The format of the return value.

    Returns Promise<string>

  • Returns bytecode of a transaction given by its hash.

    Parameters

    • bytecodeHash: Bytes

      Bytecode hash as string.

    • returnFormat: DataFormat = DEFAULT_RETURN_FORMAT

      The format of the return value.

    Returns Promise<Uint8Array>

  • Returns Web3ContextObject<EthExecutionAPI, RegisteredSubscription>

  • Returns the range of blocks contained within a batch given by batch number. The range is given by beginning/end block numbers in hexadecimal.

    Parameters

    • number: Numbers

      The layer 1 batch number.

    • returnFormat: DataFormat = DEFAULT_RETURN_FORMAT

      The format of the return value.

    Returns Promise<Bytes[]>

  • Returns data pertaining to a given batch.

    Parameters

    • number: Numbers

      The layer 1 batch number.

    • returnFormat: DataFormat = DEFAULT_RETURN_FORMAT

      The format of the return value.

    Returns Promise<BatchDetails>

  • Returns the latest L1 batch number.

    Parameters

    • returnFormat: DataFormat = DEFAULT_RETURN_FORMAT

      The format of the return value.

    Returns Promise<bigint>

  • Given a transaction hash, and an index of the L2 to L1 log produced within the transaction, it returns the proof for the corresponding L2 to L1 log.

    The index of the log that can be obtained from the transaction receipt (it includes a list of every log produced by the transaction)

    Parameters

    • txHash: string

      Hash of the L2 transaction the L2 to L1 log was produced within.

    • Optionall2ToL1LogIndex: Numbers

      The index of the L2 to L1 log in the transaction (optional).

    • returnFormat: DataFormat = DEFAULT_RETURN_FORMAT

      The format of the return value.

    Returns Promise<L2ToL1Proof>

  • Returns a L2 transaction response from L1 transaction response.

    Parameters

    • receipt: TransactionReceipt

    Returns Promise<string>

  • Returns the address of the ZKsync Era contract.

    Parameters

    • returnFormat: DataFormat = DEFAULT_RETURN_FORMAT

      The format of the return value.

    Returns Promise<string>

  • Returns number

  • Returns the transaction confirmation data that is part of L2->L1 message.

    Parameters

    • txHash: string

      The hash of the L2 transaction where the message was initiated.

    • Optionalindex: number = 0

      In case there were multiple transactions in one message, you may pass an index of the transaction which confirmation data should be fetched.

    Returns Promise<{
        l1BatchNumber: string | number | bigint;
        l2MessageIndex: Numbers;
        l2TxNumberInBlock: string | number | bigint;
        proof: string[];
    }>

    If log proof can not be found.

  • Returns Merkle proofs for one or more storage values at the specified account along with a Merkle proof of their authenticity. This allows to verify that the values have not been tampered with. More details: https://docs.zksync.io/build/api.html#zks-getproof

    Parameters

    • address: string

      The account to fetch storage values and proofs for.

    • keys: string[]

      Vector of storage keys in the account.

    • l1BatchNumber: Numbers

      Number of the L1 batch specifying the point in time at which the requested values are returned.

    • returnFormat: DataFormat = DEFAULT_RETURN_FORMAT

      The format of the return value.

    Returns Promise<StorageProof>

  • Parameters

    • token: string
    • walletAddress: string

    Returns Promise<bigint>

  • Returns data from a specific transaction given by the transaction hash.

    Parameters

    • txHash: Bytes

      Transaction hash as string.

    • returnFormat: DataFormat = DEFAULT_RETURN_FORMAT

      The format of the return value.

    Returns Promise<TransactionDetails>

  • Returns the populated transfer transaction.

    Parameters

    Returns Promise<DeepWriteable<Transaction & {
        customData?: null | Eip712Meta;
        type?: Numbers;
    }> | {
        accessList?: AccessList;
        chain?: ValidChains;
        chainId?: Numbers;
        common?: Common;
        customData: {
            paymasterParams: PaymasterParams;
        };
        data?: Bytes;
        from?: string;
        gas?: Numbers;
        gasLimit?: Numbers;
        gasPrice?: Numbers;
        hardfork?:
            | "chainstart"
            | "frontier"
            | "homestead"
            | "dao"
            | "tangerineWhistle"
            | "spuriousDragon"
            | "byzantium"
            | "constantinople"
            | "petersburg"
            | "istanbul"
            | "muirGlacier"
            | "berlin"
            | "london"
            | "altair"
            | "arrowGlacier"
            | "grayGlacier"
            | "bellatrix"
            | "merge"
            | "capella"
            | "shanghai";
        input?: Bytes;
        maxFeePerGas?: Numbers;
        maxPriorityFeePerGas?: Numbers;
        networkId?: Numbers;
        nonce?: Numbers;
        r?: Bytes;
        s?: Bytes;
        to: string;
        type?: Numbers;
        v?: Numbers;
        value?: Numbers;
        yParity?: string;
    }>

  • Returns the populated withdrawal transaction.

    Parameters

    Returns Promise<TransactionCall | {
        accessList?: AccessList;
        chain?: ValidChains;
        chainId?: Numbers;
        common?: Common;
        customData: {
            paymasterParams: PaymasterParams;
        };
        data?: Bytes;
        from?: string;
        gas?: Numbers;
        gasLimit?: Numbers;
        gasPrice?: Numbers;
        hardfork?:
            | "chainstart"
            | "frontier"
            | "homestead"
            | "dao"
            | "tangerineWhistle"
            | "spuriousDragon"
            | "byzantium"
            | "constantinople"
            | "petersburg"
            | "istanbul"
            | "muirGlacier"
            | "berlin"
            | "london"
            | "altair"
            | "arrowGlacier"
            | "grayGlacier"
            | "bellatrix"
            | "merge"
            | "capella"
            | "shanghai";
        input?: Bytes;
        maxFeePerGas?: Numbers;
        maxPriorityFeePerGas?: Numbers;
        networkId?: Numbers;
        nonce?: Numbers;
        r?: Bytes;
        s?: Bytes;
        to: string;
        type?: Numbers;
        v?: Numbers;
        value?: Numbers;
        yParity?: string;
    }>

  • Type Parameters

    • ReturnFormat extends DataFormat

    Parameters

    Returns Promise<undefined | {
        blockHash: ByteTypes[ReturnFormat["bytes"]];
        blockNumber: NumberTypes[ReturnFormat["number"]];
        contractAddress?: string;
        cumulativeGasUsed: NumberTypes[ReturnFormat["number"]];
        effectiveGasPrice?: NumberTypes[ReturnFormat["number"]];
        events?: {};
        from: string;
        gasUsed: NumberTypes[ReturnFormat["number"]];
        l1BatchNumber: NumberTypes[ReturnFormat["number"]];
        l1BatchTxIndex: NumberTypes[ReturnFormat["number"]];
        l2ToL1Logs: {
            blockHash: string;
            blockNumber: NumberTypes[ReturnFormat["number"]];
            isService: boolean;
            key: string;
            l1BatchNumber: NumberTypes[ReturnFormat["number"]];
            logIndex: NumberTypes[ReturnFormat["number"]];
            sender: string;
            shardId: NumberTypes[ReturnFormat["number"]];
            transactionHash: string;
            transactionIndex: NumberTypes[ReturnFormat["number"]];
            value: string;
        }[];
        logs: {
            address?: string;
            blockHash?: ByteTypes[ReturnFormat["bytes"]];
            blockNumber?: NumberTypes[ReturnFormat["number"]];
            data?: ByteTypes[ReturnFormat["bytes"]];
            id?: string;
            l1BatchNumber: NumberTypes[ReturnFormat["number"]];
            logIndex?: NumberTypes[ReturnFormat["number"]];
            removed?: boolean;
            topics?: ByteTypes[ReturnFormat["bytes"]][];
            transactionHash?: ByteTypes[ReturnFormat["bytes"]];
            transactionIndex?: NumberTypes[ReturnFormat["number"]];
        }[];
        logsBloom: ByteTypes[ReturnFormat["bytes"]];
        root: ByteTypes[ReturnFormat["bytes"]];
        status: NumberTypes[ReturnFormat["number"]];
        to: string;
        transactionHash: ByteTypes[ReturnFormat["bytes"]];
        transactionIndex: NumberTypes[ReturnFormat["number"]];
        type?: NumberTypes[ReturnFormat["number"]];
    }>

  • Returns whether the token is the base token.

    Parameters

    • token: string

    Returns Promise<boolean>

  • Returns whether the chain is ETH-based.

    Returns Promise<boolean>

  • Returns the chain id of the underlying L1.

    Parameters

    • returnFormat: DataFormat = DEFAULT_RETURN_FORMAT

      The format of the return value.

    Returns Promise<bigint>

  • Returns the L2 token address equivalent for a L1 token address as they are not equal. ETH address is set to zero address.

    Parameters

    • token: string

      The address of the token on L1.

    Returns Promise<string>

    Only works for tokens bridged on default ZKsync Era bridges.

  • 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: "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: "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: "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: "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: "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: "defaultReturnFormat";
                  newValue: DataFormat;
                  oldValue: DataFormat;
              };
      }[K]>

    Returns void

  • Parameters

    • transaction: Eip712TxData
    • returnFormat: DataFormat = DEFAULT_RETURN_FORMAT

    Returns {
        accessList?: null | [string | Uint8Array, (string | Uint8Array)[]][] | {
            address: string;
            storageKeys: string[];
        }[];
        chainId?: string | number | bigint;
        customData?: null | {
            customSignature?: string | Uint8Array;
            factoryDeps?: (string | Uint8Array)[];
            gasPerPubdata?: string | number | bigint;
            paymasterParams?: {
                paymaster: string;
                paymasterInput: string | Uint8Array;
            };
        };
        data?:
            | string
            | number
            | bigint
            | number[]
            | Uint8Array;
        eip712Meta?: null | {
            customSignature?: string | Uint8Array;
            factoryDeps?: (string | Uint8Array)[];
            gasPerPubdata?: string | number | bigint;
            paymasterParams?: {
                paymaster: string;
                paymasterInput: string | Uint8Array;
            };
        };
        from?: string;
        gasLimit?:
            | string
            | number
            | bigint
            | Uint8Array;
        gasPrice?:
            | null
            | string
            | number
            | bigint
            | Uint8Array;
        hash?: string;
        maxFeePerGas?:
            | string
            | number
            | bigint
            | Uint8Array;
        maxPriorityFeePerGas?:
            | string
            | number
            | bigint
            | Uint8Array;
        nonce?:
            | string
            | number
            | bigint
            | Uint8Array;
        r?:
            | string
            | number
            | bigint
            | Uint8Array;
        s?:
            | string
            | number
            | bigint
            | Uint8Array;
        signature?: string;
        to?: string | Uint8Array | Address;
        type?: string | number | bigint;
        v?:
            | string
            | number
            | bigint
            | Uint8Array;
        value?:
            | string
            | number
            | bigint
            | Uint8Array;
    }

    • OptionalaccessList?: null | [string | Uint8Array, (string | Uint8Array)[]][] | {
          address: string;
          storageKeys: string[];
      }[]

      The access list which contains the addresses/storage slots which the transaction wishes to access

    • OptionalchainId?: string | number | bigint

      The transaction's chain ID

    • OptionalcustomData?: null | {
          customSignature?: string | Uint8Array;
          factoryDeps?: (string | Uint8Array)[];
          gasPerPubdata?: string | number | bigint;
          paymasterParams?: {
              paymaster: string;
              paymasterInput: string | Uint8Array;
          };
      }
    • Optionaldata?:
          | string
          | number
          | bigint
          | number[]
          | Uint8Array

      This will contain the data of the message or the init of a contract.

    • Optionaleip712Meta?: null | {
          customSignature?: string | Uint8Array;
          factoryDeps?: (string | Uint8Array)[];
          gasPerPubdata?: string | number | bigint;
          paymasterParams?: {
              paymaster: string;
              paymasterInput: string | Uint8Array;
          };
      }

      The custom data for EIP712 transaction metadata.

    • Optionalfrom?: string
    • OptionalgasLimit?:
          | string
          | number
          | bigint
          | Uint8Array

      The transaction's gas limit.

    • OptionalgasPrice?:
          | null
          | string
          | number
          | bigint
          | Uint8Array

      The transaction's gas price. To be used if maxPriorityFeePerGas and maxFeePerGas were not provided

    • Optionalhash?: string
    • OptionalmaxFeePerGas?:
          | string
          | number
          | bigint
          | Uint8Array

      The maximum total fee

    • OptionalmaxPriorityFeePerGas?:
          | string
          | number
          | bigint
          | Uint8Array

      The maximum inclusion fee per gas (this fee is given to the miner)

    • Optionalnonce?:
          | string
          | number
          | bigint
          | Uint8Array

      The transaction's nonce.

    • Optionalr?:
          | string
          | number
          | bigint
          | Uint8Array

      EC signature parameter.

    • Optionals?:
          | string
          | number
          | bigint
          | Uint8Array

      EC signature parameter.

    • Optionalsignature?: string
    • Optionalto?: string | Uint8Array | Address

      The transaction's the address is sent to.

    • Optionaltype?: string | number | bigint

      The transaction type

    • Optionalv?:
          | string
          | number
          | bigint
          | Uint8Array

      EC recovery ID.

    • Optionalvalue?:
          | string
          | number
          | bigint
          | Uint8Array

      The amount of Ether sent.

  • Parameters

    • plugin: Web3PluginBase<unknown>

    Returns void

  • Returns EventEmitter

  • Parameters

    • signedTx: string

    Returns Promise<string>

  • Parameters

    Returns Promise<TransactionReceipt>

  • Parameters

    • options: Partial<Web3ConfigOptions>

    Returns void

  • Parameters

    • maxListenersWarningThreshold: number

    Returns void

  • Will set the provider.

    Parameters

    • Optionalprovider: string | SupportedProviders<EthExecutionAPI>

      SupportedProviders The provider to set

    Returns boolean

    Returns true if the provider was set

  • Parameters

    • requestManagerMiddleware: RequestManagerMiddleware<EthExecutionAPI>

    Returns void

  • 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

  • Type Parameters

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

    Parameters

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

    Returns T

  • Creates a new Provider from provided URL or network name.

    Parameters

    • zksyncNetwork: Network = ZKsyncNetwork.Localhost

    Returns Web3ZKsyncL2

    import { initWithDefaultProvider, types } from "web3-plugin-zksync";

    const provider = ZKsyncNetwork.initWithDefaultProvider(types.Network.Sepolia);