web3
This is a main package of web3.js
Please read the main readme and documentation for more.
Installation
Node.js
npm install web3Ethereum JavaScript API
This is a main package of web3.js
Please read the main readme and documentation for more.
npm install web3All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
In 1.x user had access to raw connection object and can interact with it. e.g.
web3.currentProvider.connection.close();But this internal behavior is not exposed any further. Though you can achieve same with this approach.
web3.currentProvider.disconnect();tsc compiled files moved to lib/ directory from dist/ (#5739)build entry from package.json (#5755)registeredSubscriptions was added by default in web3 constructor (#5792)web3-types, web3-errors and web3. (#5771)new Web3().eth.contract (#5824)require('web3') will now return all web3 exported-objects organized in namespaces . (#5771)_contracts:Contract[] and static setProvider function was removed (#5792)net and fs modules (#5978)web3-providers-ipc and instantiate provider yourself (#5978)Release Notes:
Detailed List of change logs are mentioned under previous 4.x alpha and RC releases.
Documentation: Web3.js documentation Web3 API Migration Guide from 1.x
Web3Context, Web3PluginBase, Web3EthPluginBase from 'web3-core', and Web3Validator from 'web3-validator' (#6165)Web3ContextInitOptions<EthExecutionAPI, CustomRegisteredSubscription> as alternative to the still supported undefined, string, and SupportedProviders<EthExecutionAPI> (#6262).requestEIP6963Providers for multi provider discovery ( other details are in root changelog )ContractDeploySend, ContractMethodSend, Web3PromiEvent was exported (#6883)toNumber(...) function (#6880)getBlock now includes properties of eip 4844, 4895, 4788 when returning block (#6933)withdrawalsSchema, blockSchema and blockHeaderSchema schemas to include properties of eip 4844, 4895, 4788 (#6933)signature to type AbiFunctionFragment (#6922)Withdrawals, block and BlockHeaderOutput to include properties of eip 4844, 4895, 4788 (#6933)Web3EthInterface.accounts to includes privateKeyToAccount,privateKeyToAddress,and privateKeyToPublicKey (#6762)defaultReturnFormat was added to the configuration options. (#6947)InvalidIntegerError error for fromWei and toWei (#7052)defaultReturnFormat was added to all methods that have ReturnType param. (#6947)getTransactionFromOrToAttr, waitForTransactionReceipt, trySendTransaction, SendTxHelper was exported (#7000)defaultReturnFormat was added to all methods that have ReturnType param. (#6947)defaultReturnFormat was added to all methods that have ReturnType param. (#6947)defaultReturnFormat was added to all methods that have ReturnType param. (#6947)signature to type AbiFunctionFragment (#6922)Withdrawals, block and BlockHeaderOutput to include properties of eip 4844, 4895, 4788 (#6933)toWei add warning when using large numbers or large decimals that may cause precision loss (#6908)toWei and fromWei now supports integers as a unit. (#7053)checkRevertBeforeSending if there is no data set in transaction, set gas to be 21000 (#7043)toWei support numbers in scientific notation (#6908)toWei and fromWei trims according to ether unit successfuly (#7044)abi.name is not available, for example, in the case of public mappings. (#6981)browser entry point that was pointing to a non-existing bundle file was removed from package.json (#7015)RequestManagerMiddleware was changed (#7003)customTransactionReceiptSchema into methods emitConfirmation, waitForTransactionReceipt, watchTransactionByPolling, watchTransactionBySubscription, watchTransactionForConfirmations (#7000)baseFeePerGas===0x0 fill maxPriorityFeePerGas and maxFeePerGas by getGasPrice method (#7050)estimateGas method to add possibility pass Transaction type (#7000)sendTransaction in rpc_method_wrappers accepts optional param of TransactionMiddleware (#7088)setTransactionMiddleware and getTransactionMiddleware for automatically passing to sentTransaction (#7088)getText now supports first param AddressgetName has optional second param checkInterfaceSupportresult as optional never and error as optional never in typeJsonRpcNotification` (#7091)JsonRpcNotfication as a union type in JsonRpcResponse (#7091)getName reverse resolution_sendPendingRequests will catch unhandled errors from _sendToSocket (#6968)populateTransaction was added to contract methods (#7124)setTransactionMiddleware and getTransactionMiddleware for automatically passing to sentTransaction for deploy and send functions (#7138)web3.eth.Contract will get transaction middleware and use it, if web3.eth has transaction middleware. (#7138)Eip838ExecutionError constructor (#6905)getTransactionReceipt to not be casted as TransactionReceipt to give proper return type (#7159)setConfig() fix for setMaxListenerWarningThreshold fix (#5079)TransactionFactory.registerTransactionType not working, if there is a version mistatch between web3-eth and web3-eth-accounts by saving extraTxTypes at globals. (#7197)signMessageWithPrivateKey (#7174)populateTransaction to the contract.deploy(...) properties. (#7197)statusCode of response in ResponseError, statusCode is optional property in ResponseError.HttpProviderOptions | SocketOptions in Web3ExternalProvider and QuickNodeProvider for provider configsstatusCode property of response in ResponseError.contract.deploy(...) are structured with a newly created class named DeployerMethodClass. (#7197)abi parameter, at dataInputEncodeMethodHelper and getSendTxParams. (#7197)TransactionFactory.registerTransactionType if there is a version mistatch between web3-eth and web3-eth-accounts and fix nextjs problem. (#7216)Web3.providers namespace exports type EIP6963ProviderResponse = Map<string, EIP6963ProviderDetail>. Return type for the static Web3.requestEIP6963Providers function is now Promise<EIP6963ProviderResponse>. (#7239)Web3.onNewProviderDiscovered function expects a parameter of type EIP6963ProvidersMapUpdateEvent as opposed to EIP6963AnnounceProviderEvent. (#7242)providers namespace. (#7270)ignoreGasPricing to Web3ConfigOptions. If ignoreGasPricing is true, gasPrice will not be estimated (#7320)populateGasPrice function now checks Web3Context.config.ignoreGasPricing. If ignoreGasPricing is true, gasPrice will not be estimated (#7320)providers namespace. (#7270)getEthereumjsTxDataFrom to return additional fields that may be passed if using a customTransactionSchema.syncing subscription now supports Besu and Nethermind payload formatbaseFeePerGas at web3.eth.getFeeHistory to be a number. (#7291)decodeLog , decodeParametersWith , decodeParameters and decodeParameters now accepts first immutable param as well (#7288)padRight validation failure on large uint (#7265)createNewPendingTransactionFilter , createNewFilter , createNewBlockFilter , uninstallFilter , getFilterChanges and getFilterLogs are exported from Web3Eth and filtering_rpc_method_wrappers (#7353)decodeFunctionCall and decodeFunctionReturn. (#7345)hashMessage now has a new optional param skipPrefix with a default value of false. A new function signRaw was added to sign a message without prefix. (#7346)FilterParams type added (#7353)fromWei return "0" when input is 0 (#7387)