Links

Using Hardhat

​
Follow until step 6 of the Hardhat tutorial​
Write script deploy ./script/deploy.ts
import {task} from "hardhat/config";
​
​
task("deploy", "Deploy the contract", async (args, hre) => {
const helloPosiChain = await hre.ethers.getContractFactory("HelloPosiChain");
const helloPoiChainContract = await helloPosiChain.deploy();
await helloPoiChainContract.deployed();
console.log("HelloPosiChain deployed to:", helloPoiChainContract.address);
})
Add POSI Chain testnet or mainnet entries to hardhat.config.js file.
​
import { HardhatUserConfig, task } from "hardhat/config";
import "@nomicfoundation/hardhat-toolbox";
import "./scripts/deploy"; // import script verify
​
​
const privateKey = '<ADD_YOUR_PRIVATE_KEY_HERE>'
const apiKeyEthereum = '<YOUR_API_KEY>' // you can get api key from etherscan.io or bscscan.com
const config: HardhatUserConfig = {
solidity: "0.8.9",
networks: {
posichain_testnet: {
url: "http://api.s0.t.posichain.org",
chainId: 910000,
accounts: [privateKey]
},
posichain_mainnet: {
url: "https://api.posichain.org/",
chainId: 900000,
accounts: [privateKey]
​
}
}
};
​
export default config;
​
Run deploy contract: Before deploy, you must sure your contracts already compile by run
npx hardhat compile
Finally run:
npx hardhat <YOUR_TASK> --network <YOUR_NETWORK>
Example
npx hardhat deploy --network posichain_testnet // for testnet
​
npx hardhat deploy --network posichain_mainnet // for mainnet
Example: