This repository contains the smart contracts for the Gelato Smart Wallet.
Before you begin, ensure you have the following installed:
If you want to deploy contracts, you also need to have a SPONSOR_API_KEY which you can get here.
Alternatively, you can deploy contracts manually. For this you will need:
- An EOA with sufficient funds for deployment on the target network
- Access to an RPC endpoint for your target network
Periphery contracts in this repository rely on several external contracts which are added as submodules in this repo.
To install submodules:
chmod +x install-submodules.sh
./install-submodules.shTo install packages:
pnpm install- Create a
.envfile in the root directory:
cp .env.example .env- Configure your environment variables in
.env:
SPONSOR_API_KEY="" # https://app.gelato.network/relay
TARGET_ENV="" # either 'testnet' or 'mainnet'
ETHERSCAN_API_KEY=""- Load the environment variables:
source .envAdd your target chain to the deploy/chains.ts configuration:
- Open
deploy/chains.ts - Locate the
testnetsormainnetssection - Add your chain object following the existing format
The chain object can be imported from viem/chains. If the chain is not exported by viem you can add it manually. An example of this is thriveTestnet and abcTestnet.
Run the deployment script:
pnpm run deploy- Create a
.envfile in the root directory:
cp .env.example .env- Configure your environment variables in
.env:
# Required for deployment
PRIVATE_KEY=""
RPC_URL=""
ETHERSCAN_API_KEY=""- Load the environment variables:
source .envRun the deployment script using Forge:
Delegation:
forge script ./script/DeployDelegation.s.sol \
--rpc-url $RPC_URL \
--broadcastSessionValidator:
forge script ./script/DeploySessionValidator.s.sol \
--rpc-url $RPC_URL \
--broadcastAfter deployment, verify your contract on the network's block explorer:
Delegation:
forge verify-contract <DEPLOYED_ADDRESS> \
./src/Delegation.sol:Delegation \
--chain-id <CHAIN_ID> \
--verifier <etherscan|blockscout> \
--verifier-url <VERIFIER_URL> \
--etherscan-api-key $ETHERSCAN_API_KEYSessionValidator:
forge verify-contract <DEPLOYED_ADDRESS> \
./src/validators/Session.sol:SessionValidator \
--chain-id <CHAIN_ID> \
--verifier <etherscan|blockscout> \
--verifier-url <VERIFIER_URL> \
--etherscan-api-key $ETHERSCAN_API_KEYFor questions or issues, please open an issue in this repository or contact the Gelato team.