Plato Data Intelligence.
Vertical Search & Ai.

End-to-End MongoDB GraphQL Database, Chainlink External Adapter, and Oracle Contract on Ethereum

Date:

Data Flow of FidoByte

Here are the three steps we will cover

  1. MongoDB Atlas and Realm
  2. Chainlink External Adapter and Node Job Spec
  3. Oracle Contract and Decoding Bytes

MongoDB Atlas and Realm: A Fully Managed GraphQL API Solution

The randomly generated dog walking data is here, with 500 walks from 55 unique walkers. MongoDB Atlas is easy to navigate, just set up a project and create a collection. Then, take your data and insert it as JSON to fill your database. If you need to go from CSV to JSON easily, you can check out this site.

const app = new Realm.App("petproject-sfwui");await app.logIn(Realm.Credentials.emailPassword("[email protected]", "test123"));

Creating your Chainlink External Adapter and accompanying Job Specification

Okay, so now we have an authenticated endpoint for our API — but this makes getting data on-chain a little more difficult. If you just want to make a GET request to a REST API, then you can use the Chainlink GET adapter with any job specification and just pass the URL and copyPath that you want.

Creating your Oracle Contract to make your query and decoding the return data

You’re so close to being done now! Lastly comes the Oracle contract. There are three key items here too:

  1. It’s up to you if you want to create functions to set the jobID, Oracle Address (Node Address), and Fee (typically 0.1 LINK); or to just set it in the constructor. For sake of simplicity in this project, I set mine all in the constructor. Make sure you have setPublicChainlinkToken() in there otherwise your request will NOT go through.

In Conclusion

Oracles and off-chain data can get confusing, especially when it then comes to decisions on how to responsibly manage and decentralize these feeds. While we are still in the early stages of figuring out what should and shouldn’t be stored in smart contracts (due to speed, storage, cost, privacy, and other considerations), there is no doubt that this will become more and more complex in the future. Knowing how to create a Chainlink External Adapter to manage complex queries and authentications is a must have skill in Web3 development, and I hope this guide has helped clear any blockers in your way. Feel free to reach out to me if you have any lingering questions, I’ll be with other developers in the Chainlink Discord.

Join Coinmonks Telegram group and learn about crypto trading and investing

Also, Read

Get Best Software Deals Directly In Your Inbox

Source: https://medium.com/coinmonks/end-to-end-mongodb-graphql-database-chainlink-external-adapter-and-oracle-contract-on-ethereum-2f2c5b8df6ce?source=rss——-8—————–cryptocurrency

spot_img

Latest Intelligence

spot_img

Chat with us

Hi there! How can I help you?