Skip to content

sylanproject/sylan-contracts

Repository files navigation

Sylan Smart Contracts

This repository contains the core smart contracts for the Sylan API Gateway ecosystem, including:

  • SylanToken (ERC20) – Utility token for payments and staking.
  • SylanVesting – Token vesting for teams, marketing, and ecosystem participants.
  • AccessRegistry – Manages API access rights (subscriptions and pay-per-call).
  • EventLogger – Records on-chain logs for transparency and tracks authorization changes.
  • NodeRegistry – Handles node registration, staking, and reputation.
  • APIEscrow – Holds API request fees until a consensus response is reached.
  • APIConsensus – Aggregates responses from nodes, rewards honest nodes, and penalizes malicious ones.

Requirements


Project Setup

  1. Clone the repository (fork it first if you plan to contribute):

    git clone https://github.com/<your-github-username>/sylan-contracts.git
    cd sylan-contracts

    Replace <your-github-username> with the GitHub account or organization that owns your fork. You can also clone directly from the upstream owner if you only need read-only access.

  2. Install dependencies:

    npm install
  3. Create a .env file for sensitive data:

    DEPLOYER_PRIVATE_KEY=0xYOUR_PRIVATE_KEY
    ALCHEMY_API_KEY=yourAlchemyApiKey
    ETHERSCAN_API_KEY=yourEtherscanApiKey

    Replace the placeholders with the private key for your deployer wallet and the API keys issued by your infrastructure providers.

  4. Ensure hardhat.config.js loads environment variables:

    require("dotenv").config();

Contracts Overview

  • SylanToken.sol – ERC20 token with UUPS upgradeability.
  • SylanVesting.sol – Manages locked token releases.
  • NodeRegistry.sol – Node staking, reputation, and slashing logic.
  • APIEscrow.sol – Escrows API request fees until consensus.
  • APIConsensus.sol – Threshold-based aggregation of node responses.
  • EventLogger.sol – On-chain audit log that emits AuthorizedCallerSet when contract permissions change.

Node Economics and Slashing

The APIConsensus contract applies a slashing penalty to nodes that submit responses which diverge from the finalized consensus. The penalty is controlled by the slashAmount parameter, expressed in basis points (1/100th of a percent) of a node's staked SYL in the NodeRegistry (defaults to 1%). Increasing this value raises the stake at risk for misbehavior, while decreasing it reduces potential losses for node operators. The contract owner may adjust the parameter via setSlashAmount as network conditions evolve.


Deployment

The repository includes a deployment script: scripts/deploy.js.

Deploy to Testnet

npx hardhat run scripts/deploy.js --network sepolia

Deploy to Mainnet

npx hardhat run scripts/deploy.js --network mainnet

Contract Verification

To verify a contract on Etherscan:

npx hardhat verify --network sepolia <DEPLOYED_CONTRACT_ADDRESS> <CONSTRUCTOR_ARGS>
  • <DEPLOYED_CONTRACT_ADDRESS> – the address returned when your contract deployment completed on the selected network.
  • <CONSTRUCTOR_ARGS> – every constructor argument for the implementation contract, listed in the exact order defined in the Solidity constructor (omit this placeholder entirely if the constructor takes no parameters). Refer to the Hardhat verification guide for formatting details.

For UUPS proxies:

npx hardhat verify --network sepolia <IMPLEMENTATION_ADDRESS>
  • <IMPLEMENTATION_ADDRESS> – the current implementation address behind your proxy contract (available via your upgrade scripts or by querying the proxy admin). The OpenZeppelin Upgrades verification docs explain how to retrieve and verify this address.

Security Notes

  • Ensure private keys are never committed.
  • Use a multisig wallet for contract ownership.
  • Audit new deployments and configuration changes.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors