This is a step-by-step guide explaining how to set up a Chainlink node and an oracle on Agoric
Make sure you have the following requirements before starting:
- node (Use version 16.17.0)
- docker
- docker-compose
- jq
cd ~
node --version # 16.17.0 or higher
sudo npm install --global yarn
git clone https://github.com/agoric/agoric-sdk
cd agoric-sdk
git checkout 088b0abf214839326958b9c1109b2d50136636e4
yarn install
yarn build
yarn link-cli ~/bin/agoric
cd packages/cosmic-swingset && make
echo "export PATH=$PATH:$HOME/bin" >> ~/.profile
source ~/.profile
agoric --version
agd version
Before the setup, we have to run the following
cd ~
git clone https://github.com/jacquesvcritien/dapp-oracle.git
cd dapp-oracle
git checkout testnet-1
agoric install
Clone the repository containing the code for the middleware
cd ~
git clone https://github.com/SimplyVC/agoric-cl-middleware.git
cd agoric-cl-middleware
yarn install
- Create an agoric key
REPLACE WALLET_NAME WITH YOUR PREFERRED NAME
WALLET_NAME=test
agd keys add $WALLET_NAME --keyring-backend=test
- Get the address
WALLET_ADDR=$(agd keys show "$WALLET_NAME" --keyring-backend test --output json | jq -r .address)
echo "Address: $WALLET_ADDR"
- Send the address to the oracle team
- Create a service file
sudo tee /etc/systemd/system/agoric-node.service > /dev/null <<EOF
[Unit]
Description = agoric node service
Wants = network-online.target beacon-chain.service
After = network-online.target
[Service]
User = $USER
Environment="DEBUG=SwingSet:ls,SwingSet:vat"
ExecStart = /home/agoric/go/bin/agd start --log_level=info --home /home/$USER/.agoric --log_level=warn
Restart = always
[Install]
WantedBy= multi-user.target
EOF
- Start node
systemctl daemon-reload
systemctl start agoric-node
- Check if the node is still catching up
echo $(agd status) | jq ".SyncInfo.catching_up"
Make sure the above is FALSE before going to the next step
Once the node is synced, you need to provision the smart wallet
- Provision the smart wallet
- Go to the faucet
- Enter the address and select "send IST and provision smart wallet"
- Confirm the smart wallet provision
agoric wallet show --from "$WALLET_ADDR"
The next step involves accepting the oracle invitation
REPLACE WALLET_NAME WITH THE CHOSEN NAME IN STEP 4.1
WALLET_NAME=test
ASSET_IN=ATOM
ASSET_OUT=USD
CHAIN_ID=agoricdev-17
cd ~/agoric-cl-middleware/scripts
./accept-oracle-invitation.sh $WALLET_NAME $ASSET_IN $ASSET_OUT $CHAIN_ID
This step involves confirming that the oracle invitation was accepted in the previous step.
In order to do this, change $WALLET_NAME to the your wallet name and run the following command
agoric wallet show --from $(agd keys show $WALLET_NAME --keyring-backend test --output json | jq -r .address)
Then, under offerStatuses, make sure you have an accepted oracle invitation as can be seen in the image below. numWantsSatisfied: 1 indicates that the oracle invitation was accepted successfully.
REPLACE ORACLE_NAME WITH YOUR PREFERRED NAME
cd ~/agoric-cl-middleware
THIS_VM_IP=$(hostname -I | sed 's/ *$//g')
THIS_VM_IP=$(echo ${THIS_VM_IP%% *})
WALLET_ADDR=$(agd keys show "$WALLET_NAME" --keyring-backend test --output json | jq -r .address)
echo "THIS_VM_IP=$THIS_VM_IP" > .env
echo "WALLET_ADDR=$WALLET_ADDR" >> .env
#create config
mkdir -p ~/config
ORACLE_NAME="ORACLE1"
echo "{ \"$WALLET_ADDR\" : { \"oracleName\": \"$ORACLE_NAME\" }}" > ~/config/oracles.json
The next step involves running the script found at dapp-oracle/chainlink-agoric/setup.
cd ~/dapp-oracle/chainlink-agoric
docker-compose pull
./setup
This setup script does the following:
- Starts docker containers via chainlink-agoric/internal-scripts/common.sh for:
- Postgres DB Instance
- Chainlink Node
- Adds the external initiator built inside the middleware to the Chainlink node via chainlink-agoric/internal-scripts/add-ei.sh
- Adds the external adapter built inside the middleware to the bridges section of the Chainlink node via chainlink-agoric/internal-scripts/add-bridge.sh
To start the middleware, run the following commands
cd ~/agoric-cl-middleware
#build the images
docker-compose build middleware
docker-compose build monitor
docker-compose up -d
- Go to http://IP:6691
- Log in with the following credentials
notreal@fakeemail.ch
twochains
- Add the required bridges and job spec given out by the Simply Staking team
Run the following
agoric follow :published.priceFeed.ATOM-USD_price_feed