This repository will serve dApp developers, interested in developing for Aleph Zero network, to boostrap their work. It will include:
nightly-2023-02-07
toolchain.substrate-contracts-node
version v0.26.0
.cargo-contract
version 3.0.1
.To install Rust, run:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
This will install rustup
, the Rust version and toolchain management tool. Next, use it to install Rust and the appropriate toolchain:
rustup install 1.69.0
rustup install nightly-2023-02-07-x86_64-unknown-linux-gnu
To install the substrate-contracts-node
, simply download it from the release page, unpack the archive and put the binary on your path (remember to reload the shell for this to take effect).
To install cargo contract, run:
cargo install --force --locked cargo-contract --version 3.0.1
You can verify your versions using:
rustup show
substrate-contracts-node --version
cargo contract --version
In the root directory of the project, run make chain-start
. To stop the chain, just exit the process in your terminal.
To clean the chain's run make chain-clean
. This will remove chain's database files (like blocks and contracts).
To restart the chain (and purge the state) run make chain-restart
.
By default, node will bind its websocket endpoint to port 9944. Make sure that the chain is running WS on port 9944. In the logs, look for:
2023-01-10 19:23:40.475 INFO main sc_rpc_server: Running JSON-RPC HTTP server: addr=127.0.0.1:9933, allowed origins=None
2023-01-10 19:23:40.475 INFO main sc_rpc_server: Running JSON-RPC WS server: addr=127.0.0.1:9944, allowed origins=None
If it bound to a different port your frontend instance will not connect properly - it tries to connect to the 9944 port. In that case, either make sure there are no other substrate-contracts-node
running (by killing them with make chain-stop
) or change the port in the frontend app.
In the /contracts
directory run make build-all
to build both contracts.
In the root directory, run make setup
. This will:
If you need to upload the contracts many times, you have two options:
make chain-restart
command, which will remove the old contracts,BULLETIN_BOARD_VERSION
variable to different two-digit numbers with each run, which will allow you to upload different instances of the same contract.Option 1 is the recommended one for most use cases.
In the /frontend
directory, run export REACT_APP_PROVIDER_URL=ws://localhost:9944 && npm start
. This should open a new tab in your default browser that connects to your local chain.
To sign transactions, we will be using the polkadot extension. Follow the instructions about how to install it in the official documentation.
substrate-contracts-node
ships with bunch of pre-funded accounts - we need to import them into the extension:
bottom drive obey lake curtain smoke basket hold race lonely fit walk
-- this it the seed for the default accounts. You can find it on https://docs.substrate.io/reference/command-line-tools/subkey/#subkey-generate-node-key .//Bob//stash
//Charlie//stash
//Dave//stash
//Eve//stash
//Ferdie//stash
Now, you can use the newly-added account with the example frontend.