As we are preparing to release a public testnet "Dystopia" proof of concept as a Polkadot parachain, we tested a first implementation of an offchain-worker.
It's quite simple now and it fetches price from Cryptocompare API, but we can imagine it can also fetch prices from different sources like Coinmarketcap, Coingecko... in the future, with average calculation, variation checks etc.
Code is adapted from Substrate developers Hub recipes, with main functions, one for fetching price from eternal API with http get :
And one for parsing result :
Compiling, and... it works :))
yes, there's a f32 conversion before printing.
This is a part of DarkBay incoming preview, stay tuned !