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
https://classic.yarnpkg.com/en/docs/install/#debian-stable
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
exit
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 *
BLOCK_BACKFILL_DEPTH 10
BRIDGE_RESPONSE_URL
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_BALANCE_MONITOR_BLOCK_DELAY 1
ETH_DISABLED false
ETH_FINALITY_DEPTH 50
ETH_GAS_BUMP_THRESHOLD 3
ETH_GAS_BUMP_TX_DEPTH 10
ETH_GAS_BUMP_WEI 5000000000
ETH_GAS_LIMIT_DEFAULT 500000
ETH_GAS_PRICE_DEFAULT 4500000000
ETH_HEAD_TRACKER_HISTORY_DEPTH 100
ETH_HEAD_TRACKER_MAX_BUFFER_SIZE 3
ETH_MAX_GAS_PRICE_WEI 5000000000000
ETH_URL wss://kovan.infura.io/ws/v3/your_api_key
EXPLORER_URL
FEATURE_EXTERNAL_INITIATORS true
FEATURE_FLUX_MONITOR false
GAS_UPDATER_BLOCK_DELAY 3
GAS_UPDATER_BLOCK_HISTORY_SIZE 24
GAS_UPDATER_ENABLED true
GAS_UPDATER_TRANSACTION_PERCENTILE 60
JSON_CONSOLE true
LINK_CONTRACT_ADDRESS 0xa36085F69e2889c224210F603D836748e7dC0088
LOG_LEVEL debug
LOG_SQL_MIGRATIONS true
LOG_SQL false
LOG_TO_DISK true
MAX_RPC_CALLS_PER_SECOND 500
MAXIMUM_SERVICE_DURATION 8760h0m0s
MIN_INCOMING_CONFIRMATIONS 3
MIN_OUTGOING_CONFIRMATIONS 2
MINIMUM_CONTRACT_PAYMENT 0.010000000000000000
MINIMUM_REQUEST_EXPIRATION 300
ORACLE_CONTRACT_ADDRESS:0xA42FdFD2E1a7239B76D753803cbB7611004FE068
CHAINLINK_PORT 6688
REAPER_EXPIRATION 240h0m0s
REPLAY_FROM_BLOCK -1
ROOT /chainlink
SECURE_COOKIES true
SESSION_TIMEOUT 15m0s
CHAINLINK_TLS_HOST
CHAINLINK_TLS_PORT 6689
CHAINLINK_TLS_REDIRECT false
CHAINLINK_TX_ATTEMPT_LIMIT 10
——————————————
** 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:
PRIVATE_KEY=<ACCOUNT PRIVATE KEY>
Step2a. Use command:
sudo nano .env
add following entry:
PRIVATE_KEY=<ACCOUNT PRIVATE KEY>
*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:
Example:
EI_DATABASEURL=postgresql://$USERNAME:$PASSWORD@$SERVER:$PORT/$DATABASE
EI_CHAINLINKURL=http://localhost:6688
EI_IC_ACCESSKEY=bb92ad73a0624879bec0bedd70e11d78
EI_IC_SECRET=Qt02+NV2CiNFlcbJTeJmxUZSd8WB5Dd1MShANijrQ0uexvj2HKf4KML03hgiI3t5
EI_CI_ACCESSKEY=YjeTzptuk+OtII/3Zz5v5sUk61TxE7P/cjSLN8qDHsmiB8J8llBfS5yDgYUv5OaG
EI_CI_SECRET=wbWrkoSSdnlRCC6PW0GgjAkY57Oz+JrJ5lK56/ySpN2lEnM+KPS2sb/9Un6nGi1v
*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.
https://github.com/Conflux-Network-Global/demo-cfx-chainlink/blob/master/contractInteraction/contract/test_oracle.sol
Once compiled deploy the contract to Conflux testnet and you will be provided a contract address. Example address below:0x8f6bd7fd61b3c03a67e147037057be9665fb576f
Setup External Adapter Bridge & Job spec
Add External adapter to bridge configuration
Enter localhost address adapter is running on.
Example:
Name: conflux
http://172.17.0.1:5001
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
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