New Ethereum talks, every Monday. The week's conference uploads by event, in your inbox.

Loading player…

Flare Workshop - ETHGlobal Bangkok 2024

ETHGlobalThu, Oct 9, 2025, 12:00 AM

Join us for a Flare workshop with Filip Koprivec from Flare Network, and learn how to use external data to build your first on-chain app on Flare. This workshop took place at ETHGlobal Bangkok, a 3-day hackathon held November 15 to 17 2024, that brought together the most skilled web3 developers, designers and product builders from all around the globe for a weekend-long adventure to advance the Ethereum ecosystem! ----------------- Follow us: https://x.com/ethglobal Check us out: https://ethglobal.com/ Email us at: hello@ethglobal.com

Transcript

[Music] okay so let's start so flare what is flare flare is blockchain for data so flare is a evm layer one blockchain totally independent um but apart from other blockchains we allow you to get access to decentralized data in a safe and secure Manner and also very cheap and very quickly so it's easy to use and it's safe to use so if you're on blockchain that's a data source you should consider and let's just quickly go through things you should be focusing on on this Heaton so flare is an evm chain what does that means that means that everything you already know about evm chains solidity hard head Foundry anything you want to use all the toolings are already available um and what we're challenging you to do so what we want you to do is to build on this CVM chain with external data we're offering 10,000k in rewards um to effectively do two different things um and they are the most important so one is to utilize the FDC the flare data connector which allows you to connect external data to blockchain so it allows you to bridge something that you can only see in external world use it on chain and be sure that this is secure and secured by the whole stake in the ecosystem so it's not a multi it's not a single party moving data from offchain to onchain but it's something that the chain is doing itself and the chain is making sure that it's secure and the second thing you can use is the fdso which is shorthand for flare time series Oracle which allows you to have realtime pricing data directly on chain what does that means and we'll show this uh in the workshop it allows you to get the price of a specific asset in real time every block on chain and again as with the FDC as with all that's available on flare you know that this is secure by the whole network itself so you can always make sure that the data you're getting is correct and nobody can hamper it in the meantime uh so just a few words how that works because it's important to know exactly why you need this data and how you get it so the fdso is a decentralized price Oracle you have decentralized price information that is operated by the state network of validators so we have this directly enshrined on chain and this allows us to have the flexibility the speed and also the security lels um and the prices are updated every block which means that you get a new price every second or two seconds depending on the Block time so we use a pretty fast blockchain so you want to get prices fast and also our blockchain makes sure that the gas fees are low and we're not adding any additional fees on top of it and then the FDC FDC allows you to get the terministic of chain data so anything you can see in external world can be bridged by FDC to chain and then since you're on evm chain the only limit the only limitation you can have is what you can think of um so a few specific examples so we support all evm chains currently we are deployed on we we support ethereum supp ethereum and test Nets of ethereum I mean some Cosmos chains but you can come to our Boot and ask us and we'll quickly add a new chain just so that you can see and you can play around with it so if a chain is evm compatible we can quickly add it specifically for this Heaton so you can try and see what else you can get from that chains and from EVN chains you get the most important thing which is events so you can attest to specific event happening on an evm chain and then you can use this on flare to do something else so you can attach to a Unis swap happening you can attach to a transfer happening you can attach to an NFD burning and then upon this nftd Burning you do something else on flare and have the connectivity uh we also connect to some socalled non-smart chains BTC doco and xrp Ledger um and we also give you information about them so what this means well this means that you can get information about the Bitcoin transaction move it to flare and once this is on a smart contract Network you can do anything you want with so this allows you to collect payments in Bitcoin this allows you to collect payments in xrpl and it also allows you to then do some work on top of it and combining this with FTS so you can always know how much you you have been paid in dollar value because you always know how much the underlying was worth at that specific point and and um apart from this we also connect to custom web to sources which is uh one of the additional challenges in this hecaton which is invent your own web to data source invent your own specific attestation type connect to a new API we haven't thought of bridge data to flare and then on flare do something amazing with it so use the data you've been Gathering use it get it on chain and then do something that is only possible on blockchain because of those trust assumptions and then we also have some additional things so we also provide you a free and readily available random number directly on chain um as a byproduct of all other protocols well what you what can you do with a random number on chain well think gambling think U something else think pretty much any luck you would like to involve but you can also use it in some other things for example you can sample some stuff you can add a challenge for somebody to prove something else and this is again available all chain and secure and we've been connected by a layer zero to all the connective networks through layer zero so this means that any data that you have on chain or anything that you do on flare can easily be relayed by a layer zero and also by Stargate to any other network this means that your applications can now become data very rich while also incorporating other networks making your application truly multi-chain and knowing that the data that is coming to your application and the data that is guiding your application is secure and makes sense okay so um and just a quick quick uh quick talk through this so evm compatible Oracle Network what you get you get all the nice things without any limitations low transaction fees access to all the tooling um you get tc20 tokens nfts all these things for free you can use open Appling libraries we provide all these directly on check so there's no change here the only thing you need to do is you need to change to a new RPC and you have a better Network faster Network cheaper Network and better data okay um and let's see the thing that we're kind of focusing on on this Heaton so as I said before we offer three different protocols one is the fdso for pricing data one is the random number and the third one is the FDC so we're going to take a look at how to use FDC and fso in this Workshop um and one of the things we're going to check is a custom Json based web API so what this allows you it allows you to build your own post processor so pretty much it allows you to take arbitrary code put it on a verifier server let the verifier server run this arbitary code which is then run by the whole set of attestation providers on flare which is the same as the validator set so we bundle those two roles together and then you can attest to this computation on flare so what this allows you to you can create for example any Json API you can find in the wild what you do you Source you create a source that is able to read this API you create a post postprocessing code that is able to postprocess this code to something you can then use and then this gets attested to in a decentralized manner to chain and once you're on chain you can directly use it for whatever you need to do and we're going to see how you can use this in a weather example when we're going to take an open Weather API we're going to check the data we're going to postprocess it to something nicer so that you can use it on chain and in solidity and then we're going to uh see a simple smart contract that just verifies that this data is correct and then uses this weather for whatever you need to do here the sky and your imagination is the limit okay so here's the workshop you can scan this um if you want to work with me otherwise this is all on the notion page and if you run into any troubles we're just on the other side of the this uh big space uh just on the left side of the main stage you can find us there those boys and girls in this pinky uh pinky branded uniforms and you can ask us a question okay so let's see how networks uh so the first thing we're going to check is uh is an example on how to gather the FTS data how you can easily get prices on flare okay let's en large this can you see this can you see this now okay so this is the fdso contract so the fdso contract allows you to gather data from chain so we made it as easy as possible by using our periphery contract libraries which allow you to connect directly to the necessary contract so and here's a simple smart contract I'm not going to write it I'm just going to guide you through it and the only thing you need to do is you need to get the fso in our case we're going to be using the test fso which abstracts even more things away but on a real Network the only change is that you have to make a call a bit differently but it's a it's a minor change and we're going to use the feed ID converter that is going to be useful in a later stage when I'll show you how you can get a bunch of these things in the same call and the main thing you have to do to get the price is pretty much call the fdso V2 get feed ID and provide the feed ID you want to use so we currently support 50 different feeds directly on chain that are refreshed every second and that's the and that's all you have to do so get feed ID for feed flare slusd okay and you can see this is encoded into bytes 21 this my seem a bit daunting but in reality this is just Hax encoded FL LR slusd so you can easily decode this back and present it to a user in a nice way and um in another perspective so you can get a bit more generalized way when you allow user to provide your feed ID but if you want to be really really nice to user the only thing you need to do is you can get a feed name from the user and you just convert it using our library for conversion and this conversion I can show show you that this okay it's an interface but this conversion is just Hax and coding which is just AI um ABI encoding two different two separate bytes and this is just the conversion okay so that's how you get the prices and then in the same contract so this is also available on the notion page so you can check the contract there's a starter pack that contains all the necessary information um and then there are just a few uh nice auxiliary methods which you can use to check which feets are available how you can query them and so on okay and um of course I have to do this but uh no demo is as good as a live demo and to deploy this since we're an evm chain the only thing you need to do you just need to create a new contract and deployed and also in this hardhead reposit hardhead starter pack uh will automatically verify this for you on a on a flare Explorer and so you can easily check this and play around with this okay so the contract has been deployed and let us just wait for the verification status and let's open this okay that's the deployed contract and as I said before we're an evm chain so all the tooling you're familiar with is already available you don't have to change anything okay so you have a contract what you need to do you can read the price and let's let's see what the let's see which feeds are available by name and you have okay here's a bunch of feeds that are available and I'm just going to copy that one and check it here and I just read it so this is a simple example if this were your smart contract or adap you would just call an RPC with that so we get a price for Bitcoin and we also get some additional information so how many decimals is it in because you don't want to use floating numbers in solidity we already encode and decode this into nice uh uint representations and we also give you a time stamp when this was late lat when this was um last updated so you can always know how good your prices are and how stale they might be okay so this is the fdso easy to use directly on chain methods that you can read yeah yeah the time stamp is just the block time stamp when this was latest updated so we wanted to make this as simple as possible so you can compare this to block stamp and you're fine okay so this is FTS so using the um random number would be the same you pretty much just take a different interface that's available in a long-term support interfaces and quer the random number now the fun part that you can do is is these so-called arbitrary data types so what arbitrary data types allow you is to do the following so you can def so we're going to do three things in a succession but we're going to do them quickly because this is a workshop if you want to know this into detail just come to the boot and we'll show you a bit a longer tutorial how to do this so um what Json API allows you is to set three things so you can say I want you to go to this URL I want you to postprocess this URL with this JQ and then I want you to encode this JQ postprocess Json into a solidity data type and what that allows you is you can say okay we're going to go to the weather API we're going to get some information about the weather in Bangkok we're going to postprocess this with JQ to a nice representation that contains only the things we want to know and once we have this I'm going to provide you with an AI definition for a solidity type so you can encode this into exactly the structure I'm going to use later in my contract and what this allows you this allows you to take an arbitrary API say how you want to postprocess it and then use it in your contract how however you want to use it okay uh so how does this look like um we have a specific server that you can run locally and you can say the following we're going to go through this uh in a few steps so just so that you know how all this looks okay so this now fails but the important thing is this so we first make a request to a weather API and we get back a Json like this so and what you're providing to the verifier server is this URL so please check this for me we're going to copy this to a JQ playground apply the JQ transformation and we get back this okay so this is the so we start with an arbitrary API we set a JQ response and we end up with this so I've passed out just the specific Fields I want to use I don't need clouds I don't need visibility but I do need latitude and longitude temperature and I immediately multiplied this by a million so that I again lose the decimals I don't want to use the decimals I want to be in solidity nice types okay and if you can see it's a bit hot in Bangkok can you say why why is it so hot huh yeah near the equator but it's still a bit too hot why because this thing is returning uh this thing is returning the temperature in Kelvin so and we don't want to do this in solidity so what you can do you can just change your post processing and change this to Celsius apply the post-processing again and say okay so please is return this in Celsius and the only thing you need to do you need to provide this to the verifier server so you have the input you have the postprocessing and then you just need the encoding type okay and let's see how this really looks in this um in the code okay so what you do you you first ask an offchain server and you say the following okay request body I want you to get to to this URL I want you to postprocess this by this specific JQ and then at the end encode this to this specific structure and this structure is the same as the one you then use in your solidity code you see the idea and what you have to do offchain is the following so we've mocked quite a few of the things for hackaton so we don't have to go through all the consensus algorithms um we just always make sure that your data is correct and then what you do on the on the offchain site you just deploy a contract that uses this um API instance and then add this full response so you add this full response from a server you add the you add whatever the verifier server gave you and you put it to a contract and when you in a when you are in a contract the only thing you need to do is the following you need to check that this is indeed correct so you need to check against the Merkel root of what the verifiers here come to that this data point that the verifier is providing you is indeed correct because otherwise anyone could give you the data on a smart contract so this is the security part and after that the only thing you need to do is decode the response why do you have to decode it why can't you use a a custom data type beforehand because we want to keep the message payload as general as possible so if you change the JQ and get some new data you will now have to decode it to a new structure and that's why at the end and it's up to you so you can change your JQ in a very specific new data that can compare stuff that can compute stuff that can run a python script practically to do something and then it's just up to you to properly decode this and once you have this decoded as a solidity struct it's up to you to do something so here I just push it to a to a set of uh to to a list of weathers but I could easily do if I don't know if let's say weather Dot temperature is greater than let's say 20° remove the last one um yeah okay so the easiest thing you could do here is you can do some prediction Market you can do some insurance on top of it it's pretty much you can get any data you want on chain and once it's on chain it's up to you to do whatever you want to do okay so that's it [Music]

Automatic transcript — names and jargon may be misspelled.