Set Up a ChainLink Test Node with AWS EC2 , Fiews , and Docker

developer blog
14 min readJul 14, 2019

Work in progress — Started: July 14 2019

Usual reminder to consult the official documentation: https://docs.chain.link/docs/running-a-chainlink-node

This guide is intended for AWS beginners and those who have never set up a server/used terminal before. This guide does not cover: multiple servers, what to do in case services fail, and some other important topics that you neat to node.

^

AWS EC2 = our vps (virtual private server). This is where the ChainLink node runs.

Fiews = our EaaS (ethereum as a service) provider. Our connection to Ethereum. Having our own connection to Ethereum would be more difficult because the Ethereum blockchain is huge if starting from scratch.

Docker = a container platform. It’s useful for putting software on a server because it simplifies some of the settings that can vary across systems. Basically, it makes this easy since the ChainLink node software is ready to be downloaded with Docker.

Ropsten = the test ethereum network we’re using

Both AWS EC2 and Fiews offer free trials (as of right now). Fiews may discontinue their free trial for test nodes but the low tier plan is very cheap if you are testing ($5/month).

We start out at Amazon’s AWS (Amazon Web Services). Go to Amazon.com’s AWS.

Set up an AWS account and add your card information so you can get a free trial of 12 months. Read the actual trial information so you know what you sign up for.

Enter the AWS management console, check under your account or look at the page for a link.

Go up to “services” and find the EC2 option. It should be pretty easy to spot.

Click EC2.

This brings us to a new page.

ADVICE: If you just created your AWS account, you may have a problem when you launch EC2 since your account is very new. You’ll have to try again later (maybe an hour or so, no big deal)

Click “Launch Instance”. There’s a list of different types of servers, different types of Linux, Windows, etc. Linux is commonly used.

Choose Amazon Linux 2 AMI (HVM), SSD Volume Type. It’s 64-bit x86.

We are going to put Docker on this vps.

Leave t2 micro selected, because it’s free and it’s all we need to test this.

Click next to configure instance details.

Check that the auto-assign public IP is set to use subnet setting (It’s Enabled). You don’t need to change anything on Step 3: Configure Instance Details. Click next to add storage.

You need more than 8 GB which is the default, so change the size to 20 GB. Note the message which tells you the max size for free tier.

Click next and add a tag.

Type “name” for the key. For the value, type something like “linkNode”, “myLinkNode”, “Sergey”, it’s really up to you.

Click next to configure a quick and simple security group.

Click add rule or edit the group that’s already there. You need SSH, TCP, Port 22. On source, click the dropdown box and select “My IP” to get your IP.

We are making this so that only your computer can connect to the server with SSH. There’s no point in allowing everyone to connect to your Link node for administration.

Click review and launch, check the things you edited, then click launch.

It doesn’t launch. A window pops up.

You need a key pair to be able to connect. Choose create a new key pair. Name it something you remember, and download it to somewhere you remember.

Click Launch Instances so that your instance starts up, and then click View Instances.

Go download and install your SSH client, PuTTY. When it’s done, make sure that you have PuTTY and PuTTYgen installed.

Open PuTTYgen.

Click Load, and find the .pem key that you downloaded. You have to look for all files and not the specific file extension set default.

It loads but PuTTYgen will warn you. Make sure RSA is selected, and then click “save private key”. PuTTYgen will warn you about a password. For now, you don’t need a key password but note you have the option. Name your private key something you remember and save it somewhere you remember.

Back in AWS, you should see a list, and your new EC2 instance should be on it. Otherwise click around until you see the list panel with your instance. Right click your instance and select connect. If “stand alone SSH” is selected, you’ll see vps information.

Copy the public dns so you can paste it into PuTTY later.

Open up PuTTY.

Paste into the host name box. Port 22, SSH selected.

You need to use your key, so look on the left and find SSH in the tree. Under SSH, there’s a settings panel for “Auth”.

Click Browse and find your private key .ppk file you saved with PuTTYgen. Click open.

Now go back to Session (at the top of the tree). Name and save this profile so you don’t have to add your key and the host name info again. Now you can click the profile to load this information quickly.

Name and save this profile so you don’t have to add your key and the host name info again.

You can click Open to SSH and log in to your EC2. A black terminal window opens. By default, just type ec2-user as the username. The key works (at least is should).

You can type what it tells you to quickly upgrade out of date software.

Now, install Docker. Enter the following or copy-paste, line by line. Copy-paste is a bit different in SSH, try only right clicking to paste in the PuTTY window and some terminals copy-paste tools are ctrl-shift-c/ctrl-shift-v. Hit enter after each line to execute the command. At some point, there might be a message telling you how much storage this takes. Type y and then hit enter to continue.

sudo amazon-linux-extras install docker

sudo systemctl start docker

sudo gpasswd -a $USER docker

exit

We installed docker, started it, and assigned ec2-user with it.

Then with the last command we exit, so reopen PuTTy, click your profile that you created to load the info (the host box might stay blank), click load, and log in again using ec2-user as the username.

Go to https://fiews.io/ and create an account. After you create the account and verify email, go to your account and create a new subscription. Select “free trial” and “for chainlink”.

Note: a lot of this guide is based on their quick guide here https://docs.fiews.io/docs/run-a-chainlink-node-from-scratch

Copy the key you get so that you can type it in PuTTY later.

Go back to your PuTTY window and make a directory for chainlink.

mkdir -p ~/.chainlink-ropsten

Type or copypaste this, and hit enter.

Now setup some settings for the chainlink environment.

BIG NOTE: We are using Fiews. However, if you want a different service, you can substitute the ETH_URL below:

ETH_URL=wss://ropsten-rpc.linkpool.io/ws

You can enter line-by-line or you can copy-paste. Ok, this is the part where you substitute your API key you just copied from Fiews into the first line where it says “yourapikey”. Pasting in the SSH window is different, try only right clicking.

echo “ETH_URL=wss://cl-ropsten.fiews.io/v1/yourapikey

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=*” > ~/.chainlink-ropsten/.env

Hit enter and make sure everything looks good.

Now enter the lines below to go into your chainlink directory and then run the chainlink on the Ropsten eth test network via docker with the environment file you just specified with port 6688.

cd ~/.chainlink-ropsten

docker run -p 6688:6688 -v ~/.chainlink-ropsten:/chainlink -it --env-file=.env smartcontract/chainlink local n

The ChainLink code will be downloaded from docker and run with docker. If prompted, Type y and hit enter.

Create a password for your wallet file, save this password. Type in your password carefully (the line stays the same even though you’re typing) and then confirm it.

Create a email address and password for the api, save these also.

You might notice that you have 0 eth in your Ropsten test address.

You can go to a Ropsten test eth faucet to get free test eth. https://faucet.ropsten.be/

You can get test LINK for ropsten here: https://ropsten.chain.link/

At this point you have used AWS to start a vps, connect to the test ETH network with Fiews, and have installed and are running your test ChainLink node with Docker.

— — — — — — — — Instructions on accessing the Chainlink Operator GUI are following the next section.

Logging In Again, Checking Docker, Checking Jobs

Usual reminder to check the official documentation: https://docs.chain.link/docs/miscellaneous

You might have closed PuTTY already, but your Docker Chainlink is running on AWS EC2. Open PuTTY and click the profile you saved. Click load. Then click open so that you can ssh log in to AWS EC2 as username: ec2-user. Your key will load and you’ll see the same familiar screen.

Type:

docker ps

Hit enter, and it shows you currently running dockers. You can see some information about your Chainlink docker. Note the name. If you didn’t custom name it when you first ran the node, it will be something odd like cocky_sergey . Remember this for the next step.

Log in to the docker Chainlink shell

Type:

docker exec -it cocky_sergey /bin/bash

Replace the name with the one you found in the previos step. Hit enter, and:

If everything worked the name of the command line will change, this is because you are now in the shell for the docker.

I hope you remember your api email and password from a bit earlier in this guide, because now you can type:

chainlink login

and enter those details to login.

Type:

Type chainlink j

and hit enter to see a list of running jobs. You probably don’t have any because you just started, but you’ll see a table meaning you’ve been successful in accessing this.

Quickly Access the Chainlink GUI by SSH Tunneling with PuTTY

It would be great to access the Chainlink test node GUI with a few simple additions to PuTTY.

After set up, you will be able to see this by going to the http://localhost:6688 link in your browser.

Open a new PuTTY window.

Go to session if you are not already there, and load your link node profile.

Click the profile name, then click load. This will load the usual connection information in along with your security key we added much earlier in this guide.

Now in the tree, find and expand SSH, and under that, find Tunnels.

In the source port box, type 6688.

In the destination box, type localhost:6688

Leave the options on Local and Auto.

Click add.

You’ll see your addition go into the large textbox as L6688 localhost:6688. Click that to highlight it. Now, hit open. The usual window will open to let you log into AWS. Because you highlighted and loaded in your saved link node profile in the session pane, your key will be given as well. Log in as ec2-user .

This window serves as the SSH tunnel. Closing this window will close the SSH tunnel, so you need to leave it open while accessing the GUI from your browser with localhost:6688 . You might have trouble if you have odd firewall settings or router settings, just a warning, fixing is too detailed for this guide.

The gui will load into the log in screen. This is where you input your api email and password that you added when you first ran the node via docker.

Logging in, you’ll see the Chainlink Operator interface.

You’ll have 0 ropsten test-ETH and 0 test-LINK if you haven’t sent any to the account address. You can click Configuration to see your test account address.

Get test ETH here: https://faucet.ropsten.be/

You can get test LINK here: https://ropsten.chain.link/

Now you can quickly click through the menu options and familiarize yourself with the node operator options.

Setting Up the Smart Contract for Your Node

Reminder: Log in using PuTTY. Remember to set up the SSH tunnel so you can access the GUI.

This section requires more software tools.

Go to https://remix.ethereum.org/#optimize=true&version=soljson-v0.4.24+commit.e67f0147.js&appVersion=0.7.7

This is a way for you to create, edit, and review smart contracts in your browser.

When you open Remix, your Metamask app will tell you to login. (If you don’t have Metamask, get it https://metamask.io/ and add it as a browser extension).

First, login to Metamask, second, change Metamask to use the ropsten test network by clicking the top dropdown box which has the name of the current network.

Back at Remix, highlight and delete the sample contract in the text area (click in the text, press ctrl-A, then backspace).

Copy the entire smart contract here at this link: https://raw.githubusercontent.com/smartcontractkit/chainlink/master/examples/testnet/contracts/Oracle.so

and paste it into the text area. Find the button on the right that says Start to Compile and then click it.

Now look at the top right and click the Run tab.

Use the dropdown box which currently says ChainlinkRequestInterface and change it to Oracle.

Copy and paste the ropsten Chainlink smartcontract address 0x20fE562d797A42Dcb3399062AE9546cd06f63280

into the text area next to Deploy .

Metamask will show up, and if you’re on ropsten, you probably have zero test eth to use to confirm. Copy your eth address from metamask and then get some test eth from a faucet. https://faucet.ropsten.be/ before continuing.

Click Deploy. Make sure that you are using the ropsten test network and not the mainnet.

You can see the Deployed Contracts section on the right. Save this address of your oracle smart contract somewhere you remember.

Look on the right after the Oracle smartcontract is created and you’ll see a dropdown selection that says Oracle deployment at 0x…

Click it and find the setFulfillmentPermission field. Put your test node address followed by a comma, and True in the field. If you set up the SSH tunnel to access your node GUI, then you can quickly find your node test address at the top here: http://localhost:6688/config

your_node_address_here, True

Make sure to remove all spaces around your node address if you are copy-pasting from your node GUI page.

Click setFulfillmentPermission and confirm it in Metamask. Again, make sure that you are on the ropsten test network.

Adding Jobs

Reminder: Set up SSH tunneling (explained earlier in this guide) to access your node GUI easily.

Go to your node GUI — specifically, the jobs tab. http://localhost:6688/jobs

Click New Job. The JSON text field lets you manually add jobs.

Go ahead and open a .txt file on your PC so that you can copy and paste the job ids that you will create here.

Copy and paste the sample job below into the JSON text field. This is a sample job from the Chainlink documentation which gets the current ethereum price.

In Remix (explained in the previous section), get your oracle smart contract address (NOT your test node address) from the Deployed Contracts section on the right.

Substitute your oracle smart contract address into this JSON text.

{
“initiators”: [
{
“type”: “runlog”,
“params”: {
“address”: “YOUR_ORACLE_CONTRACT_ADDRESS”
}
}
],
“tasks”: [
{
“type”: “httpget”
},
{
“type”: “jsonparse”
},
{
“type”: “ethbytes32”
},
{
“type”: “ethtx”
}
]
}

Make sure to keep the address quote marks and the same structure especially if copy-pasting into the GUI.

Click create job, and a message will announce that the job was created. Save the job id.

Now create a new job for each of the four code blocks below.

Copy a code block into the node GUI text field, change it to include your oracle contract address, add the job, save the job id to your text file, and then highlight and delete the JSON text.

{
“initiators”: [
{
“type”: “runlog”,
“params”: {
“address”: “YOUR_ORACLE_CONTRACT_ADDRESS”
}
}
],
“tasks”: [
{
“type”: “httppost”
},
{
“type”: “jsonparse”
},
{
“type”: “ethbytes32”
},
{
“type”: “ethtx”
}
]
}
{
“initiators”: [
{
“type”: “runlog”,
“params”: {
“address”: “YOUR_ORACLE_CONTRACT_ADDRESS”
}
}
],
“tasks”: [
{
“type”: “httpget”
},
{
“type”: “jsonparse”
},
{
“type”: “multiply”
},
{
“type”: “ethint256”
},
{
“type”: “ethtx”
}
]
}
{
“initiators”: [
{
“type”: “runlog”,
“params”: {
“address”: “YOUR_ORACLE_CONTRACT_ADDRESS”
}
}
],
“tasks”: [
{
“type”: “httpget”
},
{
“type”: “jsonparse”
},
{
“type”: “multiply”
},
{
“type”: “ethuint256”
},
{
“type”: “ethtx”
}
]
}
{
“initiators”: [
{
“type”: “runlog”,
“params”: {
“address”: “YOUR_ORACLE_CONTRACT_ADDRESS”
}
}
],
“tasks”: [
{
“type”: “httpget”
},
{
“type”: “jsonparse”
},
{
“type”: “ethbool”
},
{
“type”: “ethtx”
}
]
}

If you click on the Jobs tab in the node GUI, you should see five jobs in total.

In a yet-to-be written section of this guide, you will act like a requester (that is, someone who wants to get information using your node) in order to test the sample job running on your node.

For now, continue reading the documentation here and scroll to the bottom for a guide on how to to do that. https://docs.chain.link/docs/fulfilling-requests

End for now

  • add section on requesting from node

LINK Donations for the generous (mainnet LINK):

0xbBb6368AA6d4983F2F40429177F6fe1a1fb843A9

--

--