Writing a Basic Smart Contract
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;
contract HelloNexi {
string public message;
constructor(string memory _message) {
message = _message;
}
}
Initialize Using Hardhat
npx hardhat init
Compile the Contract
npx hardhat compile
Deploy Using a Hardhat Script
const { ethers } = require("hardhat");
async function main() {
const HelloNexi = await ethers.getContractFactory("HelloNexi");
const contract = await HelloNexi.deploy("Hello, NEXI!");
console.log("Deployed at:", contract.address);
}
main();
Run the Deployment
npx hardhat run scripts/deploy.js --network nexi