Parachain Setup
A guide showing how to setup a parachain on the Porta Relay Chain
Setup server on Digital Ocean
Minimum required specification: 2 GB Memory / 1 AMD vCPU / 50 GB Disk / LON1 - Ubuntu 20.04 (LTS) x64
Install dependencies
Open console
Enter the following command into the console:
sudo apt update && sudo apt upgrade && sudo apt install -y git clang curl libssl-dev llvm libudev-dev && curl https://getsubstrate.io -sSf | bash -s -- --fast
Add a volume
Volume > Create Volume
Configure:
  • Storage size
  • Droplet
  • Volume name
Click Create Volume
Build Pod
Open the server’s console and navigate to the volume storage. Download the pod and compile.
Run the following command:
cargo build--release
Purchase domain and transfer nameservers to Digital Ocean
Here is an example of purchasing the domain portaverse.co.uk through 1&1 and changing its name servers to Digital Ocean.
We shall be using portastation.co.uk as the domain in this tutorial.
Add DNS record to Digital Ocean
A parachain is both relay node and a collator node, do you must add one record to represent the collator node and another record to represent the relay node.
Networking > Domains > portastation.co.uk
Create a record called ‘collator.portaverse.co.uk’ pointed to the IP address of your parachain node.
Create another record called ‘relay.portaverse.co.uk’ pointed to the IP address of your parachain node.
Setup Certificate
Enter the following command in the console:
sudo apt-get install nginx && sudo snap install core && sudo snap refresh core && sudo apt-get remove certbot && sudo snap install --classic certbot && sudo ln -s /snap/bin/certbot /usr/bin/certbot && sudo certbot –nginx
Enter:
  • Contact email address
  • Relay and Collator FQDN’s
Configure Nginx server block
My preferred method for doing this is accessing the server using FileZilla.
  • 9944 and 443 for relay
  • 9945 and 4433 for collator
cd .. && nano /etc/nginx/sites-available/default
File should be this:
server {
root /var/www/html;
index index.html index.htm index.nginx-debian.html;
server_name relay.portastation.co.uk; # managed by Certbot
location / {
try_files $uri $uri/ =404;
proxy_buffering off;
proxy_pass http://localhost:9944;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
listen [::]:443 ssl; # managed by Certbot
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/relay.portastation.co.uk/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/relay.portastation.co.uk/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
server {
if ($host = relay.portastation.co.uk) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80 ;
listen [::]:80 ;
server_name relay.portastation.co.uk;
return 404; # managed by Certbot
}
server {
root /var/www/html;
index index.html index.htm index.nginx-debian.html;
server_name collator.portastation.co.uk; # managed by Certbot
location / {
try_files $uri $uri/ =404;
proxy_buffering off;
proxy_pass http://localhost:9945;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
listen [::]:4433 ssl; # managed by Certbot
listen 4433 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/collator.portastation.co.uk/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/collator.portastation.co.uk/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
server {
if ($host = collator.portastation.co.uk) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80 ;
listen [::]:80 ;
server_name collator.portastation.co.uk;
return 404; # managed by Certbot
}
Restart nginx
sudo systemctl restart nginx
Register Parachain ID
Access relay chain UI: Open Polkadot-UI and navigate to the following custom network:
wss://station.porta.network:443
Network > Parachain > Parathreads
Click: ParaId
Make a note of the para_id and click Submit
Our example will use para_id 2001
Generate chain_spec
./target/release/parachain-collator build-spec --disable-default-bootnode --chain local > parachain-chainspec.json
Generate two sr25519 encryption keys
Enterthe following command in the console:
subkey generate --scheme sr25519
Adapt chain_spec to reference
  • para_id 2009
  • Porta NFT Testnet
  • ProtocolId
  • Properties
  • Custom sudo key
  • Custom aura key x2
  • Custom balances x2
Build the raw chain_spec
Enter the following command:
./target/release/parachain-collator build-spec --chain=parachain-chainspec.json --raw --disable-default-bootnode > parachain-chainspec-raw.json
Generate Parachain Genesis State
./target/release/parachain-collator export-genesis-state --chain parachain-chainspec.json > parachain-genesis
Generate WASM Runtime Validation Function
./target/release/parachain-collator export-genesis-wasm --chain parachain-chainspec.json > parachain-wasm
Move the raw chain_spec used for Relay Nodes (porta-raw.json) to the ./pod directory
Start the Collator Node
./target/release/parachain-collator --name nft --collator --force-authoring --base-path ./data/parachain-demo --port 30000 --ws-port 9945 --rpc-port 9933 --rpc-external --rpc-cors all --rpc-methods=unsafe --chain parachain-chainspec-raw.json -- --execution wasm --chain ./porta-raw.json --port 30001 --ws-port 9944 --bootnodes /ip4/64.227.45.184/tcp/30001/p2p/12D3KooWDGgqoUNZKNmwJL48eRoS59KZT7JyBL5ne7G59cGMjjrF --rpc-port 9934 --rpc-external --rpc-cors all --rpc-methods=unsafe
Wait for the node to synchronise blocks...
Create a parathread
Network > Parachain > Parathread
Once the instantiation lifecycle completes, the parathread will have been created
To upgrade the parathread to a parachain you must call paraSudoWrapper.sudoScheduleParathreadUpgrade()
Parachain will then begin the countdown to upgrade
The wait time will be: the time remaining in this epoch + one whole epoch
Add custom aura keys to the parachain node
Access the node:
Navigate to Developer > RPC Calls
Author > insertKey()
Insert both the sr25519 keys you previously generated
  • aura
  • 12-word mnemonic
  • Public key (hex)
Proof of Validity will now begin. The parachain will now author blocks (#best) and having them finalised by the relay chain (#finalised).
The parachain is now working.
Copy link