On-Chain Oracle (Ethereum)
Last updated
Last updated
Our API can be consumed via a Chainlink oracle on-chain, on Ethreum. Both Solana NFT and Ethereum NFT prices can be consumed, which means you can build a cross-chain app on Ethereum that, for example, relies on SMB or DeGods prices from Solana.
Chainlink oracles on Ethereum require one to operate a node in order to access an endpoint. At this point Tensor doesn't have its own node, which means (for now) the responsibility falls onto the consumer.
The good news is that there are "Node-as-a-service" services that are actually free on test networks like Rinkeby and Goeli, and are super easy to setup.
Head on over to
Sign up then hit "Deploy". This will take you to where you can select your network and deploy a node. For this tutorial we'll be deploying a Rinkeby node
Once your node is live hit the blue "Operator" button on the right hand side
You'll be taken to . Use the "domain login" details to get rid of the browser password prompt, then login into the actual page using "node ui login"
Once inside, we'll need to fund your node.
Hit the settings cog in the upper right corner, then find the public key of your node under "Account addresses". Mine looks like this: 0xD0cf91f226c625187Ed20AF82B482669aa78fcAE
Let's get some test ETH and LINK. Chainlink conveniently has a . Fill out the details and wait for your ETH and LINK to arrive.
Once done, send 50% of both to the node address above.
Our node is now funded!
Next you'll need to complete 3 sections from Chainlink's own tutorial:
. Be sure to substitute the public key in the job with the key of the contract.
To recap, what we've done so far is:
We've deployed our own node & funded it. This is the actual hardware that will be fulfilling the job.
We've deployed our contract & enabled the node on the contract. Our contract will now forward the job to the node.
We've created a generic job that can fulfill HTTP requests on that node. We'll be hitting it next.
Now the fun part! Let's actually use the oracle!
Click into the compile tab, and hit "Compile", if not done automatically
Click into the deployment tab, change your environment to "Injected Web3" (make sure the network is the correct one - should be eg 4 for Rinkeby)
Select BaycPriceFetched
from the contract menu and hit deploy
Since Chainlink isn't free, our consumer contract will have to pay our provider contract (that we deployed earlier). Therefore we need to fund our consumer contract.
Copy the newly deployed contract address. If you're wondering where it is, it's on the left, just below "Deployed Contracts" and looks like this: BAYCPRICEFETCHER AT 0X3A0...A1E7B
Send the remaining 5 LINK to it & wait for the transaction to confirm
Our consumer is funded!
Once funded, click on getBAYCPrice
on the left and fill out the fields.
_oracle
= your oracle address
_jobId
= your job ID WITHOUT DASHES, mine looks like this 6be38109f4464658b2fc5fff40dd973b
Hit transact
!
After the transaction confirms, give it a bit of time (up to a min) and hopefully when you hit the currentPrice
field you get a number other than 0! Mine is showing 9879105914415002000000 (price of BAYC in wei)
You can repeat the same operation but this time calling getBAYCPriceAt
with at
set to a unix timestamp such as 1645215894
This will update the price on the consumer contract. Note that with current architecture, the contract only stores a single price
And just like that, you can consume smart floor prices on-chain via on oracle!
Happy Ethereum hacking! 🛠
Go to our chainlink example repo and copy the code from .
Go to and create a new workspace/contract - paste the code from the repo into it
If you're curious to see more details about the job's execution go over to , click into the job and explore the previous runs
If you're experiencing problems, try reading of Chainlink's docs, which describes the same steps above just for a different contract. Replace the code there with the code from our repo and everything should work