This server acts as a bridge for systems to communicate with Polkadot's WSS endpoints using the pure PolkadotJS API functionality, allowing seamless interaction without the need for native support.
The polkadotjs-proxy enables communication to the RPC proxy on the specified port. Example JSON command can be found below:
{
"type": "query",
"namespace": "system",
"method": "account",
"params": ["5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty"],
"network": "wss://rpc.ibp.network/kusama",
"blockHash": "0xabc123"
}(Note: Please remove the extra backslashes \ before the backticks around the JSON code block.)
The type, namespace, method, params, network, and blockHash are input variables. This proxy facilitates queries and interactions with the Polkadot nodes.
- Node.js
- Express
- @polkadot/api
- Ensure you have Node.js installed.
- Install the necessary npm packages:
npm install- Run the server using the
server.jsfile:
node server.js-
Launch using systemd:
- Create a systemd service file, e.g.,
/etc/systemd/system/polkadotjs-proxy.service:
- Create a systemd service file, e.g.,
[Unit]
Description=PolkadotJS Proxy Server
[Service]
ExecStart=/usr/bin/node /path/to/your/server.js
Restart=always
User=your_username
Group=your_group
Environment=PATH=/usr/bin:/usr/local/bin
WorkingDirectory=/path/to/your/directory
[Install]
WantedBy=multi-user.target- Reload systemd:
sudo systemctl daemon-reload- Start the service:
sudo systemctl start polkadotjs-proxy- (Optional) Enable on boot:
sudo systemctl enable polkadotjs-proxyNote: Replace /path/to/your/ with the actual path to your server.js file and adjust User and Group as necessary.