The Scriptorium
Smart Assembly code templates and tools for on-chain development in Eve Frontier.
← Back to Example Code
Basic Smart Gate
Gate MechanicsA minimal Smart Gate implementation that controls access through a stargate. Allows the owner to toggle the gate open or closed and checks access before allowing passage.
gateaccess-controlstarter
basic-smart-gate.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;
import { SmartGateBase } from "@eveworld/smart-gate/SmartGateBase.sol";
/**
* @title BasicSmartGate
* @notice Minimal gate that the owner can open or close.
*/
contract BasicSmartGate is SmartGateBase {
bool public isOpen;
address public owner;
constructor() {
owner = msg.sender;
isOpen = true;
}
modifier onlyOwner() {
require(msg.sender == owner, "Not gate owner");
_;
}
/// @notice Toggle gate open/closed
function setOpen(bool _open) external onlyOwner {
isOpen = _open;
}
/// @notice Called by the World when a ship requests passage
function canJump(
address caller,
uint256 /* shipId */
) external view override returns (bool) {
if (!isOpen) return false;
// Allow all pilots when open
return caller != address(0);
}
}