Docs/Deploying

Deploying Contracts

Deploy your AutoLoop-compatible contracts to testnet and mainnet.


Overview

Deploying an AutoLoop-compatible contract involves three steps:

  1. Deploy your contract to the target network
  2. Register it with the AutoLoop Registrar
  3. Fund it with ETH to cover execution costs

Deploy to Sepolia (Testnet)

Prerequisites

  • Foundry installed
  • Sepolia ETH (faucet)
  • An RPC endpoint (Infura, Alchemy, or a public one like https://ethereum-sepolia-rpc.publicnode.com)

Write a Deploy Script

Create script/DeployMyGame.s.sol:

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;

import "forge-std/Script.sol";
import "../src/MyGame.sol";

contract DeployMyGame is Script {
    function run() external {
        vm.startBroadcast();
        MyGame game = new MyGame();
        console.log("MyGame deployed at:", address(game));
        vm.stopBroadcast();
    }
}

Deploy

forge script script/DeployMyGame.s.sol \
  --rpc-url https://ethereum-sepolia-rpc.publicnode.com \
  --private-key $DEPLOYER_KEY \
  --broadcast \
  --verify

Register with AutoLoop

After deployment, register your contract on-chain. You can do this via the dashboard or with cast:

# Sepolia Registrar
REGISTRAR=0xDA2867844F77768451c2b5f208b4f78571fd82C1

# Register and deposit 0.01 ETH in one call
cast send $REGISTRAR \
  "registerAutoLoop(address)" $YOUR_CONTRACT \
  --value 0.01ether \
  --rpc-url https://ethereum-sepolia-rpc.publicnode.com \
  --private-key $DEPLOYER_KEY

Workers will begin monitoring your contract automatically.

Check It's Working

# Check registration
REGISTRY=0xAC905aF2e40404D06317911beb03317Bd1bc5858
cast call $REGISTRY "isRegistered(address)" $YOUR_CONTRACT --rpc-url $RPC_URL

# Check balance
cast call $REGISTRY "getBalance(address)" $YOUR_CONTRACT --rpc-url $RPC_URL

# Watch for execution
cast call $YOUR_CONTRACT "shouldProgressLoop()" --rpc-url $RPC_URL

Deploy to Mainnet

Same process, different addresses and RPC:

# Mainnet Registrar
REGISTRAR=0x202d73Ac243907A6e81B5FF55E4c316567e4fF80

forge script script/DeployMyGame.s.sol \
  --rpc-url https://eth.drpc.org \
  --private-key $DEPLOYER_KEY \
  --broadcast \
  --verify

cast send $REGISTRAR \
  "registerAutoLoop(address)" $YOUR_CONTRACT \
  --value 0.05ether \
  --rpc-url https://eth.drpc.org \
  --private-key $DEPLOYER_KEY

Mainnet Checklist

Before deploying to mainnet:

  • Test thoroughly on Sepolia first
  • Verify shouldProgressLoop() returns false when it should — unnecessary ticks waste ETH
  • Set a reasonable tick interval (every tick costs gas)
  • Fund with enough ETH for your expected session length (see Economics)
  • For VRF contracts, ensure controller keys are registered

Contract Addresses

Mainnet

ContractAddress
AutoLoop0x6748415BcE63c0FBf1E50ceB2128BfeAC977224F
Registry0xC1b9241DE87108EffF5caAf0340CcEbD05A5425f
Registrar0x202d73Ac243907A6e81B5FF55E4c316567e4fF80

Sepolia

ContractAddress
AutoLoop0x311eB21A1f7C0f12Ea7995cd6c02855b1bDa2132
Registry0xAC905aF2e40404D06317911beb03317Bd1bc5858
Registrar0xDA2867844F77768451c2b5f208b4f78571fd82C1

Using the Dashboard

The easiest way to register and fund is through the dashboard:

  1. Connect your wallet (the account that deployed the contract)
  2. Click "Register Contract"
  3. Paste your contract address
  4. Deposit ETH (minimum recommended: 0.01 ETH for testing, 0.05+ ETH for production)
  5. Your contract appears in the dashboard with live status

Depositing More ETH

When your contract balance gets low, deposit more:

# Via cast
cast send $REGISTRY "deposit(address)" $YOUR_CONTRACT \
  --value 0.05ether \
  --rpc-url $RPC_URL \
  --private-key $DEPLOYER_KEY

Or use the dashboard — click your contract and hit "Deposit".

Withdrawing Funds

To withdraw your remaining balance:

cast send $REGISTRY "requestRefund(address,address)" $YOUR_CONTRACT $RECIPIENT \
  --rpc-url $RPC_URL \
  --private-key $DEPLOYER_KEY

This sends the full remaining balance to the recipient address and resets the on-chain balance to zero. Workers will stop executing the contract once the balance is insufficient.