A bridge for protocols that can interact with Ethereum to begin interacting with Conflux without changing core code
Note: Cannot relay signed transactions from ETH to CFX, only unsigned information.
A relay to convert ETH JSON-RPC calls to CFX JSON-RPC calls.
Supports both HTTP and Websocket endpoints.
Project specs and notes:
- Conflux nodes use slightly different function calls that Ethereum JSON-RPC
- Using a JSON-RPC server as a relay
- https://www.npmjs.com/package/jayson#using-the-server-as-a-relay
- https://www.npmjs.com/package/jayson#method-routing
- Relay converts calls to ETH calls to CFX calls (pre-processing)
- Relay converts CFX responses to ETH responses (post-processing)
Commands
yarn start
: start up the relayyarn test
: start tests (make sure to also start relay)
.env
File Configuration:
ENDPOINT=http://test.confluxrpc.org
PORT=3000
- Methods are converted from
eth_*
tocfx_*
calls following the recommendations on the Conflux documentation. - The ETH block parameter is converted to the CFX epoch parameter.
- Certain methods that do not have complimentary
cfx_*
calls are custom built in the index.js under thecustomMethods()
function.
- Calls that involve getting block information (
getBlockByHash
,getBlockBy(Epoch)Number
) have CFX parameters mapped to ETH parameters as follows: (any hard coded values do not have comparable equivalents)ETH parameter CFX parameter sha3Uncles keccak256(Buffer.from(refereeHashes)) stateRoot deferredStateRoot receiptsRoot deferredReceiptsRoot gasUsed 0x0
extraData 0x0
(32 bytes)uncles []
number height - Calls involving transaction information (
getBlockByHash
,getBlockBy(Epoch)Number
,getTransactionByHash
) have CFX parameters mapped to ETH parameters as follows:ETH parameter CFX parameter input data blockNumber see code for details - Calls involving receipt data (
getTransactionReceipt
) have CFX parameters mapped to ETH parameters as follows:ETH parameter CFX parameter transactionIndex index cumulativeGasUsed gasUsed blockNumber epochNumber
- What other calls need to be converted/supported?
- Not all calls have test cases written
- Remove reliance on public node endpoint
- CFX JSON-RPC - Conflux Documentation
- ETH JSON-RPC - Ethereum Documentation
- Jayson - simple JSON-RPC server