- For use with Blocknet's XRouter Proxy Container (https://hub.docker.com/r/blocknetdx/xrouterproxy/)
- Parity or Geth Ethereum Node
- Archival node is preferred
- If full node is used some calls will not work
- Infura support is available
- Docker installed
- Blocknet Service Node
blocknet.confrequiresrpcallowip=0.0.0.0/0or specifying individual subnets if 0.0.0.0/0 is too open
- Open port 9090 or whichever port is exposed on the XRouter Proxy container
-
Download .zip or use Git (https://github.com/Aderks/ethereum-webserver.git)
- Extract locally
- Directory structure:
Dockerfile, ethereum.py, requirements.txt, start.sh
-
Open a CLI and change directory to where
ethereum-webserveris located -
Build image:
- If Ethereum RPC endpoint is localhost:
docker build --build-arg cores=8 -t ethereum-webserver . - If Ethereum RPC endpoint is not localhost:
docker build --build-arg cores=8 --build-arg url=http://[ip]:[port] -t ethereum-webserver . - If Ethereum RPC endpoint is Infura:
docker build --build-arg cores=8 --build-arg url=https://mainnet.infura.io/v3/<api_key> -t ethereum-webserver-test .- Change
--build-arg cores=to adjust # of processes
- Change
- If Ethereum RPC endpoint is localhost:
-
Run etherum-webserver container:
docker run -d --name ethereum-webserver -p 8191:8191 ethereum-webserver:latest- To change the Ethereum RPC endpoint, add
-e eurl=http://[ip]:[port]to the Docker run command
- To change the Ethereum RPC endpoint, add
-
Quick commands:
- Start container:
docker start ethereum-webserver - Stop container:
docker stop ethereum-webserver - View logs:
docker logs ethereum-webserver - Tail logs:
docker logs -f ethereum-webserver - Gain access inside container:
docker exec -it ethereum-webserver /bin/bash
- Start container:
-
Download xrouterproxy image:
docker pull blocknetdx/xrouterproxy:0.3.3(or latest tag) -
Create xrproxy container config
uwsgi.iniand place in a directory that can be shared with the blocknetdx/xrouterproxy docker container- Edit config template
xrproxy_uwsgi.inifrom this repo to your local settings- Set
SERVICENODE_PRIVKEY=(retrieve fromservicenodestatus) - Set
URL_CustomXCloudPlugin_HOSTIP=&URL_CustomXCloudPlugin_PORT=to your local settings
- Set
- Rename xrproxy_uwsgi.ini to
uwsgi.ini
- Edit config template
-
Run xrouterproxy container:
docker run -d --name xrproxy -p 9090:80 -v=/location/of/uwsgi/config/file/directory:/opt/uwsgi/conf blocknetdx/xrouterproxy:0.3.3 -
Quick Commands:
- Start container:
docker start xrproxy - Stop container:
docker stop xrproxy
- Start container:
-
cURL examples:
-
curl -H "Accept: application/json" -H "Content-Type: application/json" -d '["0xc94770007dda54cF92009BFF0dE90c06F603a09f","latest"]' 127.0.0.1:9090/xrs/eth_getBalance -
curl -H "Accept: application/json" -H "Content-Type: application/json" -d '[]' 127.0.0.1:9090/xrs/eth_blockNumber -
curl -H "Accept: application/json" -H "Content-Type: application/json" -d '[]' [public_server_ip]:9090/xrs/eth_blockNumber- This will only work if port 9090 is open, and Blocknet
rpcallowip=is set accordingly
- This will only work if port 9090 is open, and Blocknet
-
Recommended for developmental use only
-
Download .zip or use Git (https://github.com/Aderks/ethereum-webserver.git)
- Extract locally
-
Edit
ethereum.pyand changeurl = os.environ['eurl']tourl = 'http://[ip]:[port]'(Your Ethereum RPC endpoint)- Infura support:
url = 'https://mainnet.infura.io/v3/<api_key>'
- Infura support:
-
Install required dependencies:
pip install -r requirements.txt -
Run
ethereum.pyto start the Flask Web Server -
cURL example:
curl -H "Accept: application/json" -H "Content-Type: application/json" -d '[]' 127.0.0.1:8191/xrs/eth_blockNumber
To Do:
- ETH calls:
eth_getLogs,eth_subscribe,parity_subscribe - Optional parameters:
eth_call,eth_estimateGas,eth_getLogs,eth_newFilter - XR payments