Forge Safe lets Forge users build Gnosis Safe batch transactions using Forge scripting in Solidity. Forge Safe builds a collection of encoded transactions, then sends them to the Gnosis Safe Transaction Service uses surl.
The goal of this tool is to allow users to quickly build, validate and version control complex Safe batches as code.
Inspired by ape-safe and Olymsig
Only supports Mainnet, Sepolia, Arbitrum and Avalanche C-Chain currently. If you'd like more to be supported, please make a PR.
The only chains supported by Gnosis Safe API can be found here.
forge install ind-igo/forge-safe
Steps:
- In your .env file
- Set
CHAINto the name of the chain your Safe is on - Set
WALLET_TYPEwithLOCALorLEDGERdepending on your wallet - Set either
- a.
PRIVATE_KEY(unsafe) or - b.
SIGNER_ACCOUNT_NAME+SENDER_ADDRESS
- a.
- Set
- Import
BatchScript.solinto your Forge script - add isBatch({SAFE_ADDRESS}) modifier to
function run() - Call
addToBatch()for each encoded call - After all encoded txs have been added, call
executeBatch()with your Safe address and whether to send the transaction - Sign the batch data
import {BatchScript} from "forge-safe/BatchScript.sol";
...
contract TestScript is BatchScript {
...
function run(bool send_) public isBatch(safe) {
string memory gm = "gm";
address greeter = 0x1111;
bytes memory txn = abi.encodeWithSelector(
Greeter.greet.selector,
gm
);
addToBatch(greeter, 0, txn);
executeBatch(send_);
}