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

Loading player…

Learn how to Pull Prices and consume Random Numbers I Aditya Arora

ETHGlobalTue, Dec 9, 2025, 12:00 AM

Join Aditya Arora for a workshop titled "Learn how to Pull Prices and consume Random Numbers", featured at ETHGlobal Buenos Aires 2025! _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 🇦🇷 *ETHGlobal Buenos Aires* This workshop is specifically for ETHGlobal Buenos Aires, a 3-day hackathon held November 21-23 at the Centro de Convenciones Buenos Aires, bringing 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! Watch the full ETHGlobal New Delhi 2025 playlist here: https://www.youtube.com/playlist?list=PLXzKMXK2aHh76O7FfAHPJkZcqTIfYpoyf _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ✅ *Follow ETHGlobal* X: https://x.com/ETHGlobal​ Warpcast: https://warpcast.com/ethglobal Website: https://ethglobal.com YouTube: https://www.youtube.com/c/ETHGlobal _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _Are you interested in Ethereum development and entrepreneurship?_ 👉 Sign up for the next ETHGlobal event: https://ethglobal.com/events 🎁 Get exclusive access and perks with ETHGlobal Plus! https://ethglobal.com/plus 📣 Want us to throw an event in your city? Tell us where! https://ethglobal.com/city

Transcript

I'm not coming. Okay. Uh, hi guys. Uh, my name is Adata. You can call me Adi.

You don't have to call me here. But I'm from PT network. Um, this I don't want because we are not a lot of people and I can't interact with people who are watching it online if they are. So I will be more interactive. So that my job here is that at least two four 6 7 8 and she knows it.

So nine people knows about pith very well and if you guys if want to build it you'll bid it correctly. That's all I want. So my job is to teach nine of you guys and I want to do it right. So this will be more of interactive session. If you want to and if you feel shy you can tell me I don't want to talk.

Okay. Anybody knows about pith basic? Any words that you can say? You don't need it. Any words that you can say about pith that you know, just shout it.

Perfect. Oracle. Yeah. So, we are Oracle. Oracle means we get data from outside of the chain world or our small world and get it into web3 world.

But we only deal with market data. What's market data? It's like prices, crypto prices, stock prices, commodities, equities, meme coins, forex, these those kind of market data. We bring it simple. And yeah, if you have any questions, just say it.

Don't have don't you have to raise hands. Just say it. Disturb me. I'm okay with that. data to us.

You can ask us but you can't do it permissionlessly by yourself because we don't want to give any data out there because everybody can use all the data. Uh he asked that can we bring any data from ourselves to which I answered you cannot do it by yourself. We have some trusted sources. We call them publishers. And we want more s like we want to have a data which everybody can trust.

Okay. Simple. Well, go ahead. How is it different from any other oracles? That's a thing.

And uh one thing the question he asked, can we bring our own data? We have some specific publishers who are like we source it from their their first party publisher. They're not coin geko, coin market cap aggregators. It's the per people who are actually generating the data. That's where you get that.

That's one thing. But as an engineer nowadays in in hackathon, you won't care about that. You want good data. And how's it different? We can send data every 400 millisecond.

Every 400 millisecond. Yes. Millisecond. So the reason is if you want to build like a perpetual future option or any fast trading application on chain you don't need 10 minutes all Ethereum data you need the data right now real time and that's what we do that's the big thing and how is it different now this is something I want to spend more time on rather than actual code because you guys know how to code that's why you're here but you want to understand how this work there we have four new guys here. Sorry, I pick pick on people in the workshop and make them uncomfortable, but that's how people learn.

Okay. Oh, what's the difference? We have other oracles which I can't name because of legal issues, but we have other oracles out there and how they work and we have our own pull architecture. The difference is between a push and pull architecture is you as a user, you go to a blockchain and you say, "I need tell me any data. Yes.

Yeah. Better. USDC. We know that. $1 price of ETH.

Okay. How would you ask them?

Thank you for correcting me.

No, no, you're right.

Yes. A deep d. And we don't hardcode it to one. We always take it. So you want ETH price.

You go to a smart contract like dude give me an ETH price. And how does that data come on the chain? Can anybody guess? Who did that transaction? He said transaction.

Who did that transaction?

The Oracle provider. And when you do the transaction, you have to pay gas fees. So he's paying money for your data. And there are so many prices out there. We support 2500 plus prices.

And if I'm start putting every price, every millisecond, I don't have money. Not even my company has money. So we can't do that. That's why other oracles can only append every 10 minutes or every 5 minutes, whatever the heartbeat they set or any price goes up and down. Oh, 1% going up.

It's volatile. Let me push some prices. That's how it happens. Any question with this architecture? Simple.

Somebody's there pushing prices. You are like I'm consuming it for free or whatever the money you are paying them. Simple simple database ledger all that. In our case, we saw there's a big gap here because you don't have authority to get the latest price here. So what we did, we made we have an Oracle network where we have all the prices.

We want users and the DAP to retrieve prices whenever you want and we will verify the prices on chain. Let me break in two parts. You retrieve the prices by yourself and we will verify because if you're retrieving the prices, you can change it. I can change E to 10,000 I'll be rich and I put some position out there but somebody has to verify the prices. So we also verify it that you're not changing the price in between.

And how does we do that? I'll work try to teach here. But this will give you more understanding how we work and why we are different and why you can build fast applications using pith. Okay. So the difference is you have to pull the prices here in other you can just consume it.

And just a small thing you can use as a push oracle by creating a bot. We already have a bot which keep pulling the prices for you. Okay. Now, any questions? Are you sure?

I I can ask some people who are not paying attention here behind. I'm just I'm just kidding. Oh, okay. I'll do one thing. I don't like to code here.

So, I'll just show it in front of you how we can do all of things by traversing through our docs because there's so many things and I don't want anybody to get confused. So when I say you can pull prices, you are pulling prices from an Oracle network. So you we have a service called Hermise which is like which connects to our network and give you the prices. So I being very raw open the swagger file. Okay.

And I like I need price for Ethereum. I just hardcoded the feed here. But I'll tell you how to get this feed ID. I have the pointer. Sorry, it's fun.

You can get this. I'll tell you how later. But if I click on execute here, you see it gets a blur of some data. Okay, but you get the price here. It's an offchain.

No blockchain here till now. You see the price here is the price exponent and the publish time. It's actually right now like 2 seconds back because it's been 2 seconds I press that button. Okay, this is simple. You get the price of chain.

Now you this is was you pull the price now you want to verify the price on chain the second part that's how you can do that you have a question sorry so in our price fields if you go to like guides in pith core just we're working on the pith core using pull integration in EVM contracts you can see the contract is only of three lines one two and three I'm not good at pointing But yeah only three lines. The first one is with get update fee and one transaction you can verify more than 150 prices and we take one way or the lowest denominator of Ethereum. That much that's nothing to verify prices. Second line update it's not working. Yeah.

Hey update price feeds here. If you see there's a price update here. This is the blurb that you saw in that file. This blurb that you saw here, you copy this, you paste it in the Ethereum contract and it will update it for you. And after that, you just consume the prices with get price no older than or get price here with the time 60.

Like if the price is older than 60, it will give you an error. You can change it by 5 seconds, 500 hours, whatever you want. So using this in three three lines of code you can fetch the latest price. So you fetch it from a web two API. There's a sign data which is like the blur of big data.

You pass it in the function. You get the I have a very thick Indian accent. I just realized I was so you sorry you pass it in a P you update it and you get the price. was a very bad explanation.

So we already have the contract which will verify for you. you you just have to

okay sorry I forgot that he asked that do we have to write this contract by ourselves or do we really need to verify every time am I right so if you want the latest price you need to fetch the latest price and uh you need to verify it you just have to call pith update price feeds and this will call our contract on that chain on whichever chain you're building on and it will verify it for you. So you don't have to write just three lines. If you're using any other oric color or any tool out there, you have to call their contract. Even you have to do a swap and unis swap. You have to do unis swap b2 dot swap and do that same thing dot update price and then

so what it does it like if it fails the price was not updated or like it doesn't need to be updated and what it does we maintain a state variable of every price it will update that. So suppose you update the price and then she comes and like I want to use the same price and she doesn't have need to update it because it's already been updated. But if she wants you updated 5 seconds back but I need it right now then she have to do it again.

Okay. Yes.

So if yes the he he asked that what will happen if you do the just last line and not do all of that. So in the last line if you see the second argument is 60 seconds. If anybody updated that price in past 60 seconds you'll get the price free. Yes. If no if nobody did it it will give you a stale price error.

So if you get an error, we have a page in the docs of troubleshooting the errors and you can see what does the error mean and you can see was a steal price that means you have to just update the price and to learn I have set a no not I personally but we have set a rule in this ETH global bounty that I want everybody to update the price once just put these three lines and call her and use it that will make you qualify if you're using directly or using a lot of people what they do they just call Hermes and use it on front end don't pay no we're not giving prices for that so you have to do this remember that this is kind of a I written in bold on ETH global website you have to call Hermes update it please because we get so many submissions and they don't do the right job even though projects are amazing but they don't read the contract. So if if if this transaction being originated by a wallet, they have to pay. If it's called by any other contract, the the contract will pay. But it's one way it's

Yeah, but it is. So you have to make this method payable. That's a big thing. Don't forget to make this payable because it will take money from the contract or EUA. Simple.

Okay. Clear? Okay, clear. Perfect. So, and we have 10k bot for price feeds and 10k for random number.

It's called entropy. Okay. And I'll explain. How much time do we have?

Yeah. 15 minutes.

15. I'm saying. Yeah. 6 minutes. Only 20 minutes.

I'll make it 10. Okay. So, this is next thing is entropy. It's like you want a random number, non-deterministic random number on your contract. You don't have to understand everything.

Don't worry. It's I just put it there to make it more complex. It's very simple though. So you need a random number, non-deterministic random number on chain. How do you do that?

We have 6 minutes. So let me directly go to the code. You go to entropy. Always go to the guides. Tutorials is a bit long.

You guys are smart. you you're good with guides. Okay, let's go directly to the whole contract. If you see here what we have to do, so it works on a commit reveal protocol which I will understand. We'll which I'll teach you how.

But before that, we'll go to the code. If you see this function, yeah, I love this uh request random number. Okay, you go to random number, you say entropy get fee like you ask how much fee I have to pay because it's a variable fees. You get the fee and you call this entropy request v2. Simple.

What it does? It will request a random number and in the next transaction or we have a delay. After that delay, it will call this method entropy call back which you have to implement in your contract because it will be called from us to your contract. It's like a call back function for any ERC 721 NFT when you are transferring. Similar you have to implement this entropy call back and it will give the random number in the argument and you'll get the random number.

Implementation is simple. Now if you want to understand how it works in behind and how it's true random I can help you with that. But before that if you have any questions with implementation I'm going to clear it here and I can help you with the the logic behind it later.

Yes. No next future block and you can see the f how many blocks after that will happen in contract and provider addresses the we are deployed on so many chains the random number and you can see the reveal delay for every block every chain. Yes. So the fee is not fixed because of different gas because we have to call a transaction for you. Oh the question was the fee why the fee is not fixed?

Sorry, you you stared at me so I remember. So why the fee is not fixed? Because the we have to call a transaction and we want it to land in the next block or the after the reveal delay. So we sometime have to pay premium when there's a lot of traffic on the chain. So that's why the fee is not fixed.

We don't change the fees way too often, but it's a good practice not not to hardcode a fee. you everybody understood the implementation for this or did I went just to

Okay. Uh uh we have a forum um if you have any questions we might not be available on the booth at the booth we'll try we'll be there but we get sleepy sometimes so you can please post on the forum our engineers are tagged when you somebody posted on forum and we have almost answered a lot of frequently asked questions on the forum so I recommend everyone to post it there if we are not there if you're there we'll definitely help you now I have time. Let me tell you how entropy works and if you start getting bored we can talk about something else. Okay. Uh okay.

Yes. Yes. Next block. It's a reveal delay. Delay.

He asked if there was written zero blocks. That means the same block that means the delay is zero block. So there's no gap in the next block. you'll get if the reveal delay is one block. So one block you leave one block and then you'll get the call back.

Okay, I'll try to be very short in this because I have three and a half minutes. You want No, I've already talked with you. You want a random number. Okay, and you ask me give me a random number and I am P. And uh what I will do is like I'll ask you just have one random number of yours.

Okay. And I have one my random number of mine. Note it down in a copy somewhere paper and keep it somewhere. You just give me the hash of it and I'll also hash it. And you will send me the hash.

You will put it on a blockchain. This is my hash. And the same block I'll put my hash on the blockchain. So nobody can change that if it's on the blockchain. Okay.

Now we will reveal our random numbers to each other. And then you can see we're using the same hash function that whatever the random number I said the hash is same and I can do the same. So we build a trust here and the final random number would be the hash of the both hashes. Let me repeat the final random number would be hash of the both hashes. So how does this happen?

If I have if I being malicious and like I can give any I can I want to hack your system but I don't know your random number but you will give okay if you want to be malicious you might give some number which you feel like but you don't know what next random number I will give so that's where it's called two-phase commit reveal protocol where you commit the random number and then you reveal it later and that's how you get the random number so you don't need to run air nodes or some extra things to generate random numbers or like lamps in some offices. That's how most of the people do. You don't need to do that. It's very simple, cheap, permissionless. You don't have to stake some tokens to get the RAM numbers here.

That's straightforward. That's how it works.

Number.

Yes, it used to be like that and it is right now like that. But a lot of people don't want to put that number and generate it. So we made we do it for you on the contract side. But if you don't want to do that, if you don't trust our contract, we if you see that we have this uh what is that? Set custom gas limits.

Yeah, you can add you can add your own random number while you're calling request v2. It's

yes request call. Thank you. So if you see this is one request v2. You call it you get the random number since so you saw the entropy call back method you have to write it can have a very complex logic and we have a default gas but if you want that you we want to run your big uh big complex logic you can increase the gas limit by sending the specific gas limit so the fees will be increased and yeah you can put your own user random randomness to increase more security if you want to but it's already secure It's just before we wanted everyone to put their number but it was not a great developer experience so we do it for you guys we have a booth I'll be outside after this workshop there are a lot of things that I covered here take your time read it if you can't understand I'm there Nidhi another devil here she will explain you everything she has a lot of videos she have explained everything in detail and she does a very better explanation than me. So you can watch those videos as well.

And yeah, I have one small thing last uh where's my slides? So one thing we have done here, we are doing a very small uh kind of a giveaway kind of a thing. Uh it's exclusive. Don't share with every hackers out there. You guys are here.

So I want to make it exclusive. So we are giving a we have launched a new product and uh what's the new product is you can get prices every millisecond realtime prices and we are selling it for 10k a month right now to institutions out there since you guys are engineers we want to get more feedback and we want to see some cool projects to be built so as soon as you go to this link there this form which will ask name and email id that's it you fill it you'll get an API key with a lot of links And you can use it for a month for free of cost. I'm not taking 10K from you guys. And build anything. You don't want to build anything, don't do it.

If you build anything, share it with us. If you want to build a bigger project, you want more help in that technical or long-term help. We're ready to do do that. We just want more feedback from you guys. How does this product look like and everything?

And actually, we're selling for 10K. I'm not kidding. So even I'm surprised that we are giving this away and that's it. Thank you. This is the link for the forum but this is already is in the ETH global website.

Yeah that's it. There's another thing that I just got to know. have five more minutes to talk but if anybody wants to talk or anybody ask question or about pet.

Yes.

So are you looking for projects more in like financial sector or can it be something completely different like healthcare for example like we have a we are building basically like proof of sleep protocol and uh we would definitely use the entropy there and yeah is that okay? Are you looking for like some crazy projects or is it only like trading finance and all this kind of usual stuff?

See, if I wanted a if we wanted a usual stuff, we would have definitely mention it. The one thing we do, we don't mention any type of use cases. We want to be surprised. And that's why I don't want to limit you guys. Just build the best DeFi out there or prediction market.

Build it like use price for your healthcare project. I don't know how will you use it. If you use it, we like it. We're happy to support you guys. We will also learn from you guys.

So yeah, there's no limitation. That's the answer.

No, you might have a big question. Take the mic. I don't want to repeat.

So we are fetching data from uh Hermes that is offchain, right? And then with that three lines of code which you mentioned we are verifying the price. I just want to know how the price are getting verified on chain.

That's a good question. That's a very relevant question.

I never covered it because I don't need to answer unless someone ask. So uh we are sending 400 uh prices every 400 millisecond. We're sending 2500 plus prices every 400 millisecond. What we do? We sign the data.

We create a Merkel route of that data and we send it via bridge to all the chains out there. So when you go and you're like I need to verify the price, we then confirm with a Merkel root of that signed data and that's how we know that you have fetched the data from Pithnet or Hermus. That's how we do it. So it's basically you are I am not sending the whole price only the prices that you need to verify then we fetch it. Oh what's your name?

Sorry. money sends some prices should I is it right or wrong then I go and I are like oh yeah it's right that's how we verify so it's on need to know basis kind of a thing that's why we don't overload any of the chains out there we don't overload us and that's why we can scale so quickly on every chain so you don't need to you know what have different price feed contracts on every chain there's only one contract it's contract we have like price feed ids that you can get like you can this is a page if you go in the pit core price feed ids you can search for okay there's a page uh it's it's not working here

we support 110 mainets and uh the price ids are same for every chain so you can go there and you can update the price so if you update the price on base chain that doesn't mean it will be updated on polygon you have to update there basic

no no so we do update prices on some chains by ourselves which is like every hour based you can find that into push feeds so when you go to documentation and it'll be like two ways using pull integration using push integrations in push integration we are updating the prices for you on some cadence or some heartbeat as heartbeat and threshold You can use that but that won't be eligible for the bounty. I always say if you understand how the pull works and you use push feeds you will be eligible but you have to show us in one way or another way. So stick on the pull for this hackathon. But if you're building a project where you need only push feeds go for it. Okay.

All good. I'll be outside. Nidhi will be there. There's another engineer happy to help you guys. Okay.

Thank you.

Automatic transcript — names and jargon may be misspelled.