Deploy to a Live Testnet
Take your AMM from local to live. You will need testnet ETH for gas, so we will grab some first.
1. Get a Wallet
If you do not have one, install MetaMask and create a new wallet. Save your seed phrase somewhere safe.
Copy your wallet address from MetaMask. You will need it for the next step.
2. Pick a Network
Choose one of the three supported testnets:
- Ethereum Sepolia, the original Ethereum testnet.
- Base Sepolia, Coinbase's L2 testnet.
- Arbitrum Sepolia, Arbitrum's L2 testnet.
3. Add the Network to Your Wallet via Chainlist
The easiest way to add a network is through chainlist.org.
- Open chainlist.org in your browser.
- Make sure your MetaMask wallet is unlocked and visible in the browser toolbar.
- In the search box on Chainlist, type the name of your chosen network (e.g.,
Sepolia). - Find the correct result and click the Connect Wallet button.
- MetaMask will pop up asking for permission. Click Connect.
- Click the Add to MetaMask button next to the network.
- MetaMask will ask you to approve the new network. Click Approve, then click Switch Network.
You should now see your chosen testnet selected in the MetaMask dropdown at the top of the extension.
Manual Fallback (if Chainlist fails)
If the automatic method does not work, add the network manually in MetaMask:
- Open MetaMask and click the network dropdown at the top.
- Click Add network, then Add a network manually.
- Fill in the details for your chosen network from the table below.
- Click Save.
| Network | RPC URL | Chain ID | Currency |
|---|---|---|---|
| Ethereum Sepolia | https://rpc.sepolia.org | 11155111 | ETH |
| Base Sepolia | https://sepolia.base.org | 84532 | ETH |
| Arbitrum Sepolia | https://sepolia-rollup.arbitrum.io/rpc | 421614 | ETH |
4. Get Testnet ETH
You need a small amount of testnet ETH to pay for gas. Reply to this post on X to receive some:
https://x.com/Trx_Tra/status/2056771557675225415?s=20
Use this exact format so the faucet bot can send you tokens:
[Network_name]-[EVM-address]Examples:
Sepolia-0x1234567890abcdef1234567890abcdef12345678
Base_Sepolia-0x1234567890abcdef1234567890abcdef12345678
Arbitrum_Sepolia-0x1234567890abcdef1234567890abcdef12345678Replace Network_name with whichever testnet you picked, and paste your actual MetaMask wallet address. Wait a few minutes for the testnet ETH to arrive.
5. Deploy Your Contracts
Remix
- In the Deploy & Run Transactions plugin, change the environment to
Injected Provider. - Make sure MetaMask is on your chosen testnet.
- Deploy your two ERC20 tokens first, then deploy your AMM using their addresses.
- MetaMask will ask you to confirm each transaction. Click Confirm.
- Copy your AMM contract address from the Deployed Contracts list.
Foundry
Create script/Deploy.s.sol:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;
import "forge-std/Script.sol";
import "../src/MyToken.sol";
import "../src/SimpleAMM.sol";
contract DeployScript is Script {
function run() external {
uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY");
vm.startBroadcast(deployerPrivateKey);
MyToken tokenA = new MyToken("Token A", "TKA", 10000);
MyToken tokenB = new MyToken("Token B", "TKB", 10000);
SimpleAMM amm = new SimpleAMM(address(tokenA), address(tokenB));
vm.stopBroadcast();
}
}Export your private key from MetaMask (Account details, Show private keys) and run:
PRIVATE_KEY=0x... forge script script/Deploy.s.sol --rpc-url <RPC_URL> --broadcastReplace <RPC_URL> with the RPC from the table above. After the script finishes, copy your AMM contract address from the terminal output.
6. Verify on Block Explorer
Paste your AMM address into the explorer for your network to confirm it is live: