Zircuit
Search
K

Deploy on Zircuit

A Tutorial for Deploying a Smart Contract on Zircuit

Overview

Deploying your first contract on Zircuit is easy! This tutorial will show you how.
If you already have an existing development environment for Ethereum, this will be fast and probably take only 10-15 minutes.
We have even provided you a boilerplate project to make this process even simpler!

Walkthrough

1. Set Up Hardhat

  • Create the folder for you new project and navigate within
    mkdir my-zircuit-coin
    cd my-zircuit-coin
  • Install Hardhat using npm (Node Package Manager):
    npm install --save-dev hardhat
  • Install the hardhat toolbox for a later step
    npm i @nomicfoundation/hardhat-toolbox
  • Initialize a new Hardhat project:
    npx hardhat

2. Write Your Smart Contract

We created a file which will have everything you need for easy deployment, all you need to do is replace the following section of the Token.sol file.
Token.sol
1KB
Binary
Sample smart contract
string public name = "Name Goes Here";
string public symbol = "TICKER";
// The fixed amount of tokens, stored in an unsigned integer type variable.
uint256 public totalSupply = 21000000;
These values are just filler, so put in a fun name for your token, a ticker and adjust the supply as you see fit!

3. Compile Your Smart Contract

  • Use this Hardhat command to compile your contract:
    npx hardhat compile

4. Set Up Your Network Configuration

  • Edit the hardhat.config.js file to define network configurations. In this case, all you need to do is enter your Zircuit private key. A sample is shown below.
require("@nomicfoundation/hardhat-toolbox");
const ZIRCUIT_PRIVATE_KEY = "YOUR ZIRCUIT PRIVATE KEY";
module.exports = {
solidity: "0.8.19",
networks: {
zircuit: {
url: `https://zircuit1.p2pify.com`,
accounts: [ZIRCUIT_PRIVATE_KEY]
}
}
};

5. Write A Deployment Script

  • In the scripts directory, create a deployment script, for instance deploy.js. This script will handle the deployment of your smart contract. A sample is below.
async function main() {
const [deployer] = await ethers.getSigners();
console.log("Deploying contracts with the account:", deployer.address);
const TokenFactory = await ethers.getContractFactory("Token");
const Token = await TokenFactory.deploy();
console.log("Token deployed to:", Token.target);
}
main()
.then(() => process.exit(0))
.catch((error) => {
console.error(error);
process.exit(1);
});

6. Deploy Your Smart Contract

  • Run the deployment script with Hardhat.
    npx hardhat run scripts/deploy.js --network zircuit

7. Verify and Interact with Your Contract

  • Once deployed, you can use Hardhat commands or the Hardhat console to interact with your contract.
  • Otherwise, you might want to verify your smart contract via our block explorer.

Conclusion

Congratulations! You've successfully launched your first contract on Zircuit.