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

Loading player…

Aditya Arora I Pyth Workshop I ETHGlobal Prague 2025

ETHGlobalThu, Oct 9, 2025, 12:00 AM

Learn how to integrate Pyth Network’s real-time price feeds and VRF-based random numbers into your blockchain projects in this ETHGlobal Prague 2025 workshop with Aditya Arora. Discover the difference between push vs. pull oracles, how to fetch on-chain/off-chain data via Pythnet, and optimize gas costs with multi-price updates. Explore use cases for crypto, forex, stocks, and metals, and master the Entropy VRF system for secure randomness. Includes live coding demos, bounty details, and Q&A. Perfect for DeFi builders, hackathon participants, and Web3 developers! 00:00 - Introduction to Pyth Network & Oracles 00:52 - Pyth’s Price Feeds: Crypto, Forex, Stocks, Metals 01:46 - Push vs. Pull Oracles Explained 02:20 - On-Chain Price Updates & Gas Costs 03:41 - Pythnet: Decentralized Data Aggregation 04:24 - How to Pull Real-Time Prices (Demo Prep) 05:40 - On-Chain Price Verification & Security 06:21 - Hermes API: Fetching Price Updates 07:14 - Live Q&A: Block Latency & Data Freshness 09:03 - Step-by-Step Price Update Demo 10:21 - Bounty Requirements & Best Practices 11:37 - Handling Price Timestamps & Conflicts 14:06 - Hermes API Walkthrough (Code Demo) 15:25 - Formatting Data for On-Chain Use 16:46 - Price Feed IDs & Cross-Chain Compatibility 17:23 - Historical Data & Off-Chain Lookups 18:09 - Data Authenticity & Publisher Networks 19:25 - Entropy VRF: Decentralized Randomness 20:43 - Hash Chains & Callback Workflow 21:54 - Implementing VRF in Smart Contracts 23:12 - Price Pusher Bot for Push Oracle Mode 24:38 - Final Q&A & Hackathon Tips _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 🇨🇿 *ETHGlobal Prague* This workshop is specifically for ETHGlobal Prague, a 3-day hackathon held May 30 - June 1 2025, 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 Prague 2025 playlist here: https://youtube.com/playlist?list=PLXzKMXK2aHh5Vv-ZobDU2YMWekDFYvOqd&si=SoQ5O2TOAK8RkYf- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ✅ *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

[Music] Okay guys, uh this mic doesn't work. It's only for the streaming. So this I have to hold it. If I forget, if I remind me, interrupt me. Okay.

One thing anybody knows about pith? It's called pith. No bite. Thank you. Anything?

Anyone knows about PT? Good. Good. And anyone who doesn't know anything about PT? Perfect.

Fine. That's my job. Anything knows about oracles that I believe everybody. Anybody can tell. I'm saying anybody a lot of times.

What's an oracle? Just tell me. Shout it. This is not a normal workshop. You guys have to interact.

Anything else? That's right. Correct. Of you want to say anything. Okay.

Yeah. It's part of that. Okay. Agree. So combining all three data provider com offchain data bringing it onchain oracle.

Simple. But the difference is as compared to other oracles we only deal in prices. You need prices we give that any chain anywhere we are working on Ethereum but we do all chains all different frameworks that I don't know if they exist right now so prices means crypto basic we'll start with that forex stocks uh metals gold and all that so if you're building anything with those prices you can use PT meme coins also but meme coins have low high liquidity so let's not talk about them And we also have there are two bounties but we also have random number provider which is VRF function bit different. So I let it be uh even though you want to build with you want to use prices you want random numbers I'll explain both if time permits how is it different first you have to understand that which is very crucial for using pith. So you know in blockchain let's think about like a database for right now.

It's not people will get angry if I say that it's like a key value database. So if you want to retrieve something I want price of ethereum right now. Ether sorry what it would be like $3,000 I hope. So I have to go and retrieve that but somebody has to update that. It can't be on the blockchain like you're building on like arbitrum.

You're building on mainet both has to have $3,000 price. Somebody has to update it and update cost gas. So who is updating it? Yes. In all oracles that you probably have used or heard of who is updating those prices?

Oracle provider basically they are updating the price. But if you're building something, you want to buy something with like 10 E. Okay, you don't want to use the price which is like 10 minutes or 15 minutes old. You want right now price, not even one minute old price because prices change. But those Oracle providers, any Oracle provider can't update the price every second because it's expensive and they have so many prices.

For example, we support 1,500 prices. If we start updating 1500 prices on every chain, I like we don't have money. Nobody has that money to update 1500 data points every millisecond. Prices are valuable. They can be updated every millisecond as well.

So that's why we changed some things. So when somebody updates a price, it's called push oracle. They are pushing the data on the chain so that you can use it. Clear? You can ask question anytime.

There's no Q&A because I will go along. You can ask anytime. Yep. I have some I used to have some slides but okay fine because I have seen that slice doesn't help. It's more of the if you understand the logic you can easily implement it.

So you understood about what's a push oracle oracle provider pushing prices you your contract goes reads it simple as that whereas in PT we you have to pull the prices that means we don't update the price we have a something called pithnet a decentralized blockchain for us you can't use it it's only for us where we aggregate all the data and we take data only for firstparty providers no coin gecko No coin market cap, no aggregators. We aggregate it. We take it from Char swab or winter mute or Jane Street these who actually have market makers or dexes. We take data from that. We aggregate into pithnet and it stays there.

Now you want to open a position on a long ETH and for that you need the right current price. What you do in your transaction? to ex take the data from the pithnet at that moment and update the price. So the difference is whenever you want data you have to pull the data. How that's another thing I'll tell you about that.

But the difference is whenever you're using a normal oracle you just say give me ETHUSD price. They give you ETHUSD price with the older price. You can't change that. You say I want right now but they can't give you because that's the latest updated. But in our case you can get price at that moment.

At that moment for us is 400 milliseconds. We can't go like our slot time is 400 millcond for now. So you can get offchain as well as onchain. So you get it offchain you read it there. Fine.

That's normal. But onchain what happens? It's a good question. So when the data comes you can see what the ETH price would be but you want to update it onchain if you want to consume there. So you update it with your transaction object.

We have a verification our contracts that we have deployed are just verify the data that you have passed because you can change the data. You took ETH price 3,000 USD but you can change to 4,000 USD before updating the price. It's it's up to you. But we verify that. We send uh like we send the digest of that data via Mhole and all the bridges and we verify it.

That's our job. Yes. Okay. So, so my my qu okay so the question was this I mean uh if I'm a um smart contract I have to have an instruction that tells me please update the data that information has to go on chain and then you can see it your system if I understand correctly will see it only on the next block okay so explain to me that part so what will happen are you before that I just want to clear that everybody's on the same stage Don't be embarrassed. You can ask question.

I'm here for that. Yeah. Sorry. I'll I'll come to you. I just want to have a same state so that everybody understands.

Uh if I understood your interpretation correctly is that say I have like a open C like NFD marketplace or some any kind of marketplace and I rely on some data. Some client comes in and places an order says I want to buy my version of some wrapped stuff basically, right? And so basically I have this market that I need to get this stock price so I can make this rap talking for my what this gentleman is saying that if the client executes the transaction at block t my contract will will will fetch data from pith in the same block. So it's like going to be like a chain execution client calls my contract something similar. Yeah.

Or what he wanted to make sure is that does your data come from block plus one. Yeah. Yeah. So he asked that if I want to extract something I have to first update it and the next one I will verify and give it back to you. It's a very bad model.

That doesn't happen. So what happens if you see here you have to extract data from we have a we call the service Hermes. We name everything on the Greek gods. So you take the data from Hermes which will be a array of bytes called price update. Since every update costs money, somebody we we have to take money from you.

So every update costs only one way nothing I can't even tell them tell that in cents right now. So every update cost one way. You can update 100 prices in one transaction also. So it's a bytes array. You take a price by uh price update a bytes array from homes.

I'll show you how to do that. Not very complex. Normal API service nothing else. You take that you put it into your argument you get update fee we calculate how many prices are there in that update suppose 10 10 way you call this method in your same meth function that you're calling you have to do that I have clearly mentioned in the bounty sorry to get on a tangent that you have to pull data if you just go and say get price sorry no that's not that's how push or works once you update it it will First check what's the last updated price. For example, Ethereum was updated 10 minutes before.

But you give me update data before 10 minus one. It won't update. It has to be after 10. It will check that it is after 10 and it will update it here only. And then you just go get price.

This method is get price no older than. So you can have a limit that I don't want price if it's older than 60 seconds. So you get the price here. So in your same transaction which you want to do you just you can have that verification happen in the same transaction not in the next block not even in next transaction is that clear actually for me it's not I mean I'm on a block right suppose I want it at latency of 1 second okay lat we have a block every 12 seconds so I'm running my uh uh contract execute it calls if I understand correctly your smart contract and uh your smart contract sees that I paid or whatever and sends me the data. But if I understand correctly, it doesn't send you the data.

It updates a state on the blockchain and that's reads it. It doesn't give you a call back. It doesn't send you data. So there's a state right now in that v key value pair on that key. Ethereum price is 3,000.

It updates to 3,500 for example in next block only you update that 3,500 latest one it gets updated in that state only and anything you do after that state has already been updated you consume it there's no call back there's no other transaction happening but if like when at the start of the block uh the price was 3500 okay and then like my uh contract executes like at halfway through the block after 6 seconds. Okay. During these six seconds, Ethereum is now 35100. Okay. And I ask uh your smart contract give me the price of Ethereum.

What will I see? 35. You ask the smart contract. You send the price update with the latest time stamp. So what will I get?

I will say at 3500 or 351 the one. So it's okay. So what will happen? You send the price update for t seconds. Yeah.

Right now the price something you send for t seconds he sends for t + 1 seconds before that and he executes it first you'll get t plus 1 second because price we check the latest time stamp okay and if I'm the first one who asks for a price so your t seconds will be updated okay but he also executes in the same block yeah know I'm happy for him that he got a free ride on thing but I mean yeah but I'm still I'm not clear how did I get the uh but the price I'm getting is still from the previous talk. Correct. How? No. Why?

Like if cuz how did the price I mean uh how did the price uh that the price change it happened from the start of the block uh get online. So when onchain so whenever a block uh like whenever block executes they have transactions they update the memory on state. It's not committed. But if your contract is executed over the transaction, it will take the temporary memory and then it will be your contract execution will change some states. Our contract changed some states and it all executed at once.

Cool. That's okay. Okay. Sorry. Uh if you guys have more questions like we can go on as many question.

I just want everybody to understand what's a polar. Sorry. Give me a second. He asked first. Sorry.

Yeah. Just a quick question. You mentioned you can ask for updates for many uh there you can do like a set and update update the same in the set and get it in a set like a 100 tokens at the same time. Okay cool. Yeah just before that I'll show that.

So if you see this contract just remember these three lines get update fee or like price update. This is the main thing that people can't visualize right now. I'll show you. So we have this Hermes. We can use it via websocket normal curl command API.

Uh there's no rate limit. You can use it offchain as well but that's not part of the boundary. We really want people to learn what's a polar. I go here. I want prices.

So I have some of the prefilled price feed ids. Price feed ids. Just remember it's all same. Even if you're building on optimism abstract or any EVM chain, it's all same. that doesn't change.

So I just add if asking so I add three just imagine they are different. Okay I can I I'm just being lazy to be honest. I can go here price that is copy three. Okay and just execute here. It's so difficult to do like this.

If you see this blurb of data big thing this is the price update. You copy this and don't remember there's one issue that everybody will have since we know solidly came from C++ it's so every string has to be started with 0x so you please add zero x when you put that the reason we never add it here because this her is used by salanos darknet apt c fuel so if I add zero xl they guys can't they have to remove It's easy to add. So just add 0x when you are sending it to your contract. One small thing and the price will her give you pass price. This will return from your contract.

So if you see this one the price is here confidence interval the exponents 10^ minus 8 and the publish time this is latest. So this is how her will look. So this will contain all three price updates that I just selected above. Question while we're here. Is there any way to get historical prices offchain?

Yes. Okay. We have that. I'll I'll tell you after this workshop because it will go along. I'm sorry I he asked question.

I either forgot or understood that it was not. Okay. I wanted to ask if like more users of the pithnet mean more efficient use of net. No. No.

No. Because prices there are 1500 price fees that we have that are that are updated 400 every 400 millisecond. So nobody can have 1500 400 millcond on all the chains. We support 160 chains right now including test nets. Uh is there uh a lookup table on onchain where you have basically for currency for on for 20 translation into this ID?

No, doesn't exist. No, that's very hard to maintain. We thought of doing that. It's very hard to maintain onchain. Again I'm again think we don't have a onchain registry for that and onchain registry for price feed ID is ETHUSD with the string we don't have that you have to go to this page I'll everything is are on a bounty every specific links I have already mentioned so that you don't have to confuse this are price speed ids page you can search everything just go don't change this this is for other chains like give me an example like gold was gold is xae or something X AU am I right?

Yeah. You just copy this, put it there in the Hermes, you get the gold price latest. Yes. How do you how do you verify the authenticity of the data? Because can anyone just publish um some prices and then update the feeds into the network from any source?

I can tell you the answer. Uh just want to ask I have 10 minutes. We want to get to random numbers or Okay. Okay. Just mind we have for every price feed that we have on pithnet we have minimum of 15 to 16 publishers out there.

Minimum total we have a set of 100 publishers and we don't just start any price feed. You just say XYZ memecoin give me price. We can't do that. It has to be some liquidity some publishers authentic that we trust. It all aggregates.

And sometimes somebody sends absurd prices. That's why we send confidence interval if you saw that. Oh, okay. Okay. And so do you have stock certification on your data?

Sorry. Stock certific. But I remember somebody asked the same question way before. So I knew the answer. It is there.

Or maybe some other certification. But I'll I'll I'll no trust me. I have to tell you the links and everything then only. Okay. Okay.

Coming I'll answer all the price questions. I believe people understood like 70% of what I have said that's enough for me for now but I'll be here. Let's go to uh random numbers. It's a bit different than other random numbers. It will have a call back which you will like.

So let's go uh to entropy. It's called entropy. And let's go to documentation home. Uh there was a line the difference between this and there are like a normal random numbers. How can we generate random number?

Such a big problem blockchain all that thing we figured out very small thing. So if you have a random number and no you want a random number from me how we can do that like any idea that send a request. Okay, but how will we generate a random number and how will you can authenticate if my random number is actual random? Simple. What we did, we ask you to send a random number first.

Anything? Yes, like a seed. Perfect. And we have a hash chain. A hash chain is a we take one random number and we hashed it millions time and we stored it.

Okay. We take one from there. You give me one, I hash it mine and you hash it yours. I don't know what's yours now. You give me your hash, I give my hash and we send we commit that hash on the chain.

I'm just telling the logic. We commit each our random number hash on the chain for now. Next block we send each other our hashes so that we can verify so that when you reveal I know that you already committed a hash you can't change that and I we can I can know that you are trustworthy and then we just combine two hashes and that's the final random number that's how the logic works how will you work on that pretty straightforward normal call back method you have already used it somewhere the reason I'm going through docs because the navig navigation. We working on the navigational docs so that you see how I'm navigating. Just go here and everything so you remember when you start because you're looking at a lot of workshops.

You might forget that's why I'm doing it in front of you. Let me show the whole contract. Okay. So for the random numbers you pass your random number you can generate with normal SDK crypto library no anything you get the default provider we only have one provider this the default provider is the one we call it fortuna it has all the random numbers stored and all the hashes everything fee all that and you said request with call back you send your own random number and the provider address you got from there and you have to implement this call back method in your contract. Very simple entropy call back and this will be called by our provider which will give you the random number and you consume it.

It's very straightforward three things you send the random number to our for first get the fees send the random number to a fortuna the provider and we will call you back with the random number consume it. It's straightforward. A lot of folks in hackathons use random numbers because that's a very common thing. You can use it anywhere. Prices, I can understand it gets difficult because you guys might not need the real time price which is our competency.

But if you use it, it's amazing. I have still five minutes. So before going for Q&A, I'll take five. Sorry. Before going to Q&A, another thing I have seen in uh the hackathons nowadays that folks who are using pith since it's a pol oracle and you know a lot of lending protocols out there a and all that people fork them and they don't want to change the contract interface if you see in a contract interface it was a payable method because you have to send the fees in native currency and nobody wants to change things.

So I you can do one thing we already have a bot we call it price pusher which will keep updating the pit price of specific feeds on specific chain that you want that normal and you can run in docker you can just clone it it's if it's in price feed schedule prices you can see that that's a like a like you know that I want to invest or like build something with stocks and pith is the only answer and I don't want to let users is to pull it. So you can push the prices by yourself as a DAP owner and let users consume it like normal traditional oracle. Sorry for that. Your question so you get one run number just hash it with different seats. Okay.

You save money with that. If you call 10 times, you'll have to pay 10 times. So, call back will give you one random number. If you go to our best practices is a very general question. Uh, okay.

Call back have a limit on call gas because we are calling it. So, there should be a limit. Oh, Sorry. My bad. It's fine in crypto.

So, yeah, that's why I show you get the random number. I just put it five random words. You hash it. you get five more random numbers in the same transaction. Okay, I will be outside.

We have a table. It's a very corner table. Can ask as many questions as you want. Thank you. Thank you.

[Music]

Automatic transcript — names and jargon may be misspelled.