Skip to content

spaceharpoon/orbitals-contracts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Orbitals Contracts

Smart contracts for the Orbitals protocol.

Handler Contract

The Handler contract is a secure transaction executor that allows users to batch multiple contract calls while automatically collecting fees.

How It Works

  1. Token Transfer: Users approve tokens to the Handler contract
  2. Call Execution: Handler executes the provided calls using the attemptCalls function
  3. Fee Collection: On successful execution, 0.5% fee is sent to the fee collector
  4. Fallback Handling: If calls fail and a fallback recipient is provided, remaining tokens are sent there

Usage

// 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));

Deployment

Setup Environment Variables

  1. Copy the example environment file:
cp .env.example .env
  1. Edit .env with 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 Commands

# 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_KEY

Events

  • FeeCollected(address indexed token, uint256 amount, address indexed feeCollector)
  • CallsFailed(Call[] calls, address indexed fallbackRecipient)
  • DrainedTokens(address indexed recipient, address indexed token, uint256 indexed amount)

NFT Contract

Deploy Commands

# 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_KEY

Checking Deployment Estimates

forge script script/DeployOrbitalsNFT.s.sol:DeployOrbitalsNFTScript --rpc-url $ETHEREUM_RPC_ENDPOINT

Foundry Toolkit

Foundry 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.

Documentation

https://book.getfoundry.sh/

Usage

Build

$ forge build

Test

$ forge test

Format

$ forge fmt

Gas Snapshots

$ forge snapshot

Anvil

$ anvil

Deploy

$ forge script script/Counter.s.sol:CounterScript --rpc-url <your_rpc_url> --private-key <your_private_key>

Cast

$ cast <subcommand>

Help

$ forge --help
$ anvil --help
$ cast --help

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors