Deploy a contract with Hardhat
Last updated
Last updated
This section is a guide on how to deploy a smart contract on the B² Network using .
Hardhat is a popular smart contract development frameworks. It is used in the B² rollup as a default for deploying and automatically verifying smart contracts.
Get some test BTC from Bitcoin testnet faucet, and cross chain the test BTC from Bitcoin testnet to B² Network Testnet by test bridge.
Install Hardhat and dependencies
Run npx hardhat init to init a new project, and you will be shown some options to facilitate project creation:
Open the hardhat.config.js file and paste the below code:
Create a new contract code file, in the contracts folder, named Storage.sol
Copy the below code and paste it in the Storage contract code:
Create a new file in the scripts folder deploy-storage.js
Add the code below to the deploy-counter.js file:
Before compiling the contract, you need to install the toolbox. You may need to change directory to install outside the project. Use this command:
Compile your contract code (i.e., go back to the project root in the CLI):
Now run the scripts: