Skip to content

Instantly share code, notes, and snippets.

@web3author
web3author / hardhat.config.js
Created February 15, 2023 16:23
Hardhat config file
/** @type import(‘hardhat/config’).HardhatUserConfig */
require("@nomiclabs/hardhat-waffle")
require("dotenv").config()
module.exports = {
solidity: "0.8.17",
networks: {
goerli: {
url: process.env.GOERLI_URL,
accounts: [process.env.PRIVATE_KEY]
}
@web3author
web3author / storage.js
Last active March 3, 2023 12:31
Testing script
const {expect} = require("chai");
describe("NumberStorage Smart Contract", function(){
it("Should set the value of storedNumber value to the value passed in", async function(){
const NumberStorage = await ethers.getContractFactory("NumberStorage");
const numberStorage = await NumberStorage.deploy();
await numberStorage.setNumber(21)
console.log(await numberStorage.storedNumber())
expect(await numberStorage.storedNumber()).to.equal(21)
})
@web3author
web3author / deploy.js
Last active March 3, 2023 12:42
Script for Deployment
async function main (){
const NumberStorage = await ethers.getContractFactory("NumberStorage"); // instance of contract
const numberStorage = await NumberStorage.deploy(); // deploy contract
console.log("NumberStorage deployed to:", numberStorage.address);
}
main()
.then(() => process.exit(0))
.catch(error => {
console.error(error);
@web3author
web3author / NumberStorage.sol
Last active March 3, 2023 11:28
Simple Solidity code to store a number
//SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.17;
contract NumberStorage {
uint public storedNumber;
// Storing function
function setNumber(uint _number) public {
storedNumber = _number;