1. Home
  2. Docs
  3. Conflux Network
  4. Chainlink Oracle Setup

Chainlink Oracle Setup

Chainlink Oracle Setup on Conflux Network

*Oracle setup & deployment.
*External adapter & bridge configuration.
*Test contract deployment to Conflux Blockchain.

November 9, 2020

Research, build, log and general testing on Conflux network using Chainlink oracle framework to full offchain market data.

Setup Steps

Step 0. Run on local machine or create virtual machine instance on GCP.

On GCP create the following specs:

N1 Series, 1 cpu 3.5gb ram, Ubuntu 20.0

Create instance and first run command:
sudo apt-get update

followed with upgrade command:
sudo apt-get upgrade -y

Download developer essentials:
sudo apt-get install build-essential

Download and setup OS firewall UFW
sudo apt-get install ufw
sudo ufw allow 6688
sudo ufw allow 6689
sudo ufw allow 22
sudo ufw enable (disrupt connections? YES. Will not disconnect)
sudo ufw status (confirm running and ports open)

Download and install nano text editior (optional)
sudo apt-get install nano

Install NMAP port monitoring tool (optional)
sudo apt-get install nmap
sudo apt-get update
sudo apt-get upgrade -y

Download and install Yarn Debian/Ubuntu
Enter following commands:
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -

echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list

Once repository is configure you can run install command:
sudo apt update && sudo apt install yarn

Add Yarn to your path with command:

cd /home/$USER
sudo nano .profile

Paste the following line at the bottom of code.

export PATH="$PATH:`yarn global bin`"
sudo apt update

Check Yarn Version with command:
yarn –version

Download and setup Docker Container framework:
curl -sSL https://get.docker.com/ | sh
sudo usermod -aG docker $USER
log in again

Step 2. Create a directory

sudo mkdir ~/.chainlink-conflux

Step 4. Setup postgresql database server
4a. On GCP go to >SQL and create a new PostgreSQL server with private ip address. (Public IP address will require a firewall rule to allow port 5432 access)
4b. Create a new database, new user and note down all database info for next step.
4c. Under “connections” section be sure to give your instance permission to the database.

Step 4. Create an .environment file
Example .env:

ACCOUNT_ADDRESS 0xDA30Be578F5a73d3b00498eD98812242B6bAFCEB              
ALLOW_ORIGINS             *
ETH_CHAIN_ID                   42 
CLIENT_NODE_URL               http://localhost:6688                                       
 DATABASE_TIMEOUT             500ms                                                       
 DEFAULT_HTTP_LIMIT             32768 
 DEFAULT_HTTP_TIMEOUT               15s                                                         
 CHAINLINK_DEV                      true                                                        
 ENABLE_BULLETPROOF_TX_MANAGER      false                                         
 ENABLE_EXPERIMENTAL_ADAPTERS       true                                                        
 ETH_DISABLED                       false                                                       
 ETH_FINALITY_DEPTH             50 
 ETH_GAS_BUMP_TX_DEPTH          10 
 ETH_GAS_BUMP_WEI               5000000000 
 ETH_GAS_LIMIT_DEFAULT          500000 
 ETH_GAS_PRICE_DEFAULT          4500000000  
 ETH_MAX_GAS_PRICE_WEI          5000000000000 
 ETH_URL     wss://kovan.infura.io/ws/v3/your_api_key 
 FEATURE_EXTERNAL_INITIATORS        true                                                        
 FEATURE_FLUX_MONITOR               false                                                       
 GAS_UPDATER_ENABLED                true                                                        
 JSON_CONSOLE                       true                                                        
 LINK_CONTRACT_ADDRESS           0xa36085F69e2889c224210F603D836748e7dC0088                  
 LOG_LEVEL                          debug                                                       
 LOG_SQL_MIGRATIONS                 true                                                        
 LOG_SQL                            false                                                       
 LOG_TO_DISK                        true                                                        
 MAXIMUM_SERVICE_DURATION        8760h0m0s                                                   
 MINIMUM_CONTRACT_PAYMENT       0.010000000000000000 
 CHAINLINK_PORT                 6688 
 REAPER_EXPIRATION                  240h0m0s                                                    
 REPLAY_FROM_BLOCK              -1 
 ROOT     /chainlink                                                  
 SECURE_COOKIES                     true                                                        
 SESSION_TIMEOUT                 15m0s                                                       
 CHAINLINK_TLS_PORT             6689 
 CHAINLINK_TLS_REDIRECT             false


** No ETH RPC is required when running Chainlink node on Conflux network!

** For this specific experiment we will be using a Infura Kovan ETH RPC.

*Before configuring the Chainlink components, there needs to be an oracle contract on the Conflux Network that emits events.

Deploy test contract on Conflux testnet network

This is needed for the EI to trigger job runs on the Chainlink node. See the contractInteraction folder for code to interact with the Conflux Network.

Step 5. Run Chainlink Docker run command:

docker run –name chainlink-conflux -p 6688:6688 -v ~/.chainlink-conflux:/chainlink -it –env-file=.env smartcontract/chainlink local n

5a. Create your node wallet password
5b. Create dashboard login credentials. Enter email address and password.

*node will begin sync and logging info. Press ctrl+p ctrl+q to exit. Use command sudo docker ps and confirm container is running.

Setup Conflux Network External Adapter

Step 1. Locate CFX external adapter in previously downloaded conflux-chainlink repo:

sudo git clone https://github.com/Conflux-Network-Global/demo-cfx-chainlink.git

Step 2. Create an environment file that contains:

Step2a. Use command:
sudo nano .env

add following entry:

*Replace <Account Private Key> with your conflux studio wallet private key.

 *The private key is the private key to an address that allows the external adapter to send transactions to Conflux Network.
Open Conflux studio, connect to testnet and create a user key.

Step 3. Install CFX external adapter using command: 
sudo yarn install 

Start the server with yarn command: 
sudo yarn start

Confirm the server is running.

*The external servers will start on http://localhost:5001

Use NMAP to confirm running server with command:

sudo nmap localhost

Connect to node admin dashboard

You can connect to your running Chainlink node via the command prompt of a GUI browser interface. We will describe connecting to both.

CLI Dash Connection
With your Chainlink container running type the following commands.
Find docker container name with command:
sudo docker ps

Login to node dashboard with command:
sudo docker exec -it “containername” /bin/bash
(without quotes replace “containername” with your container name. )
Then enter command:
chainlink admin login

Access Node via GUI
You should be able to access your server external http://ipaddress:6688 and be presented with Chainlink operator dashboard.

Setup External Initiator

Step 1. Install GO https://golang.org/doc/install
Step 2. Clone repo: sudo git clone https://github.com/Conflux-Network-Global/external-initiator
Step 3. git checkout generalized-EI
Step 4. Go build
Step 5. Create another .env file in the external-initiator folder with the following contents:



*Note: the database URL should be separate from the Chainlink node database

Step 6. Generate keys for external initiator.

A. Use chainlink node via command prompt by typing the command:
sudo docker ps

*this will display your running containers. Note down your Chainlink container name.

Then run command:
sudo docker exec -it “container-name” /bin/bash

*Replace “container-name” with your own container name without quotes.

Once inside the container, log in using command: chainlink admin login

Step 7. Start external initiator using command:

./external-initiator "{\"name\":\"cfx-testnet\",\"type\":\"conflux\",\"url\":\"https://wallet-test.confluxrpc.org\"}" --chainlinkurl "https://localhost:6689/"

* Command is pointed at the Conflux Network testnet endpoint. For reliability purposes, do not use this in production!

*To locate your testnet URL open Conflux Studio IDE application. Set Network to testnet.

Deploy Test SmartContract to Conflux Network

Open Conflux studio and compile the following smart contract.


Once compiled deploy the contract to Conflux testnet and you will be provided a contract address. Example address below:


Setup External Adapter Bridge & Job spec

Add External adapter to bridge configuration 
Enter localhost address adapter is running on.
Name: conflux
Min Confirmations: 1
Min Payment 10000000000000000

*save bridge and a successfully added notification should appear.

Step 3. Create Job spec in CL node dashboard
  “initiators”: [
      “type”: “external”,
      “params”: {
        “name”: “cfx”,
        “body”: {
          “endpoint”: “cfx-testnet”,
          “addresses”: [“0x8f6bd7fd61b3c03a67e147037057be9665fb576f”]
  “tasks”: [
    {“type”: “TwilioBridge”}

Chainlink Dashboard Showing Configured Bridges

Add SMS Twilio Job Spec

{ "initiators": [ { "type": "cron", "params": { "schedule": "CRON_TZ=UTC */30 * * * * *" } } ], "tasks": [{ "type": "TwilioCheck" }, { "type": "conflux" }] }

Note Job ID: 0x8f6bd7fd61b3c03a67e147037057be9665fb576f

Dark Mode

demo-cfx-chainlink (this link opens in a new window) by Conflux-Network-Global (this link opens in a new window)

Demonstration of connecting Conflux Network and a SMS Gateway using Chainlink’s external initiators and external adapters


Was this article helpful to you? Yes No

How can we help?