Configuration and Deployment

This guide outlines the technical steps required to deploy smart contracts on the Cypher testnet. It includes configuring your development environment, deploying contracts, verifying deployments, and obtaining testnet tokens for transactions.

Configuration Details

RPC Endpoint and Gateway URLs

  • RPC Testnet URL: https://testnet-rpc.cypher.z1labs.ai

  • Gateway URL: https://gateway.cypherscan.ai

The RPC URL connects your development environment to the Cypher testnet, while the Gateway URL facilitates encrypted operations, such as decryption or re-encryption, when interacting with Cypher.

Deployment Steps

Step 1: Configure Network Settings

Set up the Cypher network in your development framework (e.g., Hardhat or Truffle). Below is an example configuration for Hardhat:

module.exports = {
    networks: {
        cypherTestnet: {
            url: "https://testnet-rpc.cypher.z1labs.ai",
            chainId: 10111,
            accounts: ["<YOUR_PRIVATE_KEY>"] // Replace with your wallet's private key or use a .env file for security
        }
    },
    solidity: "0.8.17",
};

For Truffle, modify your truffle-config.js:

// Example configuration for the Cypher network using Web3j in Java

module.exports = {
    networks: {
        cypherTestnet: {
            provider: () => new HDWalletProvider("<YOUR_MNEMONIC>", "https://testnet-rpc.cypher.z1labs.ai"),
            network_id: 10111, // Cypher testnet Chain ID
        }
    },
    compilers: {
        solc: {
            version: "0.8.17"
        }
    }
};

Step 2: Update Gateway Configuration

If your application interacts with encrypted data, ensure the Gateway URL is correctly configured. For example, in fhevmjs:

const instance = await createInstance({
    networkUrl: "https://testnet-rpc.cypher.z1labs.ai",
    gatewayUrl: "https://gateway.cypherscan.ai"
});

Step 3: Deploy Your Contracts

Use your preferred tool to deploy contracts. For Hardhat, an example deployment script is as follows:

const hre = require("hardhat");

async function main() {
    const Contract = await hre.ethers.getContractFactory("YourContract");
    const contract = await Contract.deploy();
    await contract.deployed();
    console.log("Contract deployed to:", contract.address);
}

main()
    .then(() => process.exit(0))
    .catch((error) => {
        console.error(error);
        process.exit(1);
    });

Run the script with:

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

For Truffle:

truffle migrate --network cypherTestnet

Step 4: Verify Deployment

Cypherscan Interface Verification

  • Provide your contract address, compiler details, and source code.

  • Follow the guided form to complete the verification process.

Cypherscan API Verification

Automate verification by interacting with the Cypherscan API:

  • API Endpoint: https://testnet.cypherscan.ai/api/v2/

  • Example Request:

After deployment, verify your contract on Cypherscan to make the source code accessible for public inspection.

curl -X POST https://testnet.cypherscan.ai/api/v2/verifyContract \
-H "Content-Type: application/json" \
-d '{
    "address": "<CONTRACT_ADDRESS>",
    "sourceCode": "<SOURCE_CODE>",
    "contractName": "YourContract",
    "compilerVersion": "v0.8.17+commit.d19bba13",
    "optimizationUsed": true
}'

Last updated