For the complete documentation index, see llms.txt. This page is also available as Markdown.

Build a dual-lane app

A step-by-step walkthrough of a dual-lane app — one Solidity contract used by both a MetaMask user and a Solana wallet user, with exactly what happens at each step.

A dual-lane app is one Solidity contract that both a MetaMask (EVM) user and a Solana wallet user use directly — same contract, same state, each with the wallet they already have. This page walks through exactly what happens at each step, on each side.

The example is a tiny vault: you deposit USDC and later withdraw it. "Stake / unstake", "supply / redeem", "tip / claim" are the same shape.

What you write — a standard ERC-20 vault

On Rome, a Solana user's USDC appears on the EVM side as an ordinary ERC-20 token — the SPL wrapper for that mint (e.g. wUSDC). So your contract is a normal token vault: it pulls tokens with transferFrom and returns them with transfer. Nothing Rome-specific:

interface IERC20 {
    function transfer(address to, uint256 amount) external returns (bool);
    function transferFrom(address from, address to, uint256 amount) external returns (bool);
}

contract Vault {
    IERC20 public immutable token;                 // the wUSDC wrapper
    mapping(address => uint256) public balanceOf;
    constructor(IERC20 _token) { token = _token; }

    function deposit(uint256 amount) external {
        require(token.transferFrom(msg.sender, address(this), amount));
        balanceOf[msg.sender] += amount;
    }
    function withdraw(uint256 amount) external {
        balanceOf[msg.sender] -= amount;
        require(token.transfer(msg.sender, amount));
    }
}

Why ERC-20, not payable / msg.value? A Solana user's spendable balance is their wallet's SPL token account, surfaced 1:1 as this ERC-20 wrapper — not the EVM native balance. So a Solana user can always fund a transferFrom, but a deposit() payable would need native value they don't hold at rest. Build around the token and both lanes work the same way.

Deploy it with Foundry or Hardhat, pointing the constructor at the wrapper address for your token (from the registry). On Rome the gas token is USDC, so you need a little USDC gas balance to deploy.

The two lanes

Lane
Wallet
How the app calls it

EVM

MetaMask (an EVM key)

submitRomeTx — the standard Rome write

Solana

a Solana wallet such as Solflare (a Solana key)

submitRomeTxV1 — one Solana v1 transaction per call, no EVM key needed

The EVM lane is ordinary. The rest of this page is the Solana lane — the interesting half.

The key idea: the synthetic is a pass-through

A Solana user's EVM identity is their synthetic address — keccak256(solana_pubkey)[12:]. It's their msg.sender in the contract, but it holds nothing at rest. The user's money lives in their Solana wallet (as SPL USDC), and on the EVM side that same balance is what wUSDC.balanceOf(synthetic) reads. Value flows through the synthetic:

  • In (deposit): wallet token account → synthetic token account → contract (via transferFrom).

  • Out (withdraw): contract → synthetic token account → wallet token account.

The synthetic nets back to nothing after each round-trip.

One-time: Activate (provision the synthetic)

A brand-new synthetic's on-chain account doesn't exist until you create it. The first time a Solana user acts, their synthetic is provisioned with a create_pda call — after that, value-moving calls (the ERC-20 transferFrom, the sweep) can be signed by it.

submitRomeTxV1 does not do this for you, so provision explicitly, once, before the first value-moving call. A good place is an "Activate" step, or just before the first approve:

One-time: grant the wrapper

The wUSDC wrapper moves a user's tokens as the SPL delegate of their token account, so each user has to grant it that right once per wrapper, before the first deposit. This applies to a MetaMask user and to a Solana user's synthetic address alike. Without the grant, every transferFrom out of the wallet fails and the deposit reverts with SPL error 0x4 (owner mismatch).

Check with the wrapper's view isEnabled(user). If it returns false, send approve_spl(wrapper, 2^64-1, mint) straight to the Helper precompile at 0xff00000000000000000000000000000000000009; the mint is mint_id() on the wrapper. On the EVM lane that is a submitRomeTx call, on the Solana lane a submitRomeTxV1 call:

What each side needs

Needs
Why

Solana user

SOL (a little)

pays the Solana transaction fee on each lane tx

USDC as an SPL token in their wallet

the value they deposit (seen on the EVM side as wUSDC)

EVM user (MetaMask)

USDC as their Rome gas balance

gas, and the value they deposit once it is wrapped; they top it up by bridging USDC into Rome (there is no faucet)

a wrap of some of that gas into wUSDC (withdraw_to_ata)

the vault takes wUSDC, the ERC-20 wrapper, not native gas. A MetaMask balance of gas USDC is not wUSDC until it is wrapped

the one-time wrapper grant (approve_spl)

lets the wUSDC wrapper move their tokens; see One-time: grant the wrapper

You (the builder)

a wallet with USDC gas on Rome

to deploy the contract

Value IN — deposit (step by step)

The Solana user has SOL + USDC in their Solana wallet. Every step is a Solana v1 transaction, signed by that wallet, and the app sends it to the Solana RPC. The fund leg is built in the app and the wallet signs it with one prompt; each contract call is composed by the proxy, and the wallet signs it after a readable authorization message:

  1. Fund leg — buildFundLeg(...) → submitSolanaInstructionsV1(...). Creates the synthetic's USDC token account (if needed) and runs ActivateAta, moving amount of USDC from the wallet's token account into the synthetic's. Now wUSDC.balanceOf(synthetic) shows that balance.

  2. Grant the wrapper (when isEnabled is false) — submitRomeTxV1(deps, { to: HELPER, data: approve_spl(wUSDC, 2^64-1, mint) }). See One-time: grant the wrapper. (Provision the synthetic before this if it is the user's first lane call.)

  3. Approve — submitRomeTxV1(deps, { to: wUSDC, data: approve(vault, amount) }). Lets the vault pull the tokens.

  4. Deposit — submitRomeTxV1(deps, { to: vault, data: deposit(amount) }). The vault runs transferFrom(synthetic, vault, amount) — the USDC moves from the synthetic into the vault, credited to the synthetic's address.

Net effect: USDC went Solana wallet → (synthetic) → the vault.

Value OUT — withdraw (step by step)

Now the user withdraws. Also wallet-signed, two prompts per call:

  1. Withdraw — submitRomeTxV1(deps, { to: vault, data: withdraw(amount) }). vault.withdraw runs transfer(synthetic, amount) — USDC moves from the vault back into the synthetic's token account.

  2. Sweep leg — buildSweepLeg(...) gives you the HelperProgram.transfer_spl call + accounts; run it (create the wallet's token account if needed with submitSolanaInstructionsV1, then send the Helper call through submitRomeTxV1; the proxy finds the token accounts) to move the USDC from the synthetic back to the user's own Solana wallet. The synthetic nets to nothing.

Net effect: USDC went the vault → (synthetic) → the user's Solana wallet. Nothing is stranded.

Measured on Hadrian

Each Solana-lane step below ran as one version-1 transaction on Hadrian:

Step
Compute units
Bytes
Accounts

Provision (create_pda)

39,008

703

9

Wrapper grant (approve_spl)

50,687

899

13

Approve

79,335

769

10

Vault deposit

242,880

1,070

20

Vault withdraw

280,903

1,037

19

Sweep (transfer_spl)

46,810

899

13

The gotchas

These are the things a hand-built Solana-lane transaction gets wrong. The SDK and the proxy's composer handle most of them:

  • Provisioning. A fresh synthetic's account must be created (create_pda) before any value-moving call, or it can't sign the transfer. submitRomeTxV1 does not do it for you: check isSyntheticProvisioned and submit buildCreatePdaCall(synthetic) once.

  • Grant the wrapper once. The wrapper moves tokens as the user's SPL delegate. Check isEnabled and send approve_spl to the Helper precompile before the first deposit, or the deposit reverts with SPL error 0x4.

  • Spend the wrapper, not msg.value. A Solana user's balance is their SPL token account, surfaced as the ERC-20 wrapper — move it with transfer / transferFrom, never native value.

  • Composed for you. ComputeBudget, the treasure wallet and account discovery are done by the proxy's composer, so none of them appear in your code. Before the wallet signs, the SDK checks the composed transaction and refuses anything but the call the user authorized.

  • Where it's sent. The wallet signs the v1 transaction and the app sends it to the Solana RPC — not to the proxy, which composes it (a relayed call is the one exception, below; see Relayed calls and long calls). On-chain, the program derives msg.sender from the Solana signer.

  • Two prompts per call. The wallet signs a readable authorization message (Rome authorization and the EVM transaction hash), then the transaction, both with the same key.

  • Check your wallet signs v1. signV1Wire must return the 64-byte signature over the v1 message; through Wallet Standard that is solana:signTransaction on the raw wire and signedTransaction.slice(-64). Not every wallet decodes v1 transactions yet, so test yours before you build on it. On devnet today, Solflare signs them; Phantom does not yet.

  • Big calls relay. A call that does not fit one transaction is relayed by the proxy with the same authorization signature, and the result has route: "relay". A relayed call is paid in the chain's native gas, so top up the synthetic with fundSyntheticGas(deps, amountWei). See Relayed calls and long calls.

  • Gas is USDC. No faucet — bridge USDC in (see Getting funded).

The earlier submitRomeTxSolanaLane is still in the SDK: it builds a legacy Solana transaction in the client (one wallet prompt, with ComputeBudget and the treasure wallet handled by the SDK).

The same app from MetaMask

An EVM user calls the identical contract with submitRomeTx — standard EVM tooling, gas in USDC. One difference from the Solana user: a MetaMask user holds native gas USDC, not wUSDC. The vault takes the wUSDC wrapper, so the user wraps some of their gas first, then grants the wrapper once, then does the ERC-20 steps as usual. There are no fund or sweep legs, because the wrapped tokens already live at their EVM address.

  1. Wrap gas into wUSDC — send withdraw_to_ata(wei) to the Withdraw precompile at 0x4200000000000000000000000000000000000016. It burns that much native gas and credits the equivalent amount to the user's token account in the gas token, which wUSDC.balanceOf(user) then shows. wei is in the 18-decimal gas unit and must be a multiple of 10^12 (one 6-decimal wUSDC unit), or the call reverts. Skip this step if the user already holds wUSDC.

  2. Grant the wrapper (when isEnabled is false) — the same approve_spl call as above, sent with submitRomeTx. See One-time: grant the wrapper.

  3. Approve — approve(vault, amount) on wUSDC.

  4. Deposit — deposit(amount) on the vault. Withdraw is withdraw(amount).

Both users share the same balanceOf state in the vault.

What's next

Last updated

Was this helpful?