V1 to V2 migration guide
Last updated
Last updated
Web3 Functions V2 have been released, including new features and security enhancements. Here is a breakdown of what is new:
This migration guide explains the necessary steps for upgrading existing Web3 functions to the new V2 version. The Web3 functions hardhat template can also be consulted for reference. The guide consists of four sections:
upgrading dependencies
organizing Web3 Function projects
upgrading schema
code changes
Upgrade @gelatonetwork/web3-functions-sdk
package to the latest version by running the following command:
Organize your web3 functions into their own folders.
Move Web3 Function specific secrets to its own .env
file. Remove SECRET_
prefixes from secret names, it's no longer needed.
User arguments can be specified in the userArgs.json
file. Those arguments are only passed during testing of the Web3 Function, actual arguments will still be requested during task creation.
Each Web3 Function should have its own userArgs.json
, schema.json
and .env
files within its own folder. The file structure should look something like this:
Upgrade your web3 function's schema version, web3FunctionVersion
to 2.0.0
:
The new version of the Web3 Function allows for invoking multiple contracts with different payloads in a single execution. The callData
returned by the Web3 Function must be updated to specify a list of target contracts with their related call data:
Web3 Function context now provides a multi-chain provider, thus update the provider
in Web3 Function with multiChainProvider
. The provider for the network on which the task is created can be accessed using multiChainProvider.default()
.
gelatoArgs.blockTime
is not available anymore, if it was used previously block time can be fetched with the following: