Smart Contract Reference

9 Solidity contracts on Arbitrum One. All use UUPS upgradeable proxy pattern with OpenZeppelin v5. Built and tested with Foundry.

NodeRegistry

Registry for Compute Resource Nodes (CRN) and Core Channel Nodes (CCN). Manages node registration, metadata, heartbeats, and status lifecycle.

Types

enum NodeType { CCN, CRN }
enum NodeStatus { Inactive, Active, Unbonding, Deregistered }

struct NodeInfo {
    address operator;
    NodeType nodeType;
    NodeStatus status;
    uint64 registeredAt;
    uint64 lastHeartbeat;
    bytes32 metadataCID;
    uint16 rewardShareBps;
    bytes32 dataRegion;
}

Key Functions

FunctionAccessDescription
registerNode()PublicRegister a new node with type, metadata CID, and data region
heartbeat(bytes32 statusHash)Node operatorSubmit heartbeat with status hash, updates lastHeartbeat
activateNode(bytes32 nodeId)StakingManagerActivate node after minimum stake is met
deactivateNode(bytes32 nodeId)StakingManagerDeactivate node when stake falls below minimum
getActiveNodes()ViewReturns array of all active node IDs
isNodeActive(bytes32)ViewCheck if a specific node is active

Events

event NodeRegistered(bytes32 indexed nodeId, address indexed operator, NodeType nodeType, bytes32 metadataCID);
event NodeActivated(bytes32 indexed nodeId);
event NodeUnbonding(bytes32 indexed nodeId, uint64 unbondingCompleteAt);
event NodeDeregistered(bytes32 indexed nodeId);
event Heartbeat(bytes32 indexed nodeId, bytes32 statusHash);

StakingManager

Manages self-staking and delegation for node operators. Handles unbonding periods, slashing, and reward distribution.

Types

struct StakeInfo {
    uint256 selfStake;
    uint256 pendingUnbond;
    uint64 unbondStartedAt;
    uint256 totalDelegated;
}

struct Delegation {
    uint256 amount;
    uint256 pendingUndelegate;
    uint64 delegatedAt;
    uint64 undelegateStartedAt;
}

Key Functions

FunctionDescription
stake(bytes32 nodeId, uint256 amount)Self-stake ALEPH tokens for a node
unstake(bytes32 nodeId, uint256 amount)Begin unbonding period for staked tokens
withdraw(bytes32 nodeId)Withdraw tokens after unbonding period completes
delegate(bytes32 nodeId, uint256 amount)Delegate tokens to a node operator
slash(bytes32 nodeId, uint256 amount, bytes32 evidenceHash)Slash a node's stake (SLASHER_ROLE only)
Staking Parameters

minSelfStake and minTotalStake are governance-configurable. The unbonding period and max slash percentage (maxSlashBps) protect both operators and delegators.

JobManager

Manages the full job lifecycle for compute instances and serverless programs.

Types

enum JobType { Instance, Program }
enum JobStatus { Created, Assigned, Running, Stopped, Completed, Disputed }

struct ResourceRequirements {
    uint16 vcpus;
    uint32 memoryMiB;
    uint64 storageMiB;
    bool gpuRequired;
    uint16 gpuCount;
    bytes32 gpuType;       // e.g., "nvidia-a100"
    uint32 gpuVramMiB;
}

struct Job {
    bytes32 jobId;
    address owner;
    JobType jobType;
    JobStatus status;
    bytes32 contentHash;
    bytes32 assignedNode;
    uint64 createdAt;
    uint64 startedAt;
    uint64 stoppedAt;
    ResourceRequirements resources;
    bytes32 slaAgreementId;
}

Lifecycle

Created  Assigned  Running  Stopped/Completed
                                  Disputed

PaymentManager

Allowance-based periodic settlement with multi-token support. Users approve ALEPH (or other tokens) and the contract settles periodically. Non-ALEPH tokens are swapped via Uniswap V3.

Types

struct JobPayment {
    address payer;
    address paymentToken;
    uint256 pricePerSecond;
    uint64 lastSettledAt;
    uint256 totalPaid;
}

Key Functions

FunctionDescription
startPayment(bytes32 jobId, address token, uint256 pricePerSec)Initialize payment stream for a job
settle(bytes32 jobId)Settle accrued payment, swap tokens if needed
addAllowedToken(address token, uint24 fee)Add accepted payment token with Uniswap pool fee tier
DEX Integration

PaymentManager integrates with Uniswap V3's ISwapRouter.exactInputSingle() to automatically convert non-ALEPH payment tokens. Slippage protection is configurable via maxSlippageBps.

StorageRegistry

Manages storage commitments with on-chain Merkle proof verification and challenge/response auditing.

Types

struct Commitment {
    bytes32 nodeId;
    bytes32 merkleRoot;
    uint64 totalSizeBytes;
    uint16 replicationFactor;
    uint64 createdAt;
    uint64 lastProofAt;
    bool active;
}

struct Challenge {
    bytes32 commitmentId;
    bytes32 seed;
    uint64 issuedAt;
    uint64 respondedAt;
    bool resolved;
}

Key Functions

FunctionDescription
commitStorage(bytes32 nodeId, bytes32 merkleRoot, uint64 size, uint16 replication)Create storage commitment with Merkle root
issueChallenge(bytes32 commitmentId)Issue a random challenge to verify storage
respondToChallenge(bytes32 challengeId, bytes32[] proof, bytes32 leaf)Respond with Merkle proof

DomainRegistry

On-chain custom domain registration. Maps domains to compute instances with TLS certificate management.

SLAManager

Defines Service Level Agreements between users and node operators. Tracks violations and enforces penalties via StakingManager slashing.

ImageMarketplace

Marketplace for VM images. Operators publish images, users rate them, and revenue is shared between image creators and compute providers.

Deployment

# Deploy all contracts with Foundry
cd contracts
forge script script/Deploy.s.sol \
    --rpc-url $ARB_RPC \
    --broadcast \
    --verify

# Verify on Arbiscan
forge verify-contract $ADDRESS NodeRegistry \
    --chain arbitrum \
    --etherscan-api-key $ARBISCAN_KEY