Token Deposit Examples

Using Foundry’s cast for ERC20 Deposits

This guide covers approving tokens on L1 and depositing them into the multi-ledger rollup using the Deposit Contract of the relevant blockchain.

📘

Assumptions: This guide assumes you have collected testnet tokens from the relevant faucets as discussed in the Rollup Testnet Tokens Page. Additionally this guide assumes you are aware of the deposit smart contract addresses as described in the Smart Contract Page.

⚠️

Warning: This guide assumes you are depositing a whitelisted ERC-20 token (otherwise the deposit transaction will be rejected). The whitelisted tokens are displayed inthe Rollup Testnet Tokens Page.


1. Install Foundry and cast

cast is part of Foundry, an Ethereum toolkit maintained by Paradigm. It provides CLI utilities for interacting with smart contracts via JSON-RPC.

Install Foundry

curl -L https://foundry.paradigm.xyz | bash
foundryup

Verify installation

cast --version

You should see output similar to: cast 0.2.0 (or higher)


2. Environment Setup

Before running the steps below, make sure you’ve exported the following environment variables:

export L1_RPC_URL=<your L1 RPC endpoint>                  
export ROLLUP_RPC_URL=https://fusion-rollup.quant.dev/rpc/<your-client-id>  
export PRIVATE_KEY=<your private key>                     # wallet performing the deposit transaction
export WALLET=<wallet address derived from PRIVATE_KEY>   # e.g., cast wallet address --private-key $PRIVATE_KEY
export L1_TOKEN=<ERC20 token contract on L1>              # e.g., 0xYourL1TokenAddress
export ROLLUP_TOKEN=<ERC20 token contract on rollup>      # e.g., 0xYourRollupTokenAddress
export L1_DEPOSIT_CONTRACT=<L1 deposit contract address>   # e.g., 0xYourL1DepositContract
export ROLLUP_CHAIN_ID=73073                              # rollup chain ID
export APPROVAL_AMOUNT=1000000000000000000                # amount to approve (1e18 = 1 token)
export DEPOSIT_AMOUNT=5200000                             # amount to deposit
export ROLLUP_GAS_LIMIT=300000																# safe limit for deposit execution

3. Approve L1 Deposit Contract

Description

Grant the L1 Deposit Contract permission to spend your L1 ERC-20 tokens.

Command

cast send $L1_TOKEN \
  "approve(address,uint256)" \
  $L1_DEPOSIT_CONTRACT \
  $APPROVAL_AMOUNT \
  --rpc-url $L1_RPC_URL \
  --private-key $PRIVATE_KEY

Verify Allowance

Confirm the approval:

cast call $L1_TOKEN \
  "allowance(address,address)(uint256)" \
  $WALLET \
  $L1_DEPOSIT_CONTRACT \
  --rpc-url $L1_RPC_URL

4. Deposit to Rollup

Description

Deposit your approved tokens from L1 into the Rollup via the L1 Deposit Contract.

Command

cast send $L1_DEPOSIT_CONTRACT \
  "depositERC20(address,address,uint256,uint32,bytes,uint256)" \
  $L1_TOKEN \
  $ROLLUP_TOKEN \
  $DEPOSIT_AMOUNT \
  $ROLLUP_GAS_LIMIT \
  0x \
  $ROLLUP_CHAIN_ID \
  --rpc-url $L1_RPC_URL \
  --private-key $PRIVATE_KEY 

5. Verification

Verify Deposit and Rollup Balance

1️⃣ Verify deposit record on L1

Check a block explorer for the deposit transaction transferring the requested amount to the deposit contract.

2️⃣ Check your balance on the Rollup

⚠️

Warning: Your deposit will be credited on the Multi-Ledger Rollup ONLY after the L1 finalization period has completed. This finalisation period can be different depending on the specific L1 blockchain being used, but has a minimal time-frame of 3 minutes.

Sepolia's consensus requires a wait of around 20 minutes due to 2 epochs being needed for finalisation.

cast call $ROLLUP_TOKEN \
  "balanceOf(address)(uint256)" \
  $WALLET \
  --rpc-url $ROLLUP_RPC_URL

Using Foundry’s cast for QNT Deposits

This guide explains how to approve the QNT token on L1 and deposit it into the Multi-Ledger Rollup (MLR) using the L1 Deposit Contract.

⚠️

Warning: This guide assumes you are depositing the official testnet QNT token on Ethereum Sepolia.


1. Install Foundry and cast

cast is part of Foundry, an Ethereum toolkit maintained by Paradigm. It provides CLI utilities for interacting with smart contracts via JSON-RPC.

Install Foundry

curl -L https://foundry.paradigm.xyz | bash
foundryup

Verify installation

cast --version

You should see output similar to: cast 0.2.0 (or higher)


2. Environment Setup

Before continuing, make sure all required environment variables are exported:

export L1_RPC_URL=<your L1 RPC endpoint>
export ROLLUP_RPC_URL=https://fusion-rollup.quant.dev/rpc/<your-client-id>
export PRIVATE_KEY=<your private key>
export WALLET=<wallet address derived from PRIVATE_KEY>   # e.g., cast wallet address --private-key $PRIVATE_KEY

# QNT and contract configuration
export QNT_TOKEN="0x81Dc68CB065ec6D9a4d24f6e2F442dc2A236D853"
export L1_DEPOSIT_CONTRACT="0xaee1299034f8d04ba414e8ca3ef6a67203844313"  # on Sepolia

# Rollup configuration
export ROLLUP_CHAIN_ID=73073                              # Multi-Ledger Rollup chain ID
export ROLLUP_GAS_LIMIT=300000                            # safe gas limit for deposit execution

# Amounts (defaults from internal Quant script)
export APPROVAL_AMOUNT=10000000000000000000000 						# 10,000 QNT default
export DEPOSIT_AMOUNT=1500000000000000000        					# 1.5 QNT default

3. Approve L1 Deposit Contract for QNT

Description

Authorize the L1 Deposit Contract to spend your QNT tokens on your behalf.

Command

cast send $QNT_TOKEN \
  "approve(address,uint256)" \
  $L1_DEPOSIT_CONTRACT \
  $APPROVAL_AMOUNT \
  --rpc-url $L1_RPC_URL \
  --private-key $PRIVATE_KEY

Verify Allowance

ALLOWANCE=$(cast call $QNT_TOKEN \
  "allowance(address,address)(uint256)" \
  $WALLET \
  $L1_DEPOSIT_CONTRACT \
  --rpc-url $L1_RPC_URL)

echo "Allowance set to: $ALLOWANCE"
echo "Expected: >= $APPROVAL_AMOUNT"

The allowance should equal or exceed your approval amount before continuing.


4. Deposit QNT to the Multi-Ledger Rollup

Description

Deposit your approved QNT tokens from L1 into the Multi-Ledger Rollup via the L1 Deposit Contract.

Command

Send the deposit transaction:

cast send $L1_DEPOSIT_CONTRACT \
  "depositERC20(address,address,uint256,uint32,bytes,uint256)" \
  $QNT_TOKEN \
  "0x0000000000000000000000000000000000000000" \
  $DEPOSIT_AMOUNT \
  $ROLLUP_GAS_LIMIT \
  0x \
  $ROLLUP_CHAIN_ID \
  --rpc-url $L1_RPC_URL \
  --private-key $PRIVATE_KEY

5. Verification

1️⃣ Verify QNT Deposit Record on L1

Check a block explorer for the deposit transaction transferring the requested amount to the deposit contract.

2️⃣ Check QNT Token Balance on Rollup

⚠️

Warning: Your QNT deposit will be credited on the Multi-Ledger Rollup ONLY after the L1 finalization period has completed.

Sepolia's consensus requires a wait of around 20 minutes due to 2 epochs being needed for finalisation.

📘

Note: When QNT is deposited onto the rollup, it is transformed into the native token, therefore it's value can be read by through the eth_getBalance RPC.

You can confirm that your wallet has had a QNT deposit via the following:

cast rpc eth_getBalance $WALLET latest --rpc-url $ROLLUP_RPC_URL