-
-
Save adilanchian/9f745fdfa9186047e7a779c02f4bffb7 to your computer and use it in GitHub Desktop.
const main = async () => { | |
const [deployer] = await hre.ethers.getSigners(); | |
const accountBalance = await deployer.getBalance(); | |
console.log('Deploying contracts with account: ', deployer.address); | |
console.log('Account balance: ', accountBalance.toString()); | |
const Token = await hre.ethers.getContractFactory('WavePortal'); | |
const portal = await Token.deploy(); | |
console.log('WavePortal address: ', portal.address); | |
}; | |
const runMain = async () => { | |
try { | |
await main(); | |
process.exit(0); | |
} catch (error) { | |
console.error(error); | |
process.exit(1); | |
} | |
}; | |
runMain(); |
const main = async () => { | |
const [owner, randoPerson] = await hre.ethers.getSigners(); | |
const waveContractFactory = await hre.ethers.getContractFactory('WavePortal'); | |
const waveContract = await waveContractFactory.deploy(); | |
await waveContract.deployed(); | |
console.log('Contract deployed to:', waveContract.address); | |
console.log('Contract deployed by:', owner.address); | |
let waveCount; | |
waveCount = await waveContract.getTotalWaves(); | |
let waveTxn = await waveContract.wave(); | |
await waveTxn.wait(); | |
waveCount = await waveContract.getTotalWaves(); | |
waveTxn = await waveContract.connect(randoPerson).wave(); | |
await waveTxn.wait(); | |
waveCount = await waveContract.getTotalWaves(); | |
}; | |
const runMain = async () => { | |
try { | |
await main(); | |
process.exit(0); | |
} catch (error) { | |
console.log(error); | |
process.exit(1); | |
} | |
}; | |
runMain(); |
// SPDX-License-Identifier: UNLICENSED | |
pragma solidity ^0.8.0; | |
import "hardhat/console.sol"; | |
contract WavePortal { | |
uint256 totalWaves; | |
constructor() { | |
console.log("Yo yo, I am a contract am I am smart"); | |
} | |
function wave() public { | |
totalWaves += 1; | |
console.log("%s has waved!", msg.sender); | |
} | |
function getTotalWaves() public view returns (uint256) { | |
console.log("We have %d total waves!", totalWaves); | |
return totalWaves; | |
} | |
} |
@QChesthairQ please check your code again properly. There must be some typing mistake..or you missed brackets while calling getTotalWaves function.
@Codeprime-21 I guess I am new to npx, so I figured it out it needs to be compiled before rerun the run.js
@QChesthairQ yup. errors needs the code snippet to be checked before concluding what the error is...😂
But yeah glad you figured it out! Good luck.
LFG! 🕺
awesome tuto !
Done
done
ok! That was worth it.
Wow amazing, thank farza
Deployed and looks great. Thanks Farza
Thanks Farza!
Deployed and looks great. Thanks Farza
It's intersting
Excellent tutorial, hands on and cool!
lfg
It was so much fun! exciting!
🍭
awesome
I am here and I am on track with your code, Farza!
done
Done with the first part!!!
Love this
Done!!!
Done!!!
Awesome shit, Farza!!
This is awesome. Great job contributors!!!
Done!!!
Done,thank you Farza!
done!
niceee!
Nice!
done sir!
done! It's been a beautiful journey so far. Thanks for your help
Thanks
Muchas gracias!
Thanks Farza!
thx
i love u 😘
Thankssss! Easy to unterstand and follow:)
I got
TypeError: waveContract.getTotalWaves is not a function
.What it he root cause of this?