Create, compile, deploy an verify your own Smart Contract with Hardhat !
In this project we are going to use Hardhat for create token on the blockchain because it's easy (2 commands) and it use javascript (a common language) and solidity (close to js).
There are a few technical requirements before we start as listed below:
- Node.js v10+ LTS and npm (comes with Node)
- Git
- Download project with
git clone git@github.com:rbourgeat/tokenizer.git
- Create a METAMASK account or other crypto account
- Launch project with
cd code && npm install
Copy my BEP20Token contract (./code/contracts/rbourgeat42.sol
) and customize it if you want !
Next compile your contract with this:
npx hardhat compile
Create a secrets.json
in the code/
folder with your mnemonic and a infura API_KEY (get it here).
{
"mnemonic": "your_secret_recovery_phrase",
"infuraApiKey": "your_infura_api"
}
Note: It requires mnemonic to be passed in for Provider, this is the seed phrase for the account you'd like to deploy from. Create a new
secrets.json
file in root directory and enter your 12 word mnemonic seed phrase to get started. To get the seedwords from metamask wallet you can go to Metamask Settings, then from the menu choose Security and Privacy where you will see a button that says reveal seed words.
Now deploy your contract with the following command:
npx hardhat run --network sepolia ../deployment/deploy.js
Info: With this command we use Sepolia network for test (you can get free speolia ETH here every 24h) but you can change network for using real money.
You can interact with your contract. For example you can edit description with the following command:
Info: edit the
contractAddress
andnewDescription
variables in the top of thedeployment/edit_description.js
script before.
npx hardhat run ../deployment/edit_description.js --network sepolia
You can add a multisignature system to your token, see the code/contracts/rbourgeat42bonus.sol
and use the deployment/deploy_multisig.js
Edit the owners by modify owners address in the script (dont forget to edit the requiredSignatures
number).
Info: A multisig (multi-signature) smart contract is a type of smart contract on a blockchain that requires multiple private keys to authorize and execute a transaction.
npx hardhat run ../deployment/deploy_multisig.js --network sepolia