macOS
Set up a local development environment for Substrate on macOS.
You can install Rust and set up a Substrate development environment on Apple macOS computers with either Intel or an Apple M1 processors.
Before you begin
Before you install Rust and set up your development environment on macOS, verify that your computer meets the following basic requirements:
Operating system version is 10.7 Lion, or later.
Processor speed of at least 2Ghz, 3Ghz recommended.
Memory of at least 8 GB RAM, 16 GB recommended.
Storage of at 10 GB available space.
Broadband Internet connection.
Support for Apple Silicon
Protobuf must be installed before the build process can begin. To install it, run the following command:
brew install protobuf
Install Homebrew
In most cases, you should use Homebrew to install and manage packages on macOS computers. If you don't already have Homebrew installed on your local computer, you should download and install it before continuing.
To install Homebrew:
Open the Terminal application.
Download and install Homebrew by running the following command:
Verify Homebrew has been successfully installed by running the following command:
The command displays output similar to the following:
Installation
Because the blockchain requires standard cryptography to support the generation of public/private key pairs and the validation of transaction signatures, you must also have a package that provides cryptography, such as openssl
.
To install openssl
and the Rust toolchain on macOS:
Open the Terminal application.
Ensure you have an updated version of Homebrew by running the following command:
Install the
openssl
package by running the following command:Download the
rustup
installation program and use it to install Rust by running the following command:Follow the prompts displayed to proceed with a default installation.
Update your current shell to include Cargo by running the following command:
Verify your installation by running the following command:
Configure the Rust toolchain to default to the latest stable version by running the following commands:
Add the
nightly
release and thenightly
WebAssembly (wasm) targets to your development environment by running the following commands:Verify the configuration of your development environment by running the following command:
The command displays output similar to the following:
Install
cmake
using the following command:
Compile a Substrate node
Now that you have Rust installed and the Rust toolchains configured for Substrate development, you are ready to finish setting up your development environment by cloning the Substrate node template files and compiling a Substrate node.
The node template provides a working environment that includes all of the most common features you need to build a blockchain without any extraneous modules or tools. To ensure that the node template offers a relatively stable working environment for you to experiment with, the recommended best practice is to clone Substrate node template from the Substrate Developer Hub repository, rather than from the core Substrate repository.
To compile the Substrate node template:
Clone the node template repository by running the following command:
In most cases, you can clone the
main
branch to get the latest code. However, you can use the--branch
command-line option if you want to work with a Substrate branch that is compatible with a specific Polkadot version. Click Tags to see the list of branches that are compatible with specific Polkadot versions.Change to the root of the node template directory by running the following command:
If you want to save your changes and make this branch easy to identify, you can create a new branch by running a command similar to the following:
Compile the node template by running the following command:
Because of the number of packages required, compiling the node can take several minutes.
After the build completes successfully, your local computer is ready for Substrate development activity.
Where to go next
The Substrate Developer Hub acts as a central portal for access to the many resources available to the community. Depending on your interests and learning style, you might prefer one avenue over another. For example, if you prefer to read source code and are familiar with Rust, you might want to start by digging into the Rust API.
Here are a few additional suggestions for where you can learn more.
Tell me
Guide me
Last updated