Install Update :
sudo apt-get update && sudo apt-get upgrade -y
Install Curl :
sudo apt install curl
HARDHAT :
Create a Swiss Directory
Enter the Directory
sudo apt-get remove -y nodejs
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash && export NVM_DIR="/usr/local/share/nvm"; [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"; [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"; source ~/.bashrc; nvm install --lts; nvm use --lts
npm install --save-dev hardhat
npm install --save-dev @nomicfoundation/hardhat-toolbox
Enter - Enter - Y - Y
nano hardhat.config.js
Change "accounts: ["0xd5..."] private key with 0x :
require("@nomicfoundation/hardhat-toolbox");
module.exports = {
solidity: "0.8.19",
networks: {
swisstronik: {
url: "https://json-rpc.testnet.swisstronik.com/",
accounts: ["0xd5..."], //Your private key starting with "0x"
},
},
};
CTRL X - CTRL Y - Enter - Saved.
Copy And Paste :
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.19;
contract Swisstronik {
string private message;
constructor(string memory _message) payable{
message = _message;
}
function setMessage(string memory _message) public {
message = _message;
}
function getMessage() public view returns(string memory){
return message;
}
}
CTRL X - CTRL Y - Enter - Saved.
Now Edit Time :
mkdir scripts && cd scripts
Copy And Paste :
const hre = require("hardhat");
async function main() {
const contract = await hre.ethers.deployContract("Swisstronik", ["Hello Swisstronik, RPCdot airforce greets you!"]);
await contract.waitForDeployment();
console.log(`Swisstronik contract deployed to ${contract.target}`);
}
main().catch((error) => {
console.error(error);
process.exitCode = 1;
});
CTRL X - CTRL Y - Enter. Saved.
npx hardhat run scripts/deploy.js --network swisstronik
Result Looks Like a : Swisstronik contract deployed to 0xnumbers
Copy Contract Adress And Sumbit
nano hardhat.config.js
Delete Your Private Key.
CTRL X - CTRL Y - Enter. Saved.
Last updated