Skip to content

Small proxy that proxies HTTP JSON RPC calls to Loomchain/EVM using LoomProvider under the hood

Notifications You must be signed in to change notification settings

loomnetwork/loom-provider-json-rpc-proxy

Repository files navigation

Loom Provider JSON RPC Proxy

Small service that proxies JSON RPC calls to the Loomchain/EVM

Running

yarn build
node .

Usage

yarn build; node .

The default configuration for this proxy will connect to PlasmaChain on wss://plasma.dappchains.com and serve the HTTP interface on port 8080, however those values can be tweaked by using environment variables as the following example:

yarn build;
PORT=80 CHAIN_ID="myChain" CHAIN_ENDPOINT="ws://localhost:46658" node .

Options:

  • PORT: It's the port of http for JSON RPC requests
  • CHAIN_ID: Configures the chain id name, each chain has an id, being default the default id
  • CHAIN_ENDPOINT: And finally the address of the loomchain endpoint

It's possible to debug calls by adding the env var DEBUG=loom-provider-json-rpc-proxy

Testing

curl -X POST --data '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}' localhost:8080 | jq

# Result should be like
# {
# "id": 1,
#  "jsonrpc": "2.0",
#  "result": "1578251"
# }
curl -v -X POST --data '{"jsonrpc":"2.0","method":"eth_getBlockByNumber","params":["0x1b4", true],"id":1}' localhost:8080 | jq

# Result should be like
# {
#   "id": 1,
#   "jsonrpc": "2.0",
#   "result": {
#     "blockNumber": "0x1b4",
#     "transactionHash": "0x0423774be3b040400f000b200b6d7ec948a0fe48bec232b5f196e2fdb2b20859",
#     "parentHash": "0x2f85af1a1dc4285510ef84204b4487bef28e2838a3e2f1dea3943bf71c063c28",
#     "logsBloom": "0x",
#     "timestamp": 1536307493,
#     "transactions": [],
#     "gasLimit": "0x0",
#     "gasUsed": "0x0",
#     "size": "0x0",
#     "number": "0x0"
#   }
# }

Dockerize

Another option is to use the Docker version by build the docker image and run like

Build an image

docker build -t loom-provider-json-rpc-proxy .

Then

docker run \
-p 8545:8545 \
-e DEBUG=loom-provider-json-rpc-proxy \
-e CHAIN_ID=mychain PORT=8545 \
-e CHAIN_ENDPOINT=ws://192.168.100.23:46658 \
loom-provider-json-rpc-proxy

Using with Remix

Also is possible to use Remix

The current provider do not supports Remix debug mechanism

Example of Remix usage

# Start a local Loomchain
loom init -f
loom run
# On a second terminal start this tool
yarn build;
PORT=8545 CHAIN_ENDPOINT="ws://localhost:46658" node .

On a web browser access the Remix, click on tab Run and select Web3 Provider on dropdown button Environment and set the host to http://localhost:8545 and now you can use Remix to develop and test your Solidity smart contracts on Loomchain

About

Small proxy that proxies HTTP JSON RPC calls to Loomchain/EVM using LoomProvider under the hood

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published