Using Ad-hoc data feeds in your smart contracts
Jul 11, 2023
Ad-hoc data feeds are used by smart contract developers to retrieve off-chain data on an as-needed-basis.
For example, a dApp user takes out a loan against an NFT and needs to have the collateral NFT valued. The user clicks a button and the smart contract sends a request to an ad-hoc data feed asking “what’s the floor price of this NFT’s collection?”. The request is received by one or more Chainlink nodes which query an NFT pricing API like the one provided by NFTBank. The nodes submit the answer back to the price feed smart contract which in turn returns the value back to the NFT Loan contract.
The ad-hoc data feed model makes sense in this scenario because the number of NFT collections is vast and creating individual price feeds for all of them would a big undertaking and cost a lot in gas fees to maintain.
If you had 100 NFT collections Bored Apes, CryptoPunks, Moonbirds, etc. each with 5000 different NFTs, using the aggregator model you would need deploy a price feed contract for each of your 100 NFT collections. Each price feed contract would need one or more nodes to supply the data from the external APIs. Finally you would need to manage the funding of each of those 100 price feeds, a daunting task in itself.
The ad-hoc model is simpler and is closer in design to a traditional web2 API call. Its relatively easy to make a simple off-chain request using Chainlink. To make an ad-hoc data feeds robust you need put a bunch more work in covering areas like wallet management, role-based permissions, support for decentralisation and a lot of testing.
At Translucent we’ve put the effort in to offer you data feed templates that form the essential barebones of your custom ad-hoc data feed. Our data feed templates allow you to focus on the data you’re needing to bring on-chain, both simple as well as complex data types, to drive your smart contract automation.
We suggest you start by using our ad-hoc data feeds to bring the data you need online. Then when you’re ready to grow and you need more decentralisation, adding more nodes is just a couple admin calls on the data feed contract.
Advantages
ideal if the data feed is item-specific
data is always up-to-date
support for complex data types
Disadvantages
each request costs gas
We can deploy ad-hoc data feed contracts to all our EVM testnets and mainnets on short notice to get you started quickly. Once up and running we can transfer ownership to you for the continued running of the data feed.