Skip to content
This repository has been archived by the owner on Sep 22, 2023. It is now read-only.

Run E2E PoC

Jonas Hals edited this page Feb 10, 2020 · 25 revisions

Prerequisites

  • You are running a Substrate node with the Chainlink pallet (and example runtime module).

Run a Chainlink node

  1. Create a new directory and cd into it: mkdir ~/.chainlink-substrate && cd ~/.chainlink-substrate

  2. Set up an .env file:

ROOT=/chainlink
LOG_LEVEL=debug
ETH_CHAIN_ID=3
MIN_OUTGOING_CONFIRMATIONS=2
LINK_CONTRACT_ADDRESS=0x20fe562d797a42dcb3399062ae9546cd06f63280
CHAINLINK_TLS_PORT=0
SECURE_COOKIES=false
ALLOW_ORIGINS=*
ETH_URL=wss://ropsten.infura.io/ws
CHAINLINK_DEV=true
  1. Start container: docker run -p 6688:6688 -v ~/.chainlink-substrate:/chainlink -it --env-file=.env smartcontract/chainlink local n

  2. Follow instructions given to set up an account

Add EI to Chainlink node

  1. Open docker container bash: docker exec -it <container name> /bin/bash

You can find the container name/id with docker ps

  1. Authenticate with credentials created above: chainlink admin login

  2. Add EI with chainlink initiators create test-ei http://host.docker.internal:8080/jobs

(Exit out of the docker container)

Run Postgres node

  1. Run Postgres container: docker run -v ~/.chainlink-substrate/pg:/var/lib/postgresql/data --name postgres --rm -p 5432:5432 -e POSTGRES_PASSWORD=password -d postgres

  2. Open the psql client: psql -h localhost -U postgres

  3. Enter "password" as the password

  4. Create database: CREATE DATABASE ei;

(Exit out of the psql client with \q)

Run External Initiator

Create ei.env file:

EI_CI_ACCESSKEY= # Enter the Chainlink to Initiator accesskey
EI_CI_SECRET= # Enter the Chainlink to Initiator access secret
EI_IC_ACCESSKEY= # Enter the Initiator to Chainlink accesskey
EI_IC_SECRET= # Enter the Initiator to Chainlink access secret
EI_DATABASEURL=postgres://postgres:password@host.docker.internal:5432/ei?sslmode=disable
EI_CHAINLINKURL=http://host.docker.internal:6688/

Run using Docker: (Remember to change $YOUR_SUBSTRATE_NODE_IP to the IP address of your Substrate node. If running it locally, use localhost)

docker run -p 8080:8080 -it --env-file=ei.env smartcontract/external-initiator "{\"name\":\"substrate-node\",\"type\":\"substrate\",\"url\":\"ws://$YOUR_SUBSTRATE_NODE_IP:9944/\"}"

Run Substrate Adapter

It is recommended to get familiar with the Substrate Adapter's run instructions before starting: https://github.com/smartcontractkit/substrate-adapter

  1. Install subkey

  2. Install dependencies: go get

  3. Build executable: go build -o substrate-adapter

  4. Set applicable environment variables

  5. Run with PORT=3000 ./substrate-adapter

Add Substrate Adapter to Chainlink node

  1. Access the Chainlink node GUI at http://localhost:6688/

  2. Head over to Bridges and create new

  3. Give it the name "substrate" and enter the URL the adapter is listening on

Add test jobspec

  1. Create new job in the CL node GUI with the following jobspec:
{
  "initiators": [
    {
      "type": "external",
      "params": {
        "name": "test-ei",
        "body": {
          "endpoint": "substrate-node",
          "accountIds": [
            "$YOUR_SUBSTRATE_ADDRESS"
          ]
        }
      }
    }
  ],
  "tasks": [
    {
      "type": "httpget"
    },
    {
      "type": "jsonparse"
    },
    {
      "type": "multiply"
    },
    {
      "type": "substrate",
      "params": {
        "type": "uint128"
      }
    }
  ]
}

Send a request on-chain

Follow instructions on how to run the front-end, then click the button to send a request.

Clone this wiki locally