Skip to main content

Documentation Index

Fetch the complete documentation index at: https://core.anylayer.org/llms.txt

Use this file to discover all available pages before exploring further.

Overview

ZKScore contracts can be deployed to multiple networks with different configurations for mainnet and testnet environments.

Prerequisites

Required Tools

  • Node.js: v16.0.0 or higher
  • Hardhat: v2.17.0 or higher
  • Foundry: v0.2.0 or higher (optional)
  • Git: For cloning repositories

Environment Setup

# Clone the repository
git clone https://github.com/zkscore/smart-contracts.git
cd smart-contracts

# Install dependencies
npm install

# Install foundry (optional)
curl -L https://foundry.paradigm.xyz | bash
foundryup

Network Configuration

Mainnet Networks

// hardhat.config.js
module.exports = {
  networks: {
    ethereum: {
      url: process.env.ETHEREUM_RPC_URL,
      accounts: [process.env.PRIVATE_KEY],
      gasPrice: 20000000000, // 20 gwei
    },
    polygon: {
      url: process.env.POLYGON_RPC_URL,
      accounts: [process.env.PRIVATE_KEY],
      gasPrice: 30000000000, // 30 gwei
    },
    arbitrum: {
      url: process.env.ARBITRUM_RPC_URL,
      accounts: [process.env.PRIVATE_KEY],
    },
    base: {
      url: process.env.BASE_RPC_URL,
      accounts: [process.env.PRIVATE_KEY],
    }
  }
};

Testnet Networks

// hardhat.config.js
module.exports = {
  networks: {
    goerli: {
      url: process.env.GOERLI_RPC_URL,
      accounts: [process.env.PRIVATE_KEY],
    },
    mumbai: {
      url: process.env.MUMBAI_RPC_URL,
      accounts: [process.env.PRIVATE_KEY],
    },
    arbitrumGoerli: {
      url: process.env.ARBITRUM_GOERLI_RPC_URL,
      accounts: [process.env.PRIVATE_KEY],
    }
  }
};

Deployment Scripts

Identity SBT Deployment

// scripts/deploy-identity-sbt.js
const { ethers } = require("hardhat");

async function main() {
  const IdentitySBT = await ethers.getContractFactory("IdentitySBT");
  
  const identitySBT = await IdentitySBT.deploy(
    "ZKScore Identity", // name
    "ZKSID", // symbol
    "https://api.onzks.com/metadata/identity/" // baseURI
  );
  
  await identitySBT.deployed();
  
  console.log("IdentitySBT deployed to:", identitySBT.address);
  
  // Verify contract
  await hre.run("verify:verify", {
    address: identitySBT.address,
    constructorArguments: [
      "ZKScore Identity",
      "ZKSID", 
      "https://api.onzks.com/metadata/identity/"
    ],
  });
}

main().catch((error) => {
  console.error(error);
  process.exitCode = 1;
});

Score Calculator Deployment

// scripts/deploy-score-calculator.js
const { ethers } = require("hardhat");

async function main() {
  const ScoreCalculator = await ethers.getContractFactory("ScoreCalculator");
  
  const scoreCalculator = await ScoreCalculator.deploy(
    identitySBTAddress, // identity contract address
    trustedSignerAddress // trusted signer for score updates
  );
  
  await scoreCalculator.deployed();
  
  console.log("ScoreCalculator deployed to:", scoreCalculator.address);
}

Deployment Commands

Hardhat Deployment

# Deploy to mainnet
npx hardhat run scripts/deploy-all.js --network ethereum

# Deploy to testnet
npx hardhat run scripts/deploy-all.js --network goerli

# Verify contracts
npx hardhat verify --network ethereum <contract_address>

Foundry Deployment

# Deploy with foundry
forge script scripts/Deploy.s.sol --rpc-url $ETHEREUM_RPC_URL --broadcast

# Verify contracts
forge verify-contract <contract_address> src/IdentitySBT.sol:IdentitySBT

Environment Variables

Create a .env file with required variables:
# RPC URLs
ETHEREUM_RPC_URL=https://eth-mainnet.alchemyapi.io/v2/YOUR_KEY
POLYGON_RPC_URL=https://polygon-mainnet.g.alchemy.com/v2/YOUR_KEY
ARBITRUM_RPC_URL=https://arb-mainnet.g.alchemy.com/v2/YOUR_KEY
BASE_RPC_URL=https://mainnet.base.org

# Testnet URLs
GOERLI_RPC_URL=https://eth-goerli.alchemyapi.io/v2/YOUR_KEY
MUMBAI_RPC_URL=https://polygon-mumbai.g.alchemy.com/v2/YOUR_KEY
ARBITRUM_GOERLI_RPC_URL=https://goerli-rollup.arbitrum.io/rpc

# Private keys
PRIVATE_KEY=your_private_key_here

# API keys
ETHERSCAN_API_KEY=your_etherscan_key
POLYGONSCAN_API_KEY=your_polygonscan_key
ARBISCAN_API_KEY=your_arbiscan_key

Verification

Contract Verification

# Verify on Etherscan
npx hardhat verify --network ethereum <contract_address> <constructor_args>

# Verify on Polygonscan
npx hardhat verify --network polygon <contract_address> <constructor_args>

Testing Deployment

# Run tests
npx hardhat test

# Run tests on specific network
npx hardhat test --network goerli