Smart contracts for the Orbitals protocol.
The Handler contract is a secure transaction executor that allows users to batch multiple contract calls while automatically collecting fees.
- Token Transfer: Users approve tokens to the Handler contract
- Call Execution: Handler executes the provided calls using the
attemptCallsfunction - Fee Collection: On successful execution, 0.5% fee is sent to the fee collector
- Fallback Handling: If calls fail and a fallback recipient is provided, remaining tokens are sent there
// Create instructions
Handler.Call[] memory calls = new Handler.Call[](1);
calls[0] = Handler.Call({
target: targetContract,
callData: abi.encodeWithSignature("someFunction(uint256)", 42),
value: 0
});
Handler.Instructions memory instructions = Handler.Instructions({
calls: calls,
fallbackRecipient: fallbackAddress // or address(0) for no fallback
});
// Approve tokens and execute
token.approve(address(handler), amount);
handler.handle(address(token), amount, msg.sender, abi.encode(instructions));- Copy the example environment file:
cp .env.example .env- Edit
.envwith your actual values:
# Fee collector address for the Handler contract
FEE_COLLECTOR=0xYourActualFeeCollectorAddress
# RPC URLs
SEPOLIA_RPC_URL=https://sepolia.infura.io/v3/YOUR_INFURA_PROJECT_ID
MAINNET_RPC_URL=https://mainnet.infura.io/v3/YOUR_INFURA_PROJECT_ID
# Private key (without 0x prefix)
PRIVATE_KEY=your_private_key_here
# API keys for verification
ETHERSCAN_API_KEY=your_etherscan_api_key# Deploy to local network
forge script script/DeployHandler.s.sol:DeployHandlerScript --fork-url http://localhost:8545 --broadcast
# Deploy to mainnet
forge script script/DeployHandler.s.sol:DeployHandlerScript --fork-url $POLYGON_RPC_URL --private-key $PRIVATE_KEY --broadcast --verify --etherscan-api-key $POLYGONSCAN_API_KEYFeeCollected(address indexed token, uint256 amount, address indexed feeCollector)CallsFailed(Call[] calls, address indexed fallbackRecipient)DrainedTokens(address indexed recipient, address indexed token, uint256 indexed amount)
# Deploy to mainnet
forge script script/DeployOrbitalsNFT.s.sol:DeployOrbitalsNFTScript --rpc-url $POLYGON_RPC_URL --private-key $PRIVATE_KEY --broadcast --verify --etherscan-api-key $ETHERSCAN_API_KEYforge script script/DeployOrbitalsNFT.s.sol:DeployOrbitalsNFTScript --rpc-url $ETHEREUM_RPC_ENDPOINTFoundry is a blazing fast, portable and modular toolkit for Ethereum application development written in Rust.
Foundry consists of:
- Forge: Ethereum testing framework (like Truffle, Hardhat and DappTools).
- Cast: Swiss army knife for interacting with EVM smart contracts, sending transactions and getting chain data.
- Anvil: Local Ethereum node, akin to Ganache, Hardhat Network.
- Chisel: Fast, utilitarian, and verbose solidity REPL.
$ forge build$ forge test$ forge fmt$ forge snapshot$ anvil$ forge script script/Counter.s.sol:CounterScript --rpc-url <your_rpc_url> --private-key <your_private_key>$ cast <subcommand>$ forge --help
$ anvil --help
$ cast --help