Startup Script

Use the startup script below to bypass manual configuration when starting your Gateway.

Follow the steps below to modify the script to suit your specific configuration and needs. Once initiated, the script will create a Docker container named bxgateway-go that will running in the background, setting up your Local Gateway.

  1. Modify the startup command below to include your gateway's enode and multiaddr

./run_gateway.sh /home/ubuntu/gw/ssl \
                 /home/ubuntu/gw/logs \
                 /home/ubuntu/gw/datadir \
                 Mainnet \
                 enode://123..abc@127.0.0.1:30303 \
                 multiaddr:/ip4/<IP_address>/tcp/<port>/p2p/<Peer_ID>
  1. Specify input arguments at the beginning of the script below

    • CERT_PATH: Your SSL certificates from the portal. This should be a path to the parent directory of the external_gateway folder. The external_gateway folder should contain a registration_only folder with certs inside.

    • LOGS_PATH: Where you want a logs folder to be created with a gateway.log file inside

    • DATADIR_PATH: The directory for storing various persistent files such as gateway private key file

    • BLOCKCHAIN_NETWORK: Available options are Mainnet (for Ethereum), BSC-Mainnet, Polygon-Mainnet

    • ENODES: Local blockchain node (Enterprise clients must start the gateway with local node connection.)

    • MULTIADDR: multiaddr has replaced enr as the argument to indicate the node address because it is human-readable. It has the following format: /ip4/<IPv4_NETWORK_ADDRESS>/tcp/<LISTENING_PORT>/p2p/<NODE_ID>

  2. Copy the script to an executable file (example below)

  3. Run the run_gateway.sh command from step 1

#usr/bin/env bash

CERT_PATH=${1:-/home/ec2-user/ssl}
LOGS_PATH=${2:-/home/ec2-user/logs}
DATADIR_PATH=${3:-/home/ec2-user/datadir}
BLOCKCHAIN_NETWORK=${4:-"Mainnet"}  
ENODES=${5:-""}
MULTIADDR=${6:-""}

LOG_LEVEL="info"
LOG_FILE_LEVEL="debug"
IMAGE_TAG="latest"
EXTERNAL_IP=""

CA_CERT_URL="https://s3.amazonaws.com/credentials.blxrbdn.com/ca/ca_cert.pem"
mkdir -p "$CERT_PATH"/external_gateway/ca
curl $CA_CERT_URL -o "$CERT_PATH"/external_gateway/ca/ca_cert.pem

ARGS="--ws --port 1801"
if [[ "${EXTERNAL_IP}" != "" ]]; then
  ARGS="${ARGS} --external-ip ${EXTERNAL_IP}"
fi

if [[ "${LOG_LEVEL}" != "" ]]; then
  ARGS="${ARGS} --log-level ${LOG_LEVEL}"
fi

if [[ "${LOG_FILE_LEVEL}" != "" ]]; then
   ARGS="${ARGS} --log-file-level ${LOG_FILE_LEVEL}"
fi

if [[ "${ENODES}" != "" ]]; then
  ARGS="${ARGS} --enodes ${ENODES}"
fi

if [[ ${MULTIADDR} != "" ]]; then
  ARGS="${ARGS} --multiaddr ${MULTIADDR}"
fi

if [[ ${BLOCKCHAIN_NETWORK} == "Mainnet" && "${MULTIADDR}" != "" ]]; then
  ARGS="${ARGS} --multiaddr ${MULTIADDR}"
fi


ARGS="${ARGS} --blockchain-network ${BLOCKCHAIN_NETWORK}"

docker pull bloxroute/bloxroute-gateway-go:$IMAGE_TAG
docker rm -f bxgateway-go
docker run --name bxgateway-go --restart=on-failure -d -v "$LOGS_PATH":/app/bloxroute/logs \
  -v "$CERT_PATH":/app/bloxroute/ssl -v "$DATADIR_PATH":/app/bloxroute/datadir \
  -p 1801:1801 -p 127.0.0.1:6060:6060 \
  -p 28333:28333 bloxroute/bloxroute-gateway-go:$IMAGE_TAG "$ARGS"

Note that WebSockets are accessible at ws://localhost:28333/ws. To test it, you can use wscat -c ws://localhost:28333/ws -H "Authorization:<your auth header here>"

Last updated