### Setup Project for Polkadot.js Runtime API Example
Source: https://docs.polkadot.com/ai/categories/polkadot-protocol.md
Commands to set up a new Node.js project for the Polkadot.js runtime API example, including initializing the project and installing the necessary dependency.
```bash
mkdir pjs-runtime-api-example && cd pjs-runtime-api-example &&
npm init -y && npm pkg set type=module
```
```bash
npm install @polkadot/api
```
--------------------------------
### Setup Project for PAPI Runtime API Example
Source: https://docs.polkadot.com/ai/categories/polkadot-protocol.md
Commands to set up a new Node.js project for the PAPI runtime API example, including initializing the project, installing dependencies, and generating types.
```bash
mkdir papi-runtime-api-example && cd papi-runtime-api-example &&
npm init -y && npm pkg set type=module
```
```bash
npm install polkadot-api &&
npm install --save-dev @types/node tsx typescript
```
```bash
npx papi add polkadotTestNet -w wss://asset-hub-paseo.dotters.network
```
--------------------------------
### Clone and Navigate to dApp Repository
Source: https://docs.polkadot.com/smart-contracts/cookbook/dapps/zero-to-hero.md
Clone the example repository and navigate to the dApp directory to get started with a working example.
```bash
git clone https://github.com/polkadot-developers/revm-hardhat-examples.git
cd zero-to-hero-dapp
```
--------------------------------
### Setup Subxt Project
Source: https://docs.polkadot.com/ai/categories/chain-interactions.md
Commands to initialize a Rust project, install the Subxt CLI, and download network metadata.
```bash
cargo new subxt-query-account-example && cd subxt-query-account-example
```
```bash
cargo install subxt-cli@0.50.0
```
```bash
subxt metadata --url INSERT_WS_ENDPOINT -o polkadot_testnet_metadata.scale
```
--------------------------------
### Automate Environment Setup
Source: https://docs.polkadot.com/reference/tools/pop-cli.md
Use the interactive installer to check and install all necessary dependencies for Polkadot SDK development.
```bash
pop install
```
--------------------------------
### Setup Project for Polkadot-API
Source: https://docs.polkadot.com/ai/categories/chain-interactions.md
Initialize a new Node.js project and install necessary dependencies for using polkadot-api, including TypeScript support.
```bash
mkdir papi-query-example && cd papi-query-example &&
npm init -y && npm pkg set type=module
```
```bash
npm install polkadot-api &&
npm install --save-dev @types/node tsx typescript
```
```bash
npx papi add pah -n polkadot_asset_hub
```
--------------------------------
### Clone and Install Project Dependencies
Source: https://docs.polkadot.com/smart-contracts/cookbook/smart-contracts/deploy-erc20/erc20-hardhat.md
Initialize the project by cloning the repository and installing required Node.js packages.
```bash
git clone https://github.com/polkadot-developers/revm-hardhat-examples/
cd revm-hardhat-examples/erc20-hardhat
```
```bash
npm i
```
--------------------------------
### Install Web3.py Library
Source: https://docs.polkadot.com/smart-contracts/libraries/web3-py.md
Install the Web3.py library using pip to enable blockchain interactions.
```bash
pip install web3
```
--------------------------------
### Verify Pop CLI Installation
Source: https://docs.polkadot.com/reference/tools/pop-cli.md
Check that the CLI is installed correctly by displaying the help menu.
```bash
pop --help
```
--------------------------------
### Download and install new binary
Source: https://docs.polkadot.com/ai/categories/infrastructure.md
Commands to download, set permissions, and install the new parachain binary.
```bash
wget https://github.com/paritytech/polkadot-sdk/releases/download/INSERT_NEW_VERSION/polkadot-parachain
chmod +x polkadot-parachain
sudo mv polkadot-parachain /usr/local/bin/
```
--------------------------------
### Initialize Project and Install Dependencies
Source: https://docs.polkadot.com/smart-contracts/libraries/web3-js.md
Commands to create the project directory and install the necessary Web3.js and Solidity compiler packages.
```bash
mkdir web3js-project
cd web3js-project
npm init -y
```
```bash
npm install web3
```
```bash
npm install --save-dev solc
```
--------------------------------
### Initialize Project and Install Dependencies
Source: https://docs.polkadot.com/ai/categories/chain-interactions.md
Set up a new Node.js project and install the necessary Polkadot API packages and development tools.
```bash
mkdir papi-query-account-example && cd papi-query-account-example && \
npm init -y && npm pkg set type=module
```
```bash
npm install polkadot-api && \
npm install --save-dev @types/node tsx typescript
```
--------------------------------
### Install Moonsong Labs XCM Tools
Source: https://docs.polkadot.com/reference/tools/xcm-tools.md
Clone the Moonsong Labs XCM Tools repository and install its dependencies using yarn. This setup is required to use their collection of scripts for managing and testing XCM operations.
```bash
git clone https://github.com/Moonsong-Labs/xcm-tools &&
cd xcm-tools &&
yarn install
```
--------------------------------
### Initialize Project
Source: https://docs.polkadot.com/smart-contracts/libraries/ethers-js.md
Commands to create a new project directory and initialize a package.json file.
```bash
mkdir ethers-project
cd ethers-project
npm init -y
```
--------------------------------
### Setup Rust Project for Account Creation
Source: https://docs.polkadot.com/ai/categories/basics.md
Commands to initialize a Rust project and configure dependencies.
```bash
cargo new account-creator-rust
cd account-creator-rust
```
```toml
[package]
name = "account-creator-rust"
version = "0.1.0"
edition = "2021"
[dependencies]
sp-core = "28.0"
sp-runtime = "31.0"
```
--------------------------------
### Get Balance Example
Source: https://docs.polkadot.com/smart-contracts/precompiles/erc20.md
Shows how to retrieve the token balance for a specific account address using the ERC20 precompile.
```solidity
IERC20 token = IERC20(0x000007C000000000000000000000000001200000);\naddress user = 0x1234567890123456789012345678901234567890;\nuint256 balance = token.balanceOf(user);
```
--------------------------------
### Get Total Supply Example
Source: https://docs.polkadot.com/smart-contracts/precompiles/erc20.md
Demonstrates how to query the total number of tokens in circulation for an ERC20 asset using the precompile.
```solidity
IERC20 token = IERC20(0x000007C000000000000000000000000001200000);\nuint256 supply = token.totalSupply();
```
--------------------------------
### Initialize Project Directory
Source: https://docs.polkadot.com/smart-contracts/cookbook/dapps/zero-to-hero.md
Commands to create the root project folder and navigate into it.
```bash
mkdir polkadot-hub-tutorial
cd polkadot-hub-tutorial
```
--------------------------------
### Chopsticks RPC Listening Output
Source: https://docs.polkadot.com/reference/tools/chopsticks.md
Example output indicating that the Chopsticks RPC server has successfully started and is listening on a specific port. This confirms the fork is running and accessible.
```bash
[19:12:21.023] INFO: Polkadot RPC listening on port 8000
```
--------------------------------
### Initialize React Project
Source: https://docs.polkadot.com/smart-contracts/libraries/wagmi.md
Commands to create a new Next.js project and navigate into the directory.
```bash
npx create-next-app@latest wagmi-polkadot-hub
cd wagmi-polkadot-hub
```
--------------------------------
### Chopsticks Forked Chain Startup Output
Source: https://docs.polkadot.com/ai/categories/interoperability.md
Example output showing Chopsticks starting the forked chains, including RPC endpoints and connected parachains. Runtime logs will be visible.
```text
npx @acala-network/chopsticks xcm \ -r polkadot \ -p configs/polkadot-asset-hub-override.yaml \ -p acala
[09:29:14.988] INFO: Polkadot Asset Hub RPC listening on http://[::]:8000 and ws://[::]:8000
[09:29:14.988] INFO: Loading config file https://raw.githubusercontent.com/AcalaNetwork/chopsticks/master/configs/acala.yml
[09:29:15.984] INFO: Acala RPC listening on http://[::]:8001 and ws://[::]:8001
[09:29:15.990] INFO (xcm): Connected parachains [1000,2000]
[09:29:15.990] INFO: Loading config file https://raw.githubusercontent.com/AcalaNetwork/chopsticks/master/configs/polkadot.yml
[09:29:16.927] INFO: Polkadot RPC listening on http://[::]:8002 and ws://[::]:8002
[09:29:16.984] INFO (xcm): Connected relaychain 'Polkadot' with parachain 'Polkadot Asset Hub'
[09:29:17.028] INFO (xcm): Connected relaychain 'Polkadot' with parachain 'Acala'
```
--------------------------------
### Initialize viem Project
Source: https://docs.polkadot.com/smart-contracts/libraries/viem.md
Initialize a new project folder and set up the basic npm project structure.
```bash
mkdir viem-project
cd viem-project
npm init -y
```
--------------------------------
### Start Sidecar with Remote Node
Source: https://docs.polkadot.com/reference/tools/sidecar.md
Connect Sidecar to a remote node by specifying the RPC endpoint using the SAS_SUBSTRATE_URL environment variable. This example connects to the Polkadot Asset Hub.
```bash
SAS_SUBSTRATE_URL=wss://polkadot-asset-hub-rpc.polkadot.io substrate-api-sidecar
```
--------------------------------
### Initialize Python Project
Source: https://docs.polkadot.com/ai/categories/polkadot-protocol.md
Commands to set up a virtual environment for Python development.
```bash
mkdir account-creator-python
cd account-creator-python
python3 -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
```
--------------------------------
### Polkadot Startup with Error for Missing Node Key
Source: https://docs.polkadot.com/ai/categories/infrastructure.md
This example shows the error message encountered when starting a Polkadot validator without a stable network key. It outlines methods for generating a key.
```bash
polkadot --validator --name "INSERT_NAME_FROM_TELEMETRY"
```
--------------------------------
### Start the ETH-RPC adapter
Source: https://docs.polkadot.com/smart-contracts/dev-environments/local-dev-node.md
Launches the adapter to translate Ethereum JSON-RPC calls into Substrate-compatible requests.
```bash
./target/release/eth-rpc --dev
```
--------------------------------
### Initialize Moonwall Configuration Wizard
Source: https://docs.polkadot.com/reference/tools/moonwall.md
Use the `moonwall init` command to start an interactive wizard for creating your Moonwall configuration file. This wizard guides you through setting up essential parameters like label, timeout, environment name, network foundation, and test directory.
```bash
moonwall init
```
--------------------------------
### Install and Configure Rust
Source: https://docs.polkadot.com/ai/categories/chain-interactions.md
Commands to install the Rust toolchain, configure the environment, and verify the installation.
```bash
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
```
```bash
source ~/.cargo/env
```
```bash
rustc --version
```
```bash
rustup default stable
rustup update
rustup target add wasm32-unknown-unknown
rustup component add rust-src
```
--------------------------------
### Initialize PAPI Project
Source: https://docs.polkadot.com/ai/categories/chain-interactions.md
Commands to set up a new Node.js project for PAPI development.
```bash
mkdir papi-send-tx-example && cd papi-send-tx-example && \
npm init -y && npm pkg set type=module
```
```bash
npm install polkadot-api @polkadot/util-crypto @polkadot/keyring && \
npm install --save-dev @types/node tsx typescript
```
```bash
npx papi add polkadotTestNet -w wss://asset-hub-paseo.dotters.network
```
--------------------------------
### Install viem and Solidity Compiler
Source: https://docs.polkadot.com/smart-contracts/libraries/viem.md
Install viem for blockchain interaction and solc for compiling Solidity smart contracts.
```bash
# Install viem and resolc
npm install viem solc
# Install TypeScript and development dependencies
npm install --save-dev typescript ts-node @types/node
```
--------------------------------
### Install Polkadot using APT Package Manager
Source: https://docs.polkadot.com/ai/categories/infrastructure
Installs Polkadot binaries on Debian-based systems (like Ubuntu) by adding the official repository and installing the necessary packages. Requires root privileges. Imports GPG key, adds repository, updates package index, installs parity-keyring, and finally installs polkadot.
```bash
# Import the release-team@parity.io GPG key
gpg --keyserver hkps://keyserver.ubuntu.com --receive-keys 90BD75EBBB8E95CB3DA6078F94A4029AB4B35DAE
gpg --export 90BD75EBBB8E95CB3DA6078F94A4029AB4B35DAE > /usr/share/keyrings/parity.gpg
# Add the Parity repository and update the package index
echo 'deb [signed-by=/usr/share/keyrings/parity.gpg] https://releases.parity.io/deb release main' > /etc/apt/sources.list.d/parity.list
apt update
# Install the `parity-keyring` package - This will ensure the GPG key
# used by APT remains up-to-date
apt install parity-keyring
# Install polkadot
apt install polkadot
```
--------------------------------
### Verify Sidecar Installation
Source: https://docs.polkadot.com/reference/tools/sidecar.md
Confirm that the Substrate API Sidecar has been installed correctly by checking its version. This command verifies the global installation.
```bash
substrate-api-sidecar --version
```
--------------------------------
### Setup Native Binaries
Source: https://docs.polkadot.com/reference/tools/zombienet.md
Download and configure the required Polkadot binaries for the native provider.
```bash
zombienet setup polkadot polkadot-parachain
```
```bash
export PATH=$PATH:INSERT_PATH_TO_BINARY
```
--------------------------------
### Set Up Hardhat Project
Source: https://docs.polkadot.com/ai/site-index.json
Initializes a new Hardhat project for smart contract development. Ensure you have Node.js and npm installed.
```bash
npm init --yes
npm install --save-dev "@nomicfoundation/hardhat-toolbox" "hardhat" "ethers" "@ethersproject/contracts"
```
--------------------------------
### Start and Enable Polkadot Collator Systemd Service (Bash)
Source: https://docs.polkadot.com/ai/categories/infrastructure.md
Commands to reload systemd, enable the collator service to start on boot, and start it immediately.
```bash
sudo systemctl daemon-reload
sudo systemctl enable polkadot-collator
sudo systemctl start polkadot-collator
```
--------------------------------
### Initialize Project and Install Dependencies
Source: https://docs.polkadot.com/ai/categories/infrastructure.md
Sets up a new project directory and installs the necessary Polkadot.js packages and development tools for TypeScript.
```bash
mkdir account-creator
cd account-creator
npm init -y && npm pkg set type=module
```
```bash
npm install @polkadot/util-crypto @polkadot/keyring
npm install --save-dev typescript tsx
```
--------------------------------
### Install Rust Toolchain on macOS
Source: https://docs.polkadot.com/ai/categories/smart-contracts.md
Downloads and installs the Rust toolchain using rustup, configuring it for development. This involves running the installer script and sourcing the environment.
```bash
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
```
```bash
source ~/.cargo/env
```
--------------------------------
### Initialize Project Directory
Source: https://docs.polkadot.com/smart-contracts/libraries/web3-py.md
Create and navigate into a new project directory for your Web3.py application.
```bash
mkdir web3py-project
cd web3py-project
```
--------------------------------
### Install Polkadot.js API Dependency
Source: https://docs.polkadot.com/ai/categories/chain-interactions.md
Install the Polkadot.js API library for your project.
```bash
npm install @polkadot/api@16.5.4
```
--------------------------------
### Install PAPI dependencies
Source: https://docs.polkadot.com/ai/categories/chain-interactions.md
Install the required Polkadot-API package and development tools.
```bash
npm install polkadot-api
npm install --save-dev typescript tsx
```
--------------------------------
### Initialize Hardhat Project
Source: https://docs.polkadot.com/smart-contracts/cookbook/dapps/zero-to-hero.md
Commands to create the contract directory, initialize npm, and install Hardhat.
```bash
mkdir storage-contract
cd storage-contract
npm init -y
```
```bash
npm install --save-dev hardhat@3.0.9
```
```bash
npx hardhat --init
```
--------------------------------
### Install DApp Dependencies
Source: https://docs.polkadot.com/smart-contracts/cookbook/dapps/zero-to-hero.md
Install viem and necessary TypeScript development dependencies.
```bash
npm install viem@2.38.5
npm install --save-dev typescript@5.9.3 @types/node@22.19.24
```
--------------------------------
### Set up Imports and Utilities for Deployment Script
Source: https://docs.polkadot.com/smart-contracts/libraries/web3-js.md
Initializes necessary file system operations and Web3.js for contract deployment. Ensure these modules are installed in your project.
```javascript
const { writeFileSync, existsSync, readFileSync } = require('fs');
const { join } = require('path');
const { Web3 } = require('web3');
const scriptsDir = __dirname;
const abisDir = join(__dirname, '../abis');
const artifactsDir = join(__dirname, '../artifacts');
```
--------------------------------
### Install Hardhat Polkadot Plugin
Source: https://docs.polkadot.com/smart-contracts/dev-environments/hardhat-polkadot.md
Install the required Polkadot plugin for Hardhat.
```bash
npm install --save-dev @parity/hardhat-polkadot@0.2.7
```
--------------------------------
### Initialize PAPI Project Directory
Source: https://docs.polkadot.com/ai/categories/chain-interactions.md
Create and navigate into a new directory for your PAPI project.
```bash
mkdir fee-payment-tutorial && cd fee-payment-tutorial
```
--------------------------------
### Configure Environment Variables
Source: https://docs.polkadot.com/ai/categories/smart-contracts.md
Example content for the .env file to store private keys.
```text
LOCAL_PRIV_KEY="INSERT_LOCAL_PRIVATE_KEY"
AH_PRIV_KEY="INSERT_AH_PRIVATE_KEY"
```