5.5.2 Conflux
On this page:
CFX_  NETWORK_  ID FAQ How do I run my Reach DApp on CFX Test  Net or Main  Net? Why is DApp startup very slow? Why do I need to use set  Query  Lower  Bound? 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: FAQ 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:


Or this to run on Conflux 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)); 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. 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: