← notes

Bridging an ERC-20 to Base with cast and nothing else

Aug 1, 2023

Write down the handful of Base operations worth doing from the command line, where nothing is hidden.

Two recipes: bridging an ERC-20 from mainnet using cast, and downloading a full chain snapshot.

The bridge one is the keeper. Doing it without a front end means approving the bridge contract and then calling depositERC20To yourself, with every argument visible, the L1 token, the L2 token, the recipient, the amount, the minimum gas limit for the L2 side, the extra data. Front ends fill all of that in, which is why people bridge for years without knowing the L1 and L2 token addresses are separate arguments, or that a deposit is a message executed on the other side rather than a transfer.

Which is where the useful failure lives. Name an L2 token that is not a legitimate counterpart and the deposit is accepted on L1 with nothing correct to do on L2. That is exactly what the Optimism token list exists to prevent and why base-bridge-validator checks what it checks.

The snapshot recipe raises the size question that base-chain-data later answered.