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.
- Node.js v16 or above.
- Hardhat.
- OpenZeppelin Upgrades.
- A funded deployer wallet (ETH for gas).
- Access to an RPC provider (e.g., Alchemy or QuickNode).
-
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. -
Install dependencies:
npm install
-
Create a
.envfile 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.
-
Ensure
hardhat.config.jsloads environment variables:require("dotenv").config();
- 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
AuthorizedCallerSetwhen contract permissions change.
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.
The repository includes a deployment script: scripts/deploy.js.
npx hardhat run scripts/deploy.js --network sepolianpx hardhat run scripts/deploy.js --network mainnetTo 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.
- Ensure private keys are never committed.
- Use a multisig wallet for contract ownership.
- Audit new deployments and configuration changes.