Cycle

The Scriptorium

Smart Assembly code templates and tools for on-chain development in Eve Frontier.

Building Your First Gate
IntermediateChapter 4 of 420 min read

Deployment and Testing

Let's bring everything together — test our gate locally, then deploy it to Eve Frontier.

Project Structure

Your finished gate project should look like this:

``

my-smart-gate/

├── mud.config.ts # Table definitions

├── src/

│ └── systems/

│ ├── GateSystem.sol # Main gate usage

│ ├── GateAccessSystem.sol # Access control

│ └── GateTollSystem.sol # Toll collection

├── test/

│ ├── GateSystem.t.sol

│ ├── GateAccess.t.sol

│ └── GateToll.t.sol

└── script/

└── ConfigureGate.s.sol # Post-deploy setup

``

Writing Tests

solidity
// test/GateAccess.t.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;

import "forge-std/Test.sol";
import { GateAccessSystem } from "../src/systems/GateAccessSystem.sol";
import { GateConfig } from "../src/codegen/tables/GateConfig.sol";

contract GateAccessTest is Test {
  GateAccessSystem public accessSystem;
  uint256 constant GATE_ID = 1;
  address owner = address(0x1);
  address player = address(0x2);

  function setUp() public {
    accessSystem = new GateAccessSystem();
    // Initialize gate with owner
    vm.prank(owner);
    GateConfig.setOwner(GATE_ID, owner);
  }

  function test_publicAccess_allowsEveryone() public {
    vm.prank(owner);
    accessSystem.setAccessMode(GATE_ID, 0); // PUBLIC

    bool hasAccess = accessSystem.checkAccess(GATE_ID, player);
    assertTrue(hasAccess);
  }

  function test_whitelistAccess_deniesUnlisted() public {
    vm.prank(owner);
    accessSystem.setAccessMode(GATE_ID, 1); // WHITELIST

    bool hasAccess = accessSystem.checkAccess(GATE_ID, player);
    assertFalse(hasAccess);
  }

  function test_whitelistAccess_allowsListed() public {
    vm.prank(owner);
    accessSystem.setAccessMode(GATE_ID, 1);
    accessSystem.addToWhitelist(GATE_ID, player);

    bool hasAccess = accessSystem.checkAccess(GATE_ID, player);
    assertTrue(hasAccess);
  }
}

Deployment Script

solidity
// script/ConfigureGate.s.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;

import "forge-std/Script.sol";
import { GateConfig } from "../src/codegen/tables/GateConfig.sol";

contract ConfigureGate is Script {
  function run() external {
    uint256 deployerKey = vm.envUint("PRIVATE_KEY");
    vm.startBroadcast(deployerKey);

    uint256 gateId = 1234; // Your Smart Assembly ID
    address owner = vm.addr(deployerKey);

    // Configure the gate
    GateConfig.set(
      gateId,
      owner,
      5678,           // linked gate ID
      0.001 ether,    // toll
      true,           // active
      0               // public access
    );

    vm.stopBroadcast();
  }
}

Deploy and Configure

bash
# 1. Run tests
pnpm mud test

# 2. Deploy to Eve Frontier
pnpm mud deploy --profile eve-frontier

# 3. Configure your gate
forge script script/ConfigureGate.s.sol \
  --rpc-url https://rpc.evefrontier.com \
  --broadcast

Congratulations!

You've built a fully functional Smart Gate with:

  • Configurable access control (public, whitelist, tribe-only)
  • Toll collection with revenue tracking
  • Owner withdrawal
  • Full test coverage

Try extending your gate with:

  • Dynamic tolls based on time of day or demand
  • Usage limits per player per day
  • Alliance support for multi-tribe access
  • Event logging for analytics

Sign in to track your progress.