Changelog
All 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.
[4.0.0-alpha.0]
Breaking Changes
Receipt Status
The receiptInfo Status will now be be an unsigned integer instead of boolean value to comply with the specification.
1.x
myContract.methods
.MyMethod()
.send()
.on('receipt', receipt => {
console.log(receipt.status); // true | false
});
4.x
myContract.methods
.MyMethod()
.send()
.on('receipt', receipt => {
console.log(receipt.status); // BigInt(0) | BigInt(1)
});
NOTE: The unsigned integer type is dependent on the data format you specified. Default type is bigint.
Deploy ’sending’ and sent event will fire only the params
In 1.x when following was executed deploy().send().on(‘sending’, payload => {}). The payload was the complete the JSON-RPC Payload. In 4.x it will just be the transaction which is about to be transmitted. Earlier it was accessible by from payload.params[0], now will be available directly to event handler.
1.x
myContract
.deploy()
.send()
.on('send', payload => {
console.log(payload);
// {id: <1>, jsonrpc: '2.0', method: 'eth_sendTransaction', params: [txObject] }
});
4.x
myContract
.deploy()
.send()
.on('send', txObject => {
console.log(txObject);
// {id: <>, gas: <>,...}
});
Deploy ’confirmations’ handler will be invoked with object
In 1.x, the confirmations handler was invoked with multiple parameters. But in 4.x there will be one parameter as object but with all the same properties.
1.x
myContract .send().on(‘confirmation’, (confirmations: number, receipt: object, latestBlockHash: string) => {})`
4.x
myContract .send().on(‘confirmation’, ({confirmations: bigint, receipt: object, latestBlockHash: string}) => {})`
Strict validation for encodeABI
encodeABI now have strict validation for the ABI types. It's not limited to mentioned use cases below , but applied in general. Some use cases are:
- Earlier a
byte32ABI type was successfully encoded even providing less bytes as input. Now it will throw error. - Earlier a
byte32ABI type was successfully encoded even with an empty bytes. Now it will throw error.
Different error message for creating object without new keyword
The error message will be different if you try to create a contract object without a new keyword.
1.x
Please use the "new" keyword to instantiate a web3.eth.Contract() object!
4.x
Class constructor ContractBuilder cannot be invoked without 'new'
No warning message when toBlock passed to event subscription
In 1.x if you pass the toBlock as event options you would get a warning message.
Invalid option: toBlock. Use getPastEvents for specific range.
In 4.x you will not get any warning. But toBlock still have no effect.
The contract send method will now resolve with the receipt object
In 1.x the contract .send method was always resolved with transactionHash. That enforces user to make an extra call to get any further information. In 4.x the .send function will resolve with receipt object.
1.x
const transactionHash = await myContract.method.MyMethod().send();
4.x
const receipt = await myContract.method.MyMethod().send();
const transactionHash = receipt.transactionHash;
[4.0.1-alpha.1]
Added
- Decoding error data, using Error ABI if available, according to EIP-838. (#5434)
- The class
Web3ContractErroris moved from this package toweb3-error. (#5434)
Fixed
- According to the latest change in
web3-eth-abi, the decoded values of the large numbers, returned from function calls or events, are now available asBigInt. (#5435)
[4.0.1-alpha.2]
Added
- Decoding error data, using Error ABI if available, if error was returned from a smart contract function call (#5662).
SpecialOutputtype was added as a generic type into the call function to support reassigning output types (#5631)- Overloaded functions types (
ContractOverloadedMethodInputs,ContractOverloadedMethodOutputs) was added (#5631)
Fixed
- Emit past contract events based on
fromBlockwhen passed tocontract.events.someEventName(#5201) - Use different types for
ContractOptions->jsonInterfacesetter and getter (#5474) - An issue within the
Contractconstructor whereproviderwasn't being set when provided within theoptionsOrContextOrReturnFormatargument (#5669)
[4.0.1-alpha.3]
Changed
- Updated dependencies (#5725)
[4.0.1-alpha.4]
Changed
tsccompiled files moved tolib/directory fromdist/(#5739)
[4.0.1-alpha.5]
Changed
- web3.js dependencies (#5757)
[4.0.1-rc.0]
Fixed
- Fix contract defaults (#5756)
- Fixed getPastEventsError (#5819)
Changed
- Update imports statements for objects that was moved between web3 packages (#5771)
Added
- Added functionality of
createAccessListfor contracts ( #5780 ) - An instance of
ContractwillsubscribeToContextEventsupon instantiation ifsyncWithContextis set totrueand the constructor is passed an instance ofWeb3Context(#5833) - Added support of
safeandfinalizedblock tags (#5823)
Removed
decodeErrorDatais no longer exported (method was moved toweb3-eth-abiand renameddecodeContractErrorData) (#5844)
[4.0.1-rc.1]
Added
inputis now an acceptable property forContractInitOptionsin place ofdata(either can be used, butinputis used withing theContractclass) (#5915)- Added source files (#5956)
- Added hybrid build (ESM and CJS) of library (#5904)
Changed
getSendTxParamswill now returninputinstead ofdatain returned transaction parameters object (#5915)Contractconstructor will now thrown newContractTransactionDataAndInputErrorif bothdataandinputare passed inContractInitOptionsforContractconstructor (#5915)- The types
ContractInitOptions,NonPayableCallOptionsandPayableCallOptionsare moved toweb3-types. (#5993)
Removed
datawas removed as a property ofContractOptionstype (#5915)
[4.0.1-rc.2]
Added
- Added support for
getPastEventsmethod to filterallEventsand specific event (#6010) - Added
maxPriorityFeePerGasandmaxFeePerGasinContractOptionstype and updated function using it in utils (#6118) - Added method's type autodetection by ABI param (#6137)
[4.0.1]
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
[4.0.2]
Fixed
- Event filtering using non-indexed and indexed string event arguments (#6167)
[4.0.3]
Changed
- Dependencies updated
[4.0.4]
Changed
- Dependencies updated
[4.0.5]
Fixed
- Fixed bug in
contract.events.allEvents
Added
- In case of error events there will be inner error also available for details
[4.1.0]
Added
- Added
dataInputFillas a ContractInitOption, allowing users to have the choice using propertydata,inputorbothfor contract methods to be sent to the RPC provider. (#6355) - Added to
Web3ConfigpropertycontractDataInputFillallowing users to have the choice using propertydata,inputorbothfor contract methods to be sent to the RPC provider when creating contracts. (#6377)
[4.1.1]
Changed
- The
eventsproperty was added to thereceiptobject (#6410)
[4.1.2]
Changed
- Dependencies updated
[4.1.3]
Fixed
- Will populate
datafor transactions in contract for metamask provider instead ofinput(#6534)
[4.1.4]
Changed
- By default, contracts will fill
datainstead ofinputwithin method calls (#6622)
[4.2.0]
Changed
- Allow the
deployfunction to accept parameters, even when no ABI was provided to theContract(#6635)
Fixed
- Fix and error that happen when trying to get past events by calling
contract.getPastEventsorcontract.events.allEvents(), if there is no matching events. (#6647) - Fixed: The Contract is not using the context wallet passed if context was passed at constructor. (#6661)
[4.3.0]
Added
- Types
ContractDeploySend,ContractMethodSend,Web3PromiEventwas exported (#6883)
[4.4.0]
Fixed
- Fix an issue with smart contract function overloading (#6922)
Added
- Added a console warning in case of an ambiguous call to a solidity method with parameter overloading (#6942)
- Added contract.deploy(...).decodeData(...) and contract.decodeMethodData(...) that decode data based on the ABI (#6950)
[4.5.0]
Added
defaultReturnFormatwas added to all methods that haveReturnTypeparam. (#6947)
[4.6.0]
Added
populateTransactionwas added to contract methods (#7124)- Contract has
setTransactionMiddlewareandgetTransactionMiddlewarefor automatically passing tosentTransactionfordeployandsendfunctions (#7138)
[4.7.0]
Added
- Added
populateTransactionto thecontract.deploy(...)properties. (#7197)
Changed
- The returnred properties of
contract.deploy(...)are structured with a newly created class namedDeployerMethodClass. (#7197) - Add a missed accepted type for the
abiparameter, atdataInputEncodeMethodHelperandgetSendTxParams. (#7197)
[4.7.1]
Fixed
- Fix Contract methods input param type any[] (#7340)
[4.7.2]
Added
- Updated Typescript version 4 -> 5 (#7272)