chainlink node setup using xdai.
- Clone this repo to a new cloud server
- Copy
chainlink-<networ>.env
tochainlink.env
- Create folder
secrets
- In
secrets
, create these files:api
: This file contains 2 lines, one line with an email address and one line with a password. These credentials are used to log into the chainlink admin UI and CLI.password
: This file contains the password to the keystores used as node addresses for sending transactions.keystore.mnemonic
: Put the mnemonic for the keystores in here.postgres.env
: Copy frompostgres.env.sample
and insert your postgres db password.
- Run
create_keystore.py <password> keystore
, this will create the keystore and store it in thesecrets
folder. Use the password from step 4.2 - Run
docker-compose up -d
to start the docker containers. - Run
docker ps --all
to check if two docker containers are up and running. If one container exits, rundocker-compose up -d
again (the chainlink node expects the postgres container to be available, which may take some seconds and prevents the chainlink node to start immediately. Alternatively, remove the hash sign # in the line# restart: always
indocker-compose.yml
) - Run
docker logs chainlinknode_chainlink_1
and check if the node is running without errors. - On your local machine, run
ssh -L 6688.localhost.6688 <yourServer>
and check if you can open the GUI vialocalhost:6688
. - On the server, run
docker exec -it chainlinknode_chainlink_1 bash
to connect to the chainlink container. - Run
chainlink admin login
with the credentials of step 4.1 - Run
chainlink keys eth list
and copy the address of the key. - Run
chainlink keys eth delete <address> --hard
(replace with the address of the key just copied.) - Run
chainlink keys eth import ./secrets/keystore.json -p secrets/password
. The keystore should be imported. - Run
chainlink keys eth list
. The imported key (and nothing else) should be displayed. - Fund the address.
- (to be continued)
currently templates are provided for the following networks
- xdai-main
- polygon-main
- polygon-test
- avax-main
- avax-test
when any additional network needs to be supported a corresponding template file needs to be added to this repo.
eg the template file for polygon-test is chainlink-polygon-test.env
.
to create a new template file:
- copy
chainlink-xdai-main.env
tochainlink-<network-key>.env
- adapt variable
ETH_CHAIN_ID
to its network-specific value - adapt variable
LINK_CONTRACT_ADDRESS
to its network-specific value
to find the right values check with the Chainlink documentation.
public part of config files for virtual server setup.
assumption: only ssh access is possible
- open new shell (green)
- ssh login using the command below
ssh <user>@<ip-address>
<user>
your ssh username<ip-address>
the ip address of the machine where your chainlink node runs
then, in the chainlink node shell
- use docker ps to check the state of running containers and their names.
- use docker exec to open a shell inside the chainlink container
cd /opt/chainlinknode
cat api
docker ps -a
docker exec -it chainlinknode_chainlink_1 bash
inside the chainlink docker container you can now use the chainlink cli.
the chainlink cli first needs an admin login (see file api
for the credentials)
chainlink admin login
chainlink help
- open new shell (green)
- ssh tunnel using the command below
- access api endpoints via
localhost:/6688
ssh -L 6688:localhost:6688 <user>@<ip-address>
<user>
your ssh username<ip-address>
the ip address of the machine where your chainlink node runs
chainlink node auth can be done via session cookies.
curl can be used to create a session cookie (./cookie
) as shown below.
export USERNAME=<chainlink admin user name>
export PASSWORD=<chainlink admin user password>
curl -c ./cookie -H 'Content-Type: application/json' -d '{"email":"'${USERNAME}'", "PASSWORD":"'${PASSWORD}'"}' localhost:6688/sessions
examples below: use the cookie to show the node's accounting address and list the oracle node jobs
curl -b ./cookie -c ./cookie localhost:6688/v2/keys/eth
curl -b ./cookie -c ./cookie localhost:6688/v2/jobs
chainlink api endpoints extracted from the chainlink go source on github
/health
/readyz
/v2/bridge_types
/v2/chains/evm
/v2/config
/v2/external_initiators
/v2/features
/v2/feeds_managers
/v2/job_proposals
/v2/jobs
/v2/keys/csa
/v2/keys/eth
/v2/keys/ocr
/v2/keys/p2p
/v2/keys/vrf
/v2/log
/v2/ping
/v2/pipeline/runs
/v2/transactions/
/v2/tx_attempts
- open new shell (green)
- ssh tunnel using the command below
- open ui in your browser via url http://localhost:6688/
ssh -L 6688:localhost:6688 <user>@<ip-address>
<user>
your ssh username<ip-address>
the ip address of the machine where your chainlink node runs
- ssh tunnel
- open new shell (green)
- connect to postgresql db with
postgresql://<db-user>:<db-password>@localhost:5432/chainlink
ssh -L 5432:localhost:5432 <user>@<ip-address>
<db-user>
the db user name (see postgres.env)<db-password>
the db user password (see postgres.env)<user>
your ssh username<ip-address>
the ip address of the machine where your chainlink node runs
cd operator
docker run -it --rm \
-v $PWD:/projects/operator \
brownie
inside container
cd operator
brownie pm install OpenZeppelin/[email protected]
brownie pm install smartcontractkit/[email protected]
brownie compile
brownie run deploy