Introducing Gas Abstraction for Developers, Foundry edition
Gas is a burden for onboarding companies into Web3
To deploy smart contracts, developers usually need gas in your account in form of ETH or the native currency of the specific blockchain you want to deploy.
Obtaining gas or native currencies involves to buy cryptocurrencies from exchanges like Coinbase or other on-ramps, blocker for some companies that does not want to deal holding cryptocurrencies due their add volatility to company balance sheets and the accountability burden that it generates.
There is some alternatives like EIP-4337 to pay in ERC20 tokens, but the adoption of the EIP for developer tooling is minimal due it requires code changes in your deployment scripts and is more intended for consumer apps.
What if developers just want to build?
Enter Gas Abstraction for Developers
Catapulta developed a solution to offer gas-less deployments for developers and companies that just want to focus on code, while being vendor free, compatible with all deployment scripts and developers can keep using the same deployer address, no matter if is an EOA, Ledger or a Amazon KMS account.
Now you can deploy smart contracts with EUR, USD, or stablecoins, and be able to deploy in more than +20 EVM networks without worrying about gas, ETH or native tokens of each chain.
Catapulta supports Foundry scripts
Foundry is a very robust and beloved tool by the Solidity developers community, due to its blazing fast Rust EVM runtime, allowing to develop, test, debug and deploy smart contracts using only Solidity.
Catapulta supports Foundry Solidity scripts, a way to orchestrate Solidity deployments using the same language, along with cheatcodes like vm.startBroadcast()
and vm.envUint("PRIVATE_KEY")
.
Deploy smart contracts gas-less with Foundry scripting and Catapulta CLI
For this tutorial, we will deploy a series of smart contracts, using Catapulta Foundry template repository as a reference to deploy smart contracts in the Sepolia EVM network, an Ethereum testnet.
Foundry allows you to deploy smart contracts with Solidity Scripts, let's check the scripts/Deploy.s.sol
file details:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import {Script} from "forge-std/Script.sol";
import {BatteringRam} from "../src/BatteringRam.sol";
import {Catapult} from "../src/Catapult.sol";
import {Trebuchet} from "../src/Trebuchet.sol";
contract DeploySiege is Script {
function run() public {
uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY");
vm.startBroadcast(deployerPrivateKey);
new BatteringRam(50);
new Catapult(100);
new Trebuchet(200);
vm.stopBroadcast();
}
}
We see the script will load a PRIVATE_KEY
from the environment variable, and broadcast with vm.startBroadcast
the following deployments: BatteringRam
, Catapult
and Trebuchet
smart contracts.
As a note, BatteringRam
is a factory contract that perform nested deployments of Champion
contracts during the constructor.
Let's deploy this Solidity Script with the following step by step guide:
- Install Catapulta CLI with Node.js or Bun
npm i -g catapulta
- Git clone demo repository and enter the repository directory:
git clone https://github.com/catapulta-sh/catapulta-foundry-template
cd catapulta-foundry-template
- Install forge dependencies and libraries.
forge install
- Generate a new private key with Catapulta CLI, that will be stored in your
.env
file, or add your own asPRIVATE_KEY
in the.env
file stored at the root of the project
catapulta wallet
# Output:
# Wallet address: 0x6B193d5604e09f1737E33cFc4B06fb3f2C7fC3CE
# Private key appended to your .env file.
- Sign up at Catapulta, follow the quick setup to create a project and generate a free
CATAPULTA_API_KEY
that must be stored in your.env
file. - Deploy with Catapulta CLI to the Sepolia network, using the
--sponsor
flag for gas-less deployment.
catapulta script scripts/Deploy.s.sol --network sepolia --sponsor
# Output:
Catapulta.sh 🏏 Forge script deployment (0.4.1)
================================================
Project name: Ghost Deployments
Project URL: https://catapulta.sh/project/6106272a59b37a3a4a7afb55
Deployment UUID: 592a91ad-57c8-42c6-b371-2af0e170f31a
📀 Building artifacts...
🗜 Compressing artifacts...
📤 Uploading artifacts to the Catapulta DB...
✅ Artifacts uploaded successfully.
📡 Broadcasting deployments to Catapulta Gateway RPC:
📜 Running Foundry script: forge script scripts/DeployBasic.sol --rpc-url "https://catapulta.sh/api/run/add/chain/11125111/5922a91ad2-57228242c6-b37e-2af0e170f31a/gNd4vq8ApnRWhxwPJiMS" --broadcast --chain-id 11155111
[...]
==========================
ONCHAIN EXECUTION COMPLETE & SUCCESSFUL.
Total Paid: 0.000852774003979612 ETH (284258 gas * avg 3.000000014 gwei)
✅ Deployment successfully broadcasted
- Etherscan verification request sent. Check the dashboard for keeping track of verifications. If contracts are not verified in 10 minutes, contact support at Discord.
💾 Artifacts stored at:
- https://users-artifacts.s3.eu-west-1.amazonaws.com/51195a911d-57c8-42c6-b37e-2af0e170f31a-deployment-artifacts/artifacts.zip
📸 Check your deployment report at:
- https://catapulta.sh/project/6416272a5119b37a3a4a7afbd5/op/595f91ad-57c8-4112c6-b37e-2af0e170f31a
- Done! Your deployment have been broadcasted, without initially having gas or going to a faucet. Do a click on the Deployment Report URL to see all your smart contracts deployed in the Catapulta Dashboard.
Where are the RPC configs or Etherscan API keys stored?
Catapulta takes care of resolving the network name and routing your deployment script transactions into different RPC providers.
The Catapulta RPC Relay also detects if your transaction contains CREATE
or CREATE2
instructions, and automatically sends verification requests to Etherscan or the network block explorer REST API, to simplify and automate smart contracts verification in complex nested deployments.
Conclusion
Catapulta CLI allows you to deploy, verify, smart contracts using Foundry to +20 networks without gas, RPC configurations or Etherscan API keys, and automatically generate deployment reports, resulting in a better deployment experience with less boilerplate code.
Sign up with Catapulta today for free and enjoy a better Solidity development experience, with zero-config deployments, automated verifications in block explorers and deployment reports which you can share within your team, clients or users.
Can't wait to see what you build with Catapulta!