If you wish to suggest changes on this document, please open a PR on the Foundry Starter Kit Repository
Rootstock Foundry Starter Kit
Whether you’re a seasoned developer or just starting your journey into smart contract development, the foundry starter kit provides a solid foundation for building decentralized applications (dApps) on the Rootstock network.
Rootstock is fully EVM (Ethereum Virtual Machine) compatible. It brings the power of smart contracts to Bitcoin, allowing developers to leverage Bitcoin’s security while benefiting from Ethereum’s ecosystem.
In this tutorial, you'll learn how to set up your Foundry development environment, connect to a Rootstock network, write and test smart contracts, deploy them to the Rootstock blockchain, and interact with them. We'll guide you through every step, from installation to minting your first token.
Prerequisites
Before starting the dApp, make sure to have the following prerequisites:
-
Familiarity with Smart Contracts:
- If you’re new to smart contracts, consider learning the basics. Understanding how smart contracts work will enhance your experience with Rootstock development.
-
Foundry installation using Foundryup:
- To install, visit the official Foundry documentation for more information.
- Foundryup is the official installer for the Foundry toolchain. You can learn more about it in the Foundryup README.
- If you encounter any issues during installation, refer to the Foundryup FAQ for assistance.
- Precompiled binaries can be downloaded from the Foundry GitHub releases page. For easier management, we recommend using Foundryup.
To install Foundry in your system, run the following command:
curl -L https://foundry.paradigm.xyz | bash
This will install Foundryup. Follow the on-screen instructions, and the foundryup
command will be available via the CLI.
Running foundryup
automatically installs the latest (nightly) versions of the precompiled binaries: forge
, cast
, anvil
, and chisel
. For additional options, such as installing a specific version or commit, run foundryup --help
.
- Basic Knowledge of Foundry:
- Familiarity with Foundry's core concepts and functionalities is recommended. If you're new to Foundry, refer to the Rootstock Foundry Guide.
Learn how to write, test, secure, deploy and verify smart contracts on the Rootstock blockchain network. Enroll for the Rootstock Blockchain Developer Course.
Setting Up the Sample dApp
Clone the Repository
Open your terminal or command prompt and run the following command to clone the repository from GitHub:
git clone https://github.com/rsksmart/rootstock-foundry-starterkit.git
Install Dependencies
Navigate to the cloned repository folder:
cd rootstock-foundry-starterkit
Install all required dependencies using forge:
forge install openzeppelin-contracts-05=OpenZeppelin/openzeppelin-contracts@v2.5.0 openzeppelin-contracts-06=OpenZeppelin/openzeppelin-contracts@v3.4.0 openzeppelin-contracts-08=OpenZeppelin/openzeppelin-contracts@v4.8.3 --no-commit
Add Rootstock Testnet and Mainnet RPC URLs
This section will walk you through adding Rootstock Testnet and Mainnet RPC URLs to your development environment. These URLs are essential for connecting your application to the Rootstock network and interacting with smart contracts.
There are two ways to obtain RPC URLs: