5.5.2 Conflux
On this page:
CFX_  NODE_  URI
CFX_  NETWORK_  ID
5.5.2.1 FAQ
5.5.2.1.1 How do I run my Reach DApp on CFX Test  Net or Main  Net?
5.5.2.1.2 Why is DApp startup very slow? Why do I need to use set  Query  Lower  Bound?
5.5.2.1.3 How can I use Conflux  Portal with the Reach devnet?
5.5.2 Conflux

The Conflux Reach connector works almost identically to the Ethereum connector, except that it behaves differently at runtime: using, for example, Conflux Portal rather than MetaMask, and connecting to Conflux nodes.

Backends must respect the following environment variables:

5.5.2.1 FAQ
5.5.2.1.1 How do I run my Reach DApp on CFX TestNet or MainNet?

You can add the following JavaScript near the beginning of your index.js or index.mjs file in order to run on Conflux TestNet:

reach.setProviderByName('TestNet');

Or this to run on Conflux MainNet:

reach.setProviderByName('MainNet');

It is strongly recommended that you also use setQueryLowerBound to avoid waiting for unnecessary queries. For example, this code snippet sets the lower bound at 2000 blocks ago:

const now = await reach.getNetworkTime();
reach.setQueryLowerBound(reach.sub(now, 2000));

5.5.2.1.2 Why is DApp startup very slow? Why do I need to use setQueryLowerBound?

DApp startup doesn’t have to be slow. Reach relies on querying Conflux event logs in order to run the DApp. The Conflux network does not yet provide fast APIs for querying event logs for a given contract across all time, so instead, Reach incrementally queries across chunks of 1000 blocks at a time. You can use setQueryLowerBound to help Reach know at what block number to start querying, so that it does not have to start querying at the beginning of time, which can take quite a while.

5.5.2.1.3 How can I use ConfluxPortal with the Reach devnet?

If you find that ConfluxPortal’s Localhost 12537 default configuration does not work correctly with Reach apps, you can try configuring ConfluxPortal to use a custom RPC endpoint:

If your locally-running Conflux devnet restarts, you may find that you need to reset ConfluxPortal’s account history, which you can do like so: