{"id":"vB3oQGW1ydI","title":"NEAR Lunch and Learn Ep. 06: Pricing Model","description":"In this episode, Maksym Zavershynskyi provides an overview of how NEAR assigns costs to different operations in our system, including what hidden and explicit parameters determine these costs, and an explanation of gas vs tokens.\n\n~~~ABOUT Lunch and Learns~~~\nThis is a new series of videos exploring a concept on the NEAR protocol blockchain discussed in the NEAR office at lunch. Grab a sandwich and settle in!\nFollow the latest from NEAR Protocol on, \n\nWebsite: https://nearprotocol.com/\nDiscord: https://near.ai/discord\nMedium: https://near.ai/medium\nTwitter: https://near.ai/twitter\nGitHub: https://near.ai/github","channel_name":"NEAR Protocol","published_at":"2019-12-17T00:00:00.000Z","thumbnail_url":"https://img.youtube.com/vi/vB3oQGW1ydI/hqdefault.jpg","transcript_text":"my name is Maxim it's a live series from the NIR protocol I'm gonna be talking today about what the hell is gas how do we price it and what are the consequences of not pricing it correctly you heard that there are tokens and there is gas what is the difference is that tokens is like an internal currency in our system and gas is sort of a thing that we use to express cost of the operations that people can do the blockchain because anything that you can do with the blockchain should cost something and those are two separate things because we want to define an exchange range between the tokens and the gas and we want this exchange rate to be dynamically set by the validators depending on how expensive to do certain things at given moment of time so there is tokens and there is gas and in between them there is some exchange rate so gas essentially represents amount of inconvenience that you caused to the validator when you ask them to do certain operation like a process a transaction or deploy a contract call a contract and so we want certain operations which you have mean in our system to be to have pricing to to be to cause certain amount of gas and we have hundreds of operations in the system that have some need to have some certain gas value and we want this gas value to somehow reflect the amount of inconvenience that we cost the debilitate er to do this operation so a typical operation could be execute certain CPU comment create an account call a smart contract deploy a smart contract and they all take nonzero amount of time to execute and they all take some have some intensity like some operations might require a lot of RAM to run some precious might require a lot of CPU and so you could sort of picture it as a graph we're oh let's say this is RAM here oh maybe like CPU usage CPU usage on y-axis and this is time and we asked some blockchain why later to do something like create an account it will look like the load that we caused in a validation will look or something like that probably so this is going to be a curve to take certain amount of time before it's completed and it will cause certain cpu load on the validator the same thing for other resources like RAM usage disk etc so when we try to measure how much resources we used on the validator we need to take into account how long did it take for the separation to execute and how much of the resources we actually used for it so it's the length of this graph and the area under the curve because an operation can be executed really quick well the same time it can use a lot of CPU so we also want to account for that so there are two things the length of the operation in terms of time and the amount of the resources that we used and currently we are counting only for the length this is our main focus and the amount of the resources we use we don't account it for everything but only for a few things because it's really difficult for now so we're trying to end length with some consistent but simple pricing model for now and later we will might include that too right so the interesting thing is that even if you have a node running on some cloud and we perform the same operation multiple times a minute we can have different cost of the separation in different time it takes for it executes for instance the account creation can take different time depending on what is the other stuff happening on the same machine and/or like how many accounts already exist on this shard and so like when we when we call certain operation the distribution of how much time it takes is actually not just like a single spike like five microseconds but it's sort of fic distributed thing and the problem with that is how do we price this thing if sometimes our operation takes two microseconds sometimes it takes ten microseconds how do we assign certain financial value to this thing that says this is how expensive to create an account in our system and that's where the concept of average price and model versus pessimistic pricing model comes into play so there is average versus pessimistic pricing model and in average pricing model you kind of want to assume that all the operations are going to be the same in terms of time and intensity on average and in pessimistic model you're trying to aim for the very bad case where your operation is sometimes this acute at ten microseconds and we can create fully pricing model just around average and what it what will happen if we say for instance that let's say create an account takes let's say five microseconds which is let's let's say it's gonna be five gasps and we say that you can have only 500 guests per block because we need to limit how many guests you can use in a single block so that means that on average you're gonna have hundred account creations in a block but then someone can abused it someone can come in and and for instance start issuing the account creations that have the property that they take ten microseconds and this is going to be what they call grinding they can slow down our system in this case they will slow down twice suddenly no one is doing anything that can be slashed on our system but at the same time our block production slowed down twice and this is grinding it's like 2x grinding in this case 2x is probably not the worst thing they can do some operations they have a discrepancy in our system from like 10x discrepancy and therefore someone can do 10x grinding so one can slow down our system 10x times what happens if we create a pricing model which is pessimistic where we say that create account takes 10 microseconds and therefore it takes 10 gasps in this case we're going to have only 50 accounts per block maximum accounts per block number of accounts to look at we can create and our blocks are going to be only half full so this is a very tricky balance we either go with the risk and allow ourselves to be grind well or we have blocks that are not used and asked to full capacity and in this example the grinding factor was 2 but for many operations we can have 10x or even more grinding factor the problem here rises from the fact that there is a sometimes a huge gap between average and pessimistic scenario in this case is like 2x gap and what contributes to this gap there are natural shoes with pricing operations just taking different amount of time to execute if you for instance plug out the power from your laptop everything is going to be slower running on it and you will actually notice it if you're running the blockchain node or you have a different cloud instance running or just something happening in background and you're gonna have this distribution of time it takes to be certain operation this is something which is we cannot really influence in any way but there are other things we can there are explicit and hidden parameters to certain operation so let's say we're talking about great account operation great account takes the name of the account we want to create so it takes certain parameters explicit parameters like name of the account and let's say the name of the account the length of it actually affects how long it's gonna take to create this account so we could vertical price differently depending on what is the length of the account name when we decide how much gas the user should pay for the account creation but there also hidden parameters and hidden parameters are how many accounts already exist in the current system because if you have 10,000 accounts in our system versus we have 1 million accounts in our system the cost will change by orders of the magnitude more than one order of magnitude so there is a hidden parameter which let's say in this case would be size of the try or the logarithm of the number of the accounts in our system so we need to address these three things so there is like one is like natural distribution of this computation time parameters and hidden parameters so if we if you want to address this gap between average scenario in pessimistic scenario we need to do something with it and there are two things we can do with the gap we can either eliminate hidden parameters and therefore the gap is gonna close because there is less of unknown variance to the price of certain operations no blockchain or we can try accounting for this hidden parameters so we price the difference will depend on how many accounts already in the system and the second one is more Universal approach because if you know your system well you can probably figure out all the hidden parameters but that makes the economic model more complex well the first one when you completely eliminate eliminate hidden parameters is just harder engineering work like you need to design a system that has few hidden economic parameters and this is really hard so we're going with dynamic pricing we're gonna price things differently depending on how many accounts you touched while trying to create the current account","transcript_synced_at":"2026-11-04T04:27:21.569Z","segments":[{"start_seconds":5,"text":"my name is Maxim it's a live series from the NIR protocol I'm gonna be talking today about what the hell is gas how do","url":"https://www.youtube.com/watch?v=vB3oQGW1ydI&t=5s"},{"start_seconds":14,"text":"we price it and what are the consequences of not pricing it correctly you heard that there are tokens and there is gas what is the difference is","url":"https://www.youtube.com/watch?v=vB3oQGW1ydI&t=14s"},{"start_seconds":23,"text":"that tokens is like an internal currency in our system and gas is sort of a thing","url":"https://www.youtube.com/watch?v=vB3oQGW1ydI&t=23s"},{"start_seconds":30,"text":"that we use to express cost of the operations that people can do the blockchain because anything that you can","url":"https://www.youtube.com/watch?v=vB3oQGW1ydI&t=30s"},{"start_seconds":37,"text":"do with the blockchain should cost something and those are two separate things because we want to define an exchange","url":"https://www.youtube.com/watch?v=vB3oQGW1ydI&t=37s"},{"start_seconds":45,"text":"range between the tokens and the gas and we want this exchange rate to be dynamically set by the validators depending on how expensive to do certain","url":"https://www.youtube.com/watch?v=vB3oQGW1ydI&t=45s"},{"start_seconds":53,"text":"things at given moment of time so there is tokens and there is gas and in","url":"https://www.youtube.com/watch?v=vB3oQGW1ydI&t=53s"},{"start_seconds":60,"text":"between them there is some exchange rate so gas essentially represents amount of","url":"https://www.youtube.com/watch?v=vB3oQGW1ydI&t=60s"},{"start_seconds":68,"text":"inconvenience that you caused to the validator when you ask them to do certain operation like a process a","url":"https://www.youtube.com/watch?v=vB3oQGW1ydI&t=68s"},{"start_seconds":76,"text":"transaction or deploy a contract call a contract and so we want certain operations which you have mean in our","url":"https://www.youtube.com/watch?v=vB3oQGW1ydI&t=76s"},{"start_seconds":84,"text":"system to be to have pricing to to be to cause certain amount of gas and we have","url":"https://www.youtube.com/watch?v=vB3oQGW1ydI&t=84s"},{"start_seconds":93,"text":"hundreds of operations in the system that have some need to have some certain gas value and we want this gas value to","url":"https://www.youtube.com/watch?v=vB3oQGW1ydI&t=93s"},{"start_seconds":102,"text":"somehow reflect the amount of inconvenience that we cost the debilitate er to do this operation so a","url":"https://www.youtube.com/watch?v=vB3oQGW1ydI&t=102s"},{"start_seconds":109,"text":"typical operation could be execute certain CPU comment create an account call a smart contract deploy a smart","url":"https://www.youtube.com/watch?v=vB3oQGW1ydI&t=109s"},{"start_seconds":117,"text":"contract and they all take nonzero amount of time to execute and they all","url":"https://www.youtube.com/watch?v=vB3oQGW1ydI&t=117s"},{"start_seconds":125,"text":"take some have some intensity like some operations might require a lot of RAM to run some precious might require a lot of","url":"https://www.youtube.com/watch?v=vB3oQGW1ydI&t=125s"},{"start_seconds":132,"text":"CPU and so you could sort of picture it as a graph","url":"https://www.youtube.com/watch?v=vB3oQGW1ydI&t=132s"},{"start_seconds":139,"text":"we're oh let's say this is RAM here oh maybe like CPU usage CPU usage on y-axis","url":"https://www.youtube.com/watch?v=vB3oQGW1ydI&t=139s"},{"start_seconds":149,"text":"and this is time and we asked some blockchain why later to do something like create an account it will look like","url":"https://www.youtube.com/watch?v=vB3oQGW1ydI&t=149s"},{"start_seconds":157,"text":"the load that we caused in a validation will look or something like that probably so this is going to be a curve to take certain amount of time before","url":"https://www.youtube.com/watch?v=vB3oQGW1ydI&t=157s"},{"start_seconds":166,"text":"it's completed and it will cause certain cpu load on the validator the same thing","url":"https://www.youtube.com/watch?v=vB3oQGW1ydI&t=166s"},{"start_seconds":172,"text":"for other resources like RAM usage disk etc so when we try to measure how much","url":"https://www.youtube.com/watch?v=vB3oQGW1ydI&t=172s"},{"start_seconds":182,"text":"resources we used on the validator we need to take into account how long did it take for the separation to execute","url":"https://www.youtube.com/watch?v=vB3oQGW1ydI&t=182s"},{"start_seconds":189,"text":"and how much of the resources we actually used for it so it's the length of this graph and the area under the","url":"https://www.youtube.com/watch?v=vB3oQGW1ydI&t=189s"},{"start_seconds":198,"text":"curve because an operation can be executed really quick well the same time it can use a lot of CPU so we also want","url":"https://www.youtube.com/watch?v=vB3oQGW1ydI&t=198s"},{"start_seconds":207,"text":"to account for that so there are two things the length of the operation in terms of time and the amount of the","url":"https://www.youtube.com/watch?v=vB3oQGW1ydI&t=207s"},{"start_seconds":214,"text":"resources that we used and currently we are counting only for the length this is","url":"https://www.youtube.com/watch?v=vB3oQGW1ydI&t=214s"},{"start_seconds":222,"text":"our main focus and the amount of the resources we use we don't account it for everything but only for a few things","url":"https://www.youtube.com/watch?v=vB3oQGW1ydI&t=222s"},{"start_seconds":229,"text":"because it's really difficult for now so we're trying to end length with some consistent but simple pricing model for","url":"https://www.youtube.com/watch?v=vB3oQGW1ydI&t=229s"},{"start_seconds":238,"text":"now and later we will might include that too right so","url":"https://www.youtube.com/watch?v=vB3oQGW1ydI&t=238s"},{"start_seconds":246,"text":"the interesting thing is that even if you have a node running on some cloud","url":"https://www.youtube.com/watch?v=vB3oQGW1ydI&t=246s"},{"start_seconds":254,"text":"and we perform the same operation multiple times a minute we can have different cost of the separation in different time it takes for it executes","url":"https://www.youtube.com/watch?v=vB3oQGW1ydI&t=254s"},{"start_seconds":263,"text":"for instance the account creation can take different time depending on what is the other stuff happening on the same","url":"https://www.youtube.com/watch?v=vB3oQGW1ydI&t=263s"},{"start_seconds":270,"text":"machine and/or like how many accounts","url":"https://www.youtube.com/watch?v=vB3oQGW1ydI&t=270s"},{"start_seconds":276,"text":"already exist on this shard and so like","url":"https://www.youtube.com/watch?v=vB3oQGW1ydI&t=276s"},{"start_seconds":282,"text":"when we when we call certain operation the distribution of how much time it","url":"https://www.youtube.com/watch?v=vB3oQGW1ydI&t=282s"},{"start_seconds":290,"text":"takes is actually not just like a single spike like five microseconds but it's","url":"https://www.youtube.com/watch?v=vB3oQGW1ydI&t=290s"},{"start_seconds":299,"text":"sort of fic distributed thing and the problem with that is how do we price","url":"https://www.youtube.com/watch?v=vB3oQGW1ydI&t=299s"},{"start_seconds":307,"text":"this thing if sometimes our operation takes two microseconds sometimes it takes ten microseconds how do we assign","url":"https://www.youtube.com/watch?v=vB3oQGW1ydI&t=307s"},{"start_seconds":315,"text":"certain financial value to this thing that says this is how expensive to create an account in our system and that's where the concept of average","url":"https://www.youtube.com/watch?v=vB3oQGW1ydI&t=315s"},{"start_seconds":324,"text":"price and model versus pessimistic pricing model comes into play so there is average versus pessimistic pricing","url":"https://www.youtube.com/watch?v=vB3oQGW1ydI&t=324s"},{"start_seconds":333,"text":"model and in average pricing model you kind of want to assume that all the","url":"https://www.youtube.com/watch?v=vB3oQGW1ydI&t=333s"},{"start_seconds":342,"text":"operations are going to be the same in terms of time and intensity on average and in pessimistic model you're trying to aim for the very bad case where your","url":"https://www.youtube.com/watch?v=vB3oQGW1ydI&t=342s"},{"start_seconds":350,"text":"operation is sometimes this acute at ten microseconds and we can create fully","url":"https://www.youtube.com/watch?v=vB3oQGW1ydI&t=350s"},{"start_seconds":358,"text":"pricing model just around average and what it what will happen if we say for","url":"https://www.youtube.com/watch?v=vB3oQGW1ydI&t=358s"},{"start_seconds":365,"text":"instance that let's say create an account","url":"https://www.youtube.com/watch?v=vB3oQGW1ydI&t=365s"},{"start_seconds":371,"text":"takes let's say five microseconds which is let's let's say it's gonna be five","url":"https://www.youtube.com/watch?v=vB3oQGW1ydI&t=371s"},{"start_seconds":378,"text":"gasps and we say that you can have only 500 guests per block because we need to","url":"https://www.youtube.com/watch?v=vB3oQGW1ydI&t=378s"},{"start_seconds":388,"text":"limit how many guests you can use in a single block so that means that on average you're gonna have hundred account creations in a block but then","url":"https://www.youtube.com/watch?v=vB3oQGW1ydI&t=388s"},{"start_seconds":397,"text":"someone can abused it someone can come in and and for instance start issuing the account creations that have the","url":"https://www.youtube.com/watch?v=vB3oQGW1ydI&t=397s"},{"start_seconds":404,"text":"property that they take ten microseconds and this is going to be what they call grinding they can slow down our system","url":"https://www.youtube.com/watch?v=vB3oQGW1ydI&t=404s"},{"start_seconds":412,"text":"in this case they will slow down twice suddenly no one is doing anything that can be slashed on our system but at the","url":"https://www.youtube.com/watch?v=vB3oQGW1ydI&t=412s"},{"start_seconds":420,"text":"same time our block production slowed down twice and this is grinding it's like 2x grinding in this case 2x is","url":"https://www.youtube.com/watch?v=vB3oQGW1ydI&t=420s"},{"start_seconds":429,"text":"probably not the worst thing they can do some operations they have a discrepancy in our system from like 10x discrepancy","url":"https://www.youtube.com/watch?v=vB3oQGW1ydI&t=429s"},{"start_seconds":439,"text":"and therefore someone can do 10x grinding so one can slow down our system 10x times what happens if we create a pricing model which is pessimistic where","url":"https://www.youtube.com/watch?v=vB3oQGW1ydI&t=439s"},{"start_seconds":448,"text":"we say that create account takes 10 microseconds and therefore it takes 10 gasps in this case we're going to have","url":"https://www.youtube.com/watch?v=vB3oQGW1ydI&t=448s"},{"start_seconds":457,"text":"only 50 accounts per block maximum accounts per block number of accounts to look at we can create and our blocks are going to be only half full so this is a","url":"https://www.youtube.com/watch?v=vB3oQGW1ydI&t=457s"},{"start_seconds":466,"text":"very tricky balance we either go with the risk and allow ourselves to be grind well or we have blocks that are not used","url":"https://www.youtube.com/watch?v=vB3oQGW1ydI&t=466s"},{"start_seconds":476,"text":"and asked to full capacity and in this example the grinding factor was 2 but for many operations we can have 10x or","url":"https://www.youtube.com/watch?v=vB3oQGW1ydI&t=476s"},{"start_seconds":483,"text":"even more grinding factor the problem here rises from the fact that there is a","url":"https://www.youtube.com/watch?v=vB3oQGW1ydI&t=483s"},{"start_seconds":491,"text":"sometimes a huge gap between average and pessimistic scenario in this case is","url":"https://www.youtube.com/watch?v=vB3oQGW1ydI&t=491s"},{"start_seconds":497,"text":"like 2x gap and what contributes to this gap there are natural","url":"https://www.youtube.com/watch?v=vB3oQGW1ydI&t=497s"},{"start_seconds":504,"text":"shoes with pricing operations just taking different amount of time to execute if you for instance plug out the","url":"https://www.youtube.com/watch?v=vB3oQGW1ydI&t=504s"},{"start_seconds":514,"text":"power from your laptop everything is going to be slower running on it and you will actually notice it if you're running the blockchain node or you have","url":"https://www.youtube.com/watch?v=vB3oQGW1ydI&t=514s"},{"start_seconds":521,"text":"a different cloud instance running or just something happening in background and you're gonna have this distribution","url":"https://www.youtube.com/watch?v=vB3oQGW1ydI&t=521s"},{"start_seconds":528,"text":"of time it takes to be certain operation this is something which is we cannot really influence in any way but there","url":"https://www.youtube.com/watch?v=vB3oQGW1ydI&t=528s"},{"start_seconds":538,"text":"are other things we can there are explicit and hidden parameters to certain operation so let's say we're talking about great account operation","url":"https://www.youtube.com/watch?v=vB3oQGW1ydI&t=538s"},{"start_seconds":548,"text":"great account takes the name of the account we want to create so it takes certain parameters explicit parameters","url":"https://www.youtube.com/watch?v=vB3oQGW1ydI&t=548s"},{"start_seconds":556,"text":"like name of the account and let's say the name of the account the length of it","url":"https://www.youtube.com/watch?v=vB3oQGW1ydI&t=556s"},{"start_seconds":563,"text":"actually affects how long it's gonna take to create this account so we could vertical price differently depending on what is the length of the account name","url":"https://www.youtube.com/watch?v=vB3oQGW1ydI&t=563s"},{"start_seconds":572,"text":"when we decide how much gas the user should pay for the account creation but there also hidden parameters and hidden","url":"https://www.youtube.com/watch?v=vB3oQGW1ydI&t=572s"},{"start_seconds":581,"text":"parameters are how many accounts already exist in the current system because if you have 10,000 accounts in our system versus we have 1 million accounts in our","url":"https://www.youtube.com/watch?v=vB3oQGW1ydI&t=581s"},{"start_seconds":588,"text":"system the cost will change by orders of the magnitude more than one order of magnitude so there is a hidden parameter","url":"https://www.youtube.com/watch?v=vB3oQGW1ydI&t=588s"},{"start_seconds":596,"text":"which let's say in this case would be size of the try or the logarithm of the","url":"https://www.youtube.com/watch?v=vB3oQGW1ydI&t=596s"},{"start_seconds":604,"text":"number of the accounts in our system so we need to address these three things","url":"https://www.youtube.com/watch?v=vB3oQGW1ydI&t=604s"},{"start_seconds":613,"text":"so there is like one is like natural distribution of this computation time","url":"https://www.youtube.com/watch?v=vB3oQGW1ydI&t=613s"},{"start_seconds":621,"text":"parameters and hidden parameters so if we if you want to address this gap between average scenario in pessimistic scenario we need to do something with it","url":"https://www.youtube.com/watch?v=vB3oQGW1ydI&t=621s"},{"start_seconds":628,"text":"and there are two things we can do with the gap we can either eliminate hidden parameters and therefore the gap is","url":"https://www.youtube.com/watch?v=vB3oQGW1ydI&t=628s"},{"start_seconds":636,"text":"gonna close because there is less of unknown variance to the price of certain operations no blockchain or we can try accounting for this hidden parameters so","url":"https://www.youtube.com/watch?v=vB3oQGW1ydI&t=636s"},{"start_seconds":644,"text":"we price the difference will depend on how many accounts already in the system and the second one is more Universal approach because if you know your system","url":"https://www.youtube.com/watch?v=vB3oQGW1ydI&t=644s"},{"start_seconds":654,"text":"well you can probably figure out all the hidden parameters but that makes the economic model more complex well the first one when you completely eliminate","url":"https://www.youtube.com/watch?v=vB3oQGW1ydI&t=654s"},{"start_seconds":662,"text":"eliminate hidden parameters is just harder engineering work like you need to design a system that has few hidden economic parameters and this is really","url":"https://www.youtube.com/watch?v=vB3oQGW1ydI&t=662s"},{"start_seconds":670,"text":"hard so we're going with dynamic pricing we're gonna price things differently depending on how many accounts you","url":"https://www.youtube.com/watch?v=vB3oQGW1ydI&t=670s"},{"start_seconds":678,"text":"touched while trying to create the current account","url":"https://www.youtube.com/watch?v=vB3oQGW1ydI&t=678s"}],"youtube_url":"https://youtube.com/watch?v=vB3oQGW1ydI","url":"https://near-pedia.xyz/videos/vB3oQGW1ydI"}