This project is designed to deploy smart contracts on the Rootstock network using Hardhat Ignition for deployment. We'll configure the network connection using the Rootstock RPC API.
Before you can deploy the contracts, ensure you have the following installed on your pc:
- Node.js (version 16.x or higher recommended)
- npm or Yarn for package management
- Hardhat - a development environment for Ethereum software
- Hardhat Ignition - a plugin for deploying smart contracts in a predictable and reproducible manner
- A Rootstock RPC API endpoint for connecting to the Rootstock network (Mainnet or Testnet)
.
├── contracts
│ └── contracts...
├── ignition
│ └── modules
│ └── deployments...
├── test
│ └── tests...
├── package.json
├── hardhat.config.ts
├── README.md
└── tsconfig.json
- Clone the repository:
git clone https://github.com/chrisarevalo11/rsk-hardhat-workshop.git
cd rsk-hardhat-workshop
- Open it in your preferred IDE.
- Install dependencies:
npm i
- Go to the Rootstock RPC API web and get your API keys. Copy it and paste it into a
.env
file as well as your deployer account's private key. Remember to have enough funds to pay for gas. If needed, go to the Rootstock Faucet and get testnet tokens.
RSK_MAINNET_RPC_URL=
RSK_TESTNET_RPC_URL=
PRIVATE_KEY=
- Compile and test your contracts:
npx hardhat compile
npx hardhat test
- Deploy your contracts:
npx hardhat ignition deploy --network rskTestnet ignition/modules/Box.ts
And, if you followed the instructions correctly and had luck, you see something like this:
✔ Confirm deploy to network rskTestnet (31)? … yes
Hardhat Ignition 🚀
Resuming existing deployment from ./ignition/deployments/chain-31
Deploying [ BoxModule ]
Batch #1
Executed BoxModule#Box
[ BoxModule ] successfully deployed 🚀
Deployed Addresses
BoxModule#Box - 0x4949D33d795dF56283EEB3cE7744038Ab229712f
Now go to the Rootstock testnet explorer and check that the contract has indeed been deployed.
You deployed a contract on Rootstock Network. Keep on building together in this ecosystem! If you had trouble throughout this guide or need further help, please reach out to us on Discord and we will get back to you as soon as possible.