LazAI provides a testnet environment for deploying smart contracts. In this guide, we use Hardhat to build, deploy, and test a simple Counter contract.
Network Information
- Testnet: LazAI Testnet
- Chain ID: 133718
- Currency: LAZAI
- RPC: https://testnet.lazai.network
- Block Explorer: https://testnet-explorer.lazai.network
- Faucet: Telegram-based LazAI Testnet Faucet
Key Contract Addresses (Testnet)
- Data Registry:
0xEAd077726dC83ecF385e3763ed4A0A50E8Ac5AA0
- Verified Computing:
0x815da22D880E3560bCEcc85b6e4938b30c8202C4
- Data Anchoring Token (DAT):
0x2eD344c586303C98FC3c6D5B42C5616ED42f9D9d
Prerequisites
- Node.js v14+
- npm or yarn
- Git
- Code editor (VS Code recommended)
- Optional: MetaMask wallet with testnet tokens
Step 1: Setup Hardhat Project
mkdir counter-project
cd counter-project
npm init -y
npm install — save-dev hardhat @nomicfoundation/hardhat-toolbox @nomicfoundation/hardhat-ignition dotenv
npx hardhat
Step 2: Write Smart Contract
contracts/Counter.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract Counter {
uint256 private count;
function increment() public { count += 1; }
function decrement() public { count -= 1; }
function getCount() public view returns (uint256) { return count; }
}
Step 3: Compile Contracts
npx hardhat compile
Step 4: Create Deployment Script
ignition/Counter.js
const { buildModule } = require(“@nomicfoundation/hardhat-ignition/modules”);
module.exports = buildModule(“CounterModule”, (m) => {
const counter = m.contract(“Counter”);
return { counter };
});
Step 5: Configure Network
Create .env
file:
PRIVATE_KEY=your_private_key_here
Update hardhat.config.js
:
require(“@nomicfoundation/hardhat-toolbox”);
require(“dotenv”).config();
module.exports = {
solidity: “0.8.28”,
networks: {
hardhat: { chainId: 31337 },
lazai: {
url: “https://testnet.lazai.network",
chainId: 133718,
accounts: [process.env.PRIVATE_KEY],
},
},
};
Step 6: Deploy Contract
- Local Deployment (Optional)
npx hardhat node
npx hardhat ignition deploy ignition/modules/Counter.js --network localhost
LazAI Testnet Deployment
npx hardhat ignition deploy ignition/modules/Counter.js — network lazai
Step 7: Test Contract
test/Counter.js
const { expect } = require(“chai”);
describe(“Counter”, function () {
it(“Should increment the counter”, async function () {
const Counter = await ethers.getContractFactory(“Counter”);
const counter = await Counter.deploy();
await counter.deployed();
await counter.increment();
expect(await counter.getCount()).to.equal(1);
});
});
Run tests:
npx hardhat test
Github reference — Click here !!!