Arbitrum Stylus Target
Formagine compiles Forms to Arbitrum Stylus ABI-compatible WASM, producing contracts that run on Ethereum's most active L2 with full bidirectional EVM interop. Stylus executes WASM alongside the EVM on Arbitrum's optimistic rollup — WASM contracts can call Solidity contracts and vice versa, composing with the entire Arbitrum DeFi ecosystem. The Stylus runtime charges ink (converted to Arbitrum gas at a ~100x discount versus EVM opcodes), making WASM computation significantly cheaper than equivalent Solidity. Formagine compounds this advantage: proven invariants are erased at compile time, and the Rust-free approach produces leaner WASM with fewer instructions per transition. The result is algebraically verified contracts with Ethereum L1 security, L2 gas costs, and zero-overhead invariant guarantees — callable from ethers.js, viem, or Foundry using standard Ethereum ABI encoding.
Runtime Specifications
| WASM Runtime | Arbitrum Stylus (WASM execution alongside EVM on optimistic rollup) |
| Max Binary Size | Governed by Arbitrum contract size limits (comparable to EVM contract limits) |
| Gas Model | Ink (internal) converting to Arbitrum gas — ~100x cheaper computation than EVM opcodes |
| Entry Points | Single entrypoint with 4-byte function selector dispatch (Ethereum ABI compatible) |
| Message Format | Ethereum ABI encoding (same as Solidity contracts) |
| State Backend | Stylus storage slots (same underlying state trie as EVM contracts) |
| EVM Interop | Full bidirectional — WASM calls EVM, EVM calls WASM |
| Security | Ethereum L1 via Arbitrum optimistic rollup with fraud proofs |
How Formagine Targets Stylus
Stylus uses Ethereum ABI encoding — the same format Solidity compilers produce. Formagine generates a WASM binary with a single entrypoint that receives a 4-byte function selector followed by ABI-encoded calldata. The compiler builds a dispatch table mapping selectors to transition handlers, exactly mirroring Solidity's function dispatch mechanism.
State fields map to Stylus storage slots. Scalar fields occupy single slots, and per mappings use the same keccak256-based slot derivation that Solidity uses for mappings. This means Formagine contract state is accessible and verifiable using standard Ethereum tools (Etherscan, block explorers, ethers.js getStorageAt).
Because Formagine contracts use Ethereum ABI encoding, they are callable from any Ethereum tooling — ethers.js, viem, wagmi, Foundry cast, Hardhat, or direct RPC calls. There is no separate SDK or client library to integrate. If your frontend can call a Solidity contract, it can call a Formagine contract.
EVM Interoperability
Stylus's defining feature is full EVM interop. Formagine contracts can:
Call EVM contracts: Interact with any deployed Solidity contract — swap on Uniswap, deposit into Aave, transfer ERC-20 tokens. The compiler generates Stylus host I/O calls that make cross-VM calls transparent.
Be called by EVM contracts: Solidity contracts see Formagine WASM contracts as regular Ethereum contracts. No special interface needed — standard CALL opcode with ABI-encoded data.
Compose with DeFi: A Formagine vault form can hold Uniswap LP positions, a governance form can control a Solidity treasury, a token form can be listed on any DEX. The entire Arbitrum ecosystem is accessible from day one.
Gas Advantage
Stylus provides a computation cost advantage over EVM through its ink system. WASM instructions are metered in ink, which converts to Arbitrum gas at a ratio that makes WASM computation ~100x cheaper than equivalent EVM opcodes. Storage operations cost the same in both VMs since they hit the same state trie.
Formagine compounds this advantage:
Invariant erasure: Verified invariants become zero-cost at runtime. A Solidity contract might spend gas on require checks and SafeMath; a Formagine contract proves these at compile time and erases them.
Lean WASM: No Rust std, no alloc, no framework overhead. Each transition compiles to minimal WASM instructions, maximizing the ink-to-gas advantage.
Combined savings: The Stylus runtime advantage (cheaper instructions) multiplied by the Formagine optimization (fewer instructions) produces significant gas savings versus equivalent Solidity contracts.
Example: Token on Stylus
form Token { state { balance : Nat per Address supply : Nat owner : Address } invariant conservation : sum(balance) == supply transition transfer(from, to, amount) { require balance[from] >= amount balance[from] -= amount balance[to] += amount } -- Selector: 0xbeabacc8 (transfer(address,address,uint256)) -- Callable via ethers.js, viem, Foundry — standard Ethereum ABI }
Frequently Asked Questions
- Can Formagine WASM contracts on Stylus interact with EVM contracts?
- Yes, full bidirectional interop. Formagine contracts can call any EVM contract (Uniswap, Aave, ERC-20 tokens, etc.) via Stylus host I/O. EVM contracts call Formagine contracts using standard Ethereum CALL with ABI-encoded data. The entire Arbitrum DeFi ecosystem is composable from day one.
- How does Stylus gas compare to EVM gas on Arbitrum?
- WASM computation on Stylus is ~100x cheaper per instruction than EVM opcodes, metered via ink that converts to Arbitrum gas. Storage costs are the same since both VMs share the state trie. Formagine compounds this advantage by erasing proven invariants and minimizing instruction counts, producing significantly cheaper transactions than equivalent Solidity contracts.
- What security guarantees does Formagine on Stylus inherit from Ethereum?
- Two layers: Formagine provides algebraic proof of invariants at compile time (logical correctness). Arbitrum provides Ethereum L1 security via optimistic rollup with fraud proofs (settlement finality). All state transitions are posted to L1 and challengeable during the dispute window. The combination gives both provable correctness and economic security.
- How does Formagine generate Stylus ABI-compatible WASM?
- Formagine emits WASM with a single entrypoint that dispatches on 4-byte function selectors using Ethereum ABI encoding — the same format Solidity uses. State maps to storage slots using keccak256-based derivation. The result is callable from ethers.js, viem, Foundry, or any Ethereum-compatible tool. No special SDK required.