Skip to content

crynux-network/crynux-contracts

Repository files navigation

The Smart Contracts for the Crynux Network

The solidity contracts to coordinate the nodes and tasks.

Current Contract Scope

For the current off-chain task dispatch architecture and the active Relay integration contract set, see ./docs/contract-roles-and-status.md.

Task State Transitions

Task State Transitions

Compilation

The contracts are developed using Hardhat 3.

Install the dependencies before compilation:

$ npm install

Run the Hardhat compile command using npm:

$ npm run compile

L1 ERC-20 Crynux Token Deployment

Store the rollup deployer private key in the Hardhat keystore:

$ npx hardhat keystore set L2_ROLLUP_DEPLOYER_PRIVATE_KEY

Generate a new wallet when a fresh deployer account is required:

$ npx tsx scripts/generate-wallet.ts

Base mainnet uses https://mainnet.base.org by default. Base Sepolia uses https://sepolia.base.org by default. Set BASE_RPC_URL or BASE_SEPOLIA_RPC_URL in the environment to override either endpoint.

Deploy the L1 ERC-20 Crynux token with Hardhat Ignition:

$ npm run deploy:l1:erc20-crynux-token -- --network <network>

Emission ERC-20 Contract Deployment

Create a deployment parameter file for the emission contract:

{
    "DeployEmissionErc20": {
        "tokenAddress": "0x0000000000000000000000000000000000000001",
        "mode": 0,
        "daoTreasuryAddress": "0x0000000000000000000000000000000000000002",
        "relayWalletColdAddress": "0x0000000000000000000000000000000000000003",
        "startTimestamp": 1735689600,
        "initialEmissionIndex": 0,
        "initCostCNX": 0
    }
}

Parameter requirements:

  • tokenAddress: deployed CrynuxToken address.
  • mode: emission mode enum value. 0 is Primary and 1 is Mirror.
  • daoTreasuryAddress: immutable DAO treasury receiver address.
  • relayWalletColdAddress: immutable relay cold wallet receiver address.
  • startTimestamp: emission schedule start timestamp in seconds.
  • initialEmissionIndex: number of already completed emission periods when the contract is deployed.
  • initCostCNX: startup cost in whole CNX units, deducted from the first DAO emission in Primary mode. Mirror mode requires this to be 0.

Deploy the emission contract with Hardhat Ignition:

$ npm run deploy:emission:erc20 -- --network <network> --parameters ./cache/deploy-emission-erc20-params.json

L2 Node Contracts Deployment

Create a deployment parameter file for the L2 node contracts:

{
    "DeployNodeContracts": {
        "relayOperatorAddress": "0x000000000000000000000000000000000000dEaD",
        "creditsAdminAddress": "0x000000000000000000000000000000000000bEEF",
        "parameterWriterAddress": "0x000000000000000000000000000000000000c0De",
        "slashReceiverAddress": "0x000000000000000000000000000000000000FEE1"
    }
}

Parameter requirements:

  • relayOperatorAddress: Relay runtime signer for NodeStaking.unstake and NodeStaking.slashStaking.
  • creditsAdminAddress: bootstrap credit issuance signer for Credits.createCredits.
  • parameterWriterAddress: initial writer for ParameterController governed operational parameter updates.
  • slashReceiverAddress: immutable slash receiver for both NodeStaking and DelegatedStaking. This address is set in constructors and cannot be changed after deployment.

Deploy the L2 node contracts with Hardhat Ignition:

$ npm run deploy:l2:node-contracts -- --network <network> --parameters ./cache/deploy-l2-node-contracts-params.json

About

The solidity contracts to coordinate the nodes and tasks.

Resources

Stars

Watchers

Forks

Releases

Packages

Used by

Contributors

Languages