⏩Migration Guide ethers.js v5 to v6
How to migrate your code to ethers.js v6
With the @gelatonetwork/relay-sdk
version 5, the package uses ethers.js
v6
. In this guide, we will review the main changes related to the usage of the relay-sdk
.
For a comprehensive list of changes when migrating from ethers.js
v5
to ethers.js
v6
, please consult the official documentation.
Creating the calldata: populateTransaction
method
populateTransaction
methodIn all Relay requests, we send the calldata to be forwarded to the target contract. One way of creating this calldata was by invoking the populateTransaction
method. The way this is done has changed from ethers
v5
to v6
:
ethers@v5
ethers@v6
Providers
When instantiating a provider, either on the backend or frontend, you will have to update your code. This is because the package ethers.providers
has been moved to ethers
. So the change would look like this:
ethers@v5
ethers@v6
In addition to the change mentioned above, the Web3Provider
, which was used to instantiate the frontend provider using (window.ethereum)
, is now called BrowserProvider
. So, you'll need to make the following update:
ethers@v5
ethers@v6
ChainId
When querying the chainId
from the provider in ethers.js
v5
, the result was returned as a number. However, in v6
, the chainId
is returned as a BigInt
. If you have code that relies on the chainId
being a number, you'll need to update it to handle a BigInt
instead.
Here's a simple example that may help you understand how to adapt your code: ethers@v5
ethers@v6
Examples
Please visit our examples GitHub repository, which showcases the usage of the new @gelatonetwork/relay-sdk
v5 implementation for both frontend and backend.
Last updated