-
Notifications
You must be signed in to change notification settings - Fork 67
Run E2E PoC
- You are running a Substrate node with the Chainlink pallet (and example runtime module).
-
Create a new directory and cd into it:
mkdir ~/.chainlink-substrate && cd ~/.chainlink-substrate
-
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
-
Start container:
docker run -p 6688:6688 -v ~/.chainlink-substrate:/chainlink -it --env-file=.env smartcontract/chainlink local n
-
Follow instructions given to set up an account
- Open docker container bash:
docker exec -it <container name> /bin/bash
You can find the container name/id with docker ps
-
Authenticate with credentials created above:
chainlink admin login
-
Add EI with
chainlink initiators create test-ei http://host.docker.internal:8080/jobs
-
Take note of the credentials that is output
(Exit out of the docker container)
-
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
-
Open the psql client:
psql -h localhost -U postgres
-
Enter "password" as the password
-
Create database:
CREATE DATABASE ei;
(Exit out of the psql client with \q
)
Create ei.env
file:
EI_IC_ACCESSKEY= # Enter the Initiator to Chainlink accesskey
EI_IC_SECRET= # Enter the Initiator to Chainlink access secret
EI_CI_ACCESSKEY= # Enter the Chainlink to Initiator accesskey
EI_CI_SECRET= # Enter the Chainlink to Initiator access secret
EI_DATABASEURL=postgres://postgres:password@host.docker.internal:5432/ei?sslmode=disable
EI_CHAINLINKURL=http://host.docker.internal:6688/
Use the credentials generated during Add EI to Chainlink node
Run using Docker: (If you're not running the Substrate node locally, change host.docker.internal
to the Substrate node's IP address)
docker run -p 8080:8080 -it --env-file=ei.env smartcontract/external-initiator "{\"name\":\"substrate-node\",\"type\":\"substrate\",\"url\":\"ws://host.docker.internal:9944/\"}"
It is recommended to get familiar with the Substrate Adapter's run instructions before starting: https://github.com/smartcontractkit/substrate-adapter
-
Install subkey
-
Install dependencies:
go get
-
Build executable:
go build -o substrate-adapter
-
Set applicable environment variables, or run with env vars:
-
Run
PORT=3000 SA_TX_TYPE=immortal SA_PRIVATE_KEY="<your-substrate-private-key>" SA_ENDPOINT="ws://host.docker.internal:9944/" ./substrate-adapter
-
Access the Chainlink node GUI at
http://localhost:6688/
-
Head over to Bridges and create new
-
Give it the name "substrate" and enter the URL the adapter is listening on
If running the adapter locally using the command provided above, this would be http://host.docker.internal:3000/
- Create new job in the CL node GUI with the following jobspec:
{
"initiators": [
{
"type": "external",
"params": {
"name": "test-ei",
"body": {
"endpoint": "substrate-node",
"accountIds": ["0xd43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d","0x8eaf04151687736326c9fea17e25fc5287613693c912909cb226aa4794f26a48"]
}
}
}
],
"tasks": [
{
"type": "httpget"
},
{
"type": "jsonparse"
},
{
"type": "multiply"
},
{
"type": "substrate",
"params": {
"type": "uint128"
}
}
]
}
Follow instructions on how to run the front-end, then click the button to send a request.