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.
Hedera pool IDs like /pool/0.0.3964804 must be converted to a 20-byte EVM address before using them in Solidity/Forge.
$ ./scripts/hedera_pool_to_evm.sh /pool/0.0.3964804
hedera_id=0.0.3964804
evm_address=0x00000000000000000000000000000000003c7f84For live contract-to-contract flows on Hedera mainnet, use the contract's canonical evm_address from mirror-node:
$ curl -s "https://mainnet-public.mirrornode.hedera.com/api/v1/contracts/0.0.3964804" | jq -r '.evm_address'
0xc5b707348da504e9be1bd4e21525459830e7b11dHedera tests are configured to fork from the hedera RPC alias in foundry.toml.
$ forge test --match-path 'test/Hedera*.t.sol' -vvPass the converted EVM pool address into your deploy script:
$ forge script script/DeployHypervisor.s.sol:DeployHypervisor \
--rpc-url https://mainnet.hashio.io/api \
--private-key $MAINNET_PRIVATE_KEY \
--broadcast \
--sig "run(address,address,string,string)" \
0xc5b707348da504e9be1bd4e21525459830e7b11d \
<HYPE_REGISTRY_ADDRESS> \
"USDC-WHBAR Hypervisor" \
"ssUSDC-WHBAR"- Signer:
0xe911f518449ba0011D84b047B4cde50dAA081eC1 - Owner target:
0xc3Fd6DD55db9fee2c09851b51C5018a61fc84EE3 ClearingV3:0x71aD86ec15e31C535201B308b65213b70eF0bD76UniProxyETH:0x62B249AdD835b6f224c8bfE52cd00aD981974BfDAdmin:0x86275d1c85ff342C36caf33A666c78A67e2b7991HypeRegistry:0xBA77963d31d6683d1e0acB0C3F2B3f8cF80B66E7RebalanceProxy:0xFe4Cd7f5A7E0DaBFCC04dc424C9C3e849F8DC0a5
script/HederaLiveIntegration.s.sol executes:
- Deploy infra (
ClearingV3,UniProxyETH,Admin,HypeRegistry,RebalanceProxy) - Deploy
Hypervisoragainst Hedera pool0.0.3964804(or env override) - Verify
token0andtoken1 - Initial direct deposit + owner rebalance
- Proxy deposit via
UniProxyETH - Rebalance via
RebalanceProxy -> Admin -> Hypervisor
Read-only pool verification:
$ forge script script/HederaLiveIntegration.s.sol:HederaLiveIntegration \
--sig "runReadOnly()" \
--rpc-url https://mainnet.hashio.io/api -vvvFull live flow:
$ forge script script/HederaLiveIntegration.s.sol:HederaLiveIntegration \
--rpc-url https://mainnet.hashio.io/api -vvvNote: on Hedera, HTS token approve/transferFrom paths are often not fully emulated by local script simulation. If simulation reverts on token ops, use broadcast with simulation disabled:
Broadcast live transactions:
$ forge script script/HederaLiveIntegration.s.sol:HederaLiveIntegration \
--rpc-url https://mainnet.hashio.io/api \
--skip-simulation \
--broadcast -vvvImportant env vars used by the script:
MAINNET_PRIVATE_KEY(required)HEDERA_POOL_CONTRACT_ID(default3964804)HEDERA_INITIAL_DEPOSIT0/HEDERA_INITIAL_DEPOSIT1HEDERA_PROXY_DEPOSIT0/HEDERA_PROXY_DEPOSIT1HEDERA_MAX_SLIPPAGE_BPS(default500)HEDERA_LIMIT_WIDTH_MULTIPLIER(default20)HEDERA_MINT_FEE_FUND_MULTIPLIER(default6)HEDERA_STRICT_TOKEN_CHECK(defaulttrue)HEDERA_HYPE_NAME/HEDERA_HYPE_SYMBOL
$ 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