Porta Docs
Search…
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:
1
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
Copied!
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:
1
cargo build--release
Copied!
​
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:
1
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
Copied!
​
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
1
cd .. && nano /etc/nginx/sites-available/default
Copied!
​
File should be this:
1
server {
2
root /var/www/html;
3
index index.html index.htm index.nginx-debian.html;
4
server_name relay.portastation.co.uk; # managed by Certbot
5
6
location / {
7
try_files $uri $uri/ =404;
8
proxy_buffering off;
9
proxy_pass http://localhost:9944;
10
proxy_set_header X-Real-IP $remote_addr;
11
proxy_set_header Host $host;
12
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
13
proxy_http_version 1.1;
14
proxy_set_header Upgrade $http_upgrade;
15
proxy_set_header Connection "upgrade";
16
}
17
18
listen [::]:443 ssl; # managed by Certbot
19
listen 443 ssl; # managed by Certbot
20
ssl_certificate /etc/letsencrypt/live/relay.portastation.co.uk/fullchain.pem; # managed by Certbot
21
ssl_certificate_key /etc/letsencrypt/live/relay.portastation.co.uk/privkey.pem; # managed by Certbot
22
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
23
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
24
}
25
server {
26
if ($host = relay.portastation.co.uk) {
27
return 301 https://$host$request_uri;
28
} # managed by Certbot
29
30
listen 80 ;
31
listen [::]:80 ;
32
server_name relay.portastation.co.uk;
33
return 404; # managed by Certbot
34
}
35
server {
36
root /var/www/html;
37
index index.html index.htm index.nginx-debian.html;
38
server_name collator.portastation.co.uk; # managed by Certbot
39
40
location / {
41
try_files $uri $uri/ =404;
42
proxy_buffering off;
43
proxy_pass http://localhost:9945;
44
proxy_set_header X-Real-IP $remote_addr;
45
proxy_set_header Host $host;
46
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
47
proxy_http_version 1.1;
48
proxy_set_header Upgrade $http_upgrade;
49
proxy_set_header Connection "upgrade";
50
}
51
52
listen [::]:4433 ssl; # managed by Certbot
53
listen 4433 ssl; # managed by Certbot
54
ssl_certificate /etc/letsencrypt/live/collator.portastation.co.uk/fullchain.pem; # managed by Certbot
55
ssl_certificate_key /etc/letsencrypt/live/collator.portastation.co.uk/privkey.pem; # managed by Certbot
56
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
57
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
58
}
59
server {
60
if ($host = collator.portastation.co.uk) {
61
return 301 https://$host$request_uri;
62
} # managed by Certbot
63
64
listen 80 ;
65
listen [::]:80 ;
66
server_name collator.portastation.co.uk;
67
return 404; # managed by Certbot
68
}
Copied!
​
Restart nginx
1
sudo systemctl restart nginx
Copied!
​
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
1
./target/release/parachain-collator build-spec --disable-default-bootnode --chain local > parachain-chainspec.json
Copied!
Generate two sr25519 encryption keys
Enterthe following command in the console:
1
subkey generate --scheme sr25519
Copied!
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:
1
./target/release/parachain-collator build-spec --chain=parachain-chainspec.json --raw --disable-default-bootnode > parachain-chainspec-raw.json
Copied!
​
Generate Parachain Genesis State
1
./target/release/parachain-collator export-genesis-state --chain parachain-chainspec.json > parachain-genesis
Copied!
​
Generate WASM Runtime Validation Function
1
./target/release/parachain-collator export-genesis-wasm --chain parachain-chainspec.json > parachain-wasm
Copied!
​
Move the raw chain_spec used for Relay Nodes (porta-raw.json) to the ./pod directory
​
Start the Collator Node
1
./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
Copied!
​
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