{"id":"9A7LvmBn0iQ","title":"NEAR Blockchain Concepts (6/6) -- View vs Change Methods","description":"Follow the latest from NEAR Protocol on:\nWebsite: https://near.org/\nDiscord: https://near.chat/\nBlog: https://near.org/blog/\nTwitter:   / nearprotocol  \nGitHub: https://github.com/near  https://github.com/nearprotocol\n#Blockchain #FutureIsNEAR #NEAR #nearprotocol","channel_name":"NEAR Protocol","published_at":"2021-07-13T00:00:00.000Z","thumbnail_url":"https://img.youtube.com/vi/9A7LvmBn0iQ/hqdefault.jpg","transcript_text":"so welcome uh we are here with vlad frolov he's uh heading up the team on the api side and the explorer side of near protocol um and uh we're gonna talk uh today about um you know parts of the api uh that uh you know vlad thinks uh are useful for us um and vlad should we call you frol or vlad or what's the right what's the right way um whichever works for you uh yeah for all is better in terms of how like just to be unique on the team that's right yeah cool okay so uh so for what is the focus of today going to be i think you have uh some some intent to talk about um uh link drops accounts uh keys what's what's the right focus for today yeah uh first of all uh it's nice to meet you sheriff and to welcome everybody to watch our series of videos uh yeah i was about to talk about the view and change methods on nir in a perspective how they are different and how they are useful in the first place um so let's uh try to dive into it immediately you can find in the docs there are there is some uh distilled information about potential gotchas so you may encounter with view and change functions but today we are i'm going to dive into them from the point of view of api and we'll navigate through how the data is flowing and we'll follow it so for today's video i decided to go with an example of our near link drop contract you can find it on github um we are not going to dive much into the details it's implemented in rust and you can read up the source code what they want us to focus on is that there are several methods like send and claim and there is also like there are a bunch of other methods but one that we are going to focus today uh is this get key balance method specifically so this one is quite small and i suggest we just uh study it a little bit closer uh essentially get key balance a is a function which you provide with the key and it will return you a balance in unsigned one 28 bits uh integer uh yoktanir precision so we have and accounts map on the on our state and we can query it by the given key and if everything is fine so the key is not missing we will get have the the balance that is attached to this key so to look it up you can always start from the beginning of the file and see that indeed there is a map with the public key and the balance named account so that's how you read it when we have this send method implementation we can see that there is something is going on but ultimately we just insert our public key and the balance attached to this key into the structure we just covered everything else is not important right now for us and let's focus only on this accounts mapping so we essentially map not the accounts but the public keys to the balances that we uh fund and that's how this contract is working in this uh in regard to this the two methods um so now i i want us to talk a little bit about the um uh how do we make those calls from the rpc point of view from the like system point of view before we leave the contract can we just point out that that you you are we started the conversation talking about view and change methods and as a rust developer you can immediately tell uh the difference between a view and a change method because of the mutable reference to self right so yeah so that's a little right thank you yeah yeah so basically in scent we can see that self is mutable reference we can call the methods that are mutating the values on self and with the get key balance as you can see itself is is immutable and it's it's very handy as sheriff pointed out to immediately spot the method that intend to be view methods um so i would like to uh make this uh difference clear uh what these like when we implement the methods on the contract level they seem to be just the functions on the same level of abstraction they're kind of the same we just assume that one you can call and change the data and call another and we don't need to change the data seems to be uh there is like there is no distinction but on the blockchain level uh the calls that are not requiring us to modify the data could be executed for free we don't need to actually push the update to the whole network you can do it on your own machine essentially if imagine if you have your accounts mapping on your local machine what would you take to look up the the key that is provided to you and know the balance it's it's a regular program there is no problem to implement it and you just go and find the necessary key in the hashmap or even in a sequential array you know but whenever you modify the data on blockchain you need to make all the validators arrive to the same state and it is expensive and you need to make sure that consensus is reached and all of that is uh taking quite amount of resources across the network so that's the main distinct distinction between those those two types of functions and even though they look very similar on the contract level they could be they they are quite different on network level so whenever you see transactions on on the network those transactions that are call method transactions these are change methods so whenever you deposit the stake whenever you set something when you send subtle race whatever you do you modify the current state that's why you need to submit a transaction the transaction will uh get processed and all of that will get executed and your contract will be executed on a number of machines on the network and they will change the state and the state will will need to be consistent across every single time execution so it should be pure essentially a pure function meaning that whenever you have this input you will have the same output exactly um well and we only record such uh change methods on the network uh every uh function call is essentially let me pick some other example so here we had a function called sent that was executed on near account the arguments were just a single argument public key with this uh base 58 representation so if we open the contract again we can see that there is a one argument here it's a public key and this is exactly what we send it uh with our function call method in a transaction action uh there is some execution process involved but overall we can see this um on the network appearing and it it is what's changing the state of network so just to illustrate how it is actually essentially get here i will open the near account on explorer and we'll use this handy wet packet service which essentially makes a send method it creates a send transaction call i don't want us to dive into too much but let's do this right here so the amount i want to fund is 15 year i call it and we are getting transferred to the wallet page to confirm that this transaction will happen because we are attaching some near and let me try to catch it actually get this one wow um i forgot to disable to persist logs let's try again um so clean them up we're transferring this post method let's let's see what's inside so okay uh sheriff can you see the screen well or should they change the text is pretty small um but it's uh it's it's fine um maybe you could take it out of this and put it into another tool where we could look at it a little bit better what's your what's your goal what are we gonna look at the payload it will it'll be quite short here the goal is essentially to display this we have a call to to the rpc um it's very simple you provide json standard json or pc parameters you specify the method we are going to submit a transaction broadcast tx and here the transaction that is represented in base uh 58 encoding uh and before i think that one right whatever base64 i think right um well it could be both let's inspect our documentation on that um broadcast i guess it's a basic base68 too many characters that are not on base 58 yeah so the base64 encoded uh byte stream uh which the byte stream is in its turn serialized structure of a it's a structure that represents the transaction essentially the signed transaction it has actions it has nones it has signer receiver account ids all of that information that we don't want to focus right now on but what i wanted to show is that there is no indication that we are calling the some sort of function in the api from the api point of view from the api point of view we are setting a transaction it doesn't matter which kind of transaction is sent it's always like this you send a broadcast tx you come up with a transaction you sign it you you first you you craft it then you sign it and then you send it over the wire and it will ultimately reach the network and once it is there you can use transaction status endpoint tx status uh either experimental one or um even regular one let's take a look into it so this one now we can see a response actually yeah responses here let's uh so essentially in response where it returned the same object we send it uh in serialized way so uh just a reminder in response to broadcast tx we received the same transaction but json serialized now so we can essentially just confirm that everything is what we expected to send was there we have a status success value empty string and the the initial transaction was the following uh the signer was frauled here with this public key i signed this transaction and all the rest is not very important right now and the actions of this uh transaction was that the first the first action yeah and the receiver is near and the action is the following it's a function call by the way i'm like really confused with this representation let me find uh json not strictly better but i still find it better um so again you receive the json rpc response with the result in it with the status of execution and the initial transactions here and the transaction is sending from fraud.near to near with this pub signed with this public key and the actions were only a single item it's a function call method call method name is sent i reminded you that we are talking to this contract right here this is ascend and the arcs are here they are also base64 encoded we can quickly use base64 decoder and see that the input was public key this these are the arguments that we sent to this send method we attached this amount of guess and this amount this amount of near tokens is a value accompanying this function fall if you go back again you can see this attached deposit is the variable that you can use inside the contracts to manipulate with that attached balance and store it or send over somewhere else um so this is the function call that is made uh through a transaction it is changing the state we paid near talk we we paid near tokens to issue the transaction we paid network tokens to execute the transaction we paid for gas and we also attached some near tokens to the execution so we spend our tokens we transfer them it's also change on the network so we made a bunch of uh changes only to the balance of our own and also the method itself will also change certain state certain data store it on the net now what i want us to use is a another rpc method on on the network uh here is a coral command that you essentially craft a json or pc body with the method name query let me briefly mentioned that we have a dock for it so we have a bunch of different query types to view access key or whatnot and there is also a documentation how to make a contract function call through a query but uh i want us to make sure we understand that it's a viewfind view method function call so it's the only way to change something on the network it is through it calling making a transaction and sending it but if we use this api we can still execute function functions on the construct but they cannot change anything they can only view the data so if we make a critical request type call function account is near we need to specify the time frame that we're interested in we want to get the latest final state that's why we use finality final method name is going to be get key balance i get it from here so we were talking very beginning about the get key balance it expects to receive a single argument key in base 58 public key encoding and it will return me a strain representation of the balance let's see so what we have we need to we specify the method name get key balance and we also need to specify our arguments the argument is a key and we need to encode it here in base64 because we don't require everybody to use json you can write your own contract and expect certain inputs in any format even binary uh most of our sdks you by default use json encoding but we don't want to limit anybody that's why we choose to use base64 encoding here so to come up with a proper uh rx parameter i'm going to use base64 from a con line i will say okay i want to create the key which key okay let's get back we just sent a transaction uh where was it i think you decoded the response and then you may have closed the result oh i guess the transaction was right there as well huh yeah over here you're right i didn't close it so but i i can just that's it right there use it so essentially uh this is the body that i want to send as a argument to my function and if the parameter name was the same for this uh getkeybalance function if the parameter name was public key you could have just used the original base64 encoding and re-encode it because the parameter name server and after that i use pipe to jq just to make the output a bit more sane what we receive in result is a json rpc response with a result and this result is represented as a array of bytes of of the value that is returned from the function here so get key balance returned to 128 which essentially is a string so if we grab these bytes and convert them each into into the their character representation and then join just for the sake of readability you can see that it's a and print you can see that it's a quote encoded a quote encoded integer so let's grab this integer and see that it's a 14 yoktaneer here attached to this um public key yeah for 14 year which is the 15 that you send less the one year for the access key fee that's removed by the contract exactly and we can inspect this so there is no magic here if you read the code you can see that we insert as a public key value we insert the value the the previous value that we could have had for this public key previously we add the attached balance and we subtract the access key allowance so this is a uh this constant here it's exactly one near which is used for contract operation later to cover storage and other needs so whenever you create a dread packet you will deposit one year for the account operation so that's why it's 14 not 15. that's right um and and so in that you've you've now made a distinction between the change function the view function right so the change function was originally sending the red packet you sent that broadcast tx commit transaction we looked at the response to get an idea of what the original transaction being sent was because there was encoded as json we could read it more easily than the base64 encoded signed transaction or whatever that was was actually being sent to the network and so you could see okay deposit on that line uh as part of this original transaction was 15 near there's a signature uh you know the method name that you were calling send etc right all these details so that was the change function that sent the transaction that the network arrived at consensus over this transaction basically you were changing the truth of the network but then the second example was this simple you know query that that you made where you made a function call using the query method function call as a parameter asking the network for some truth for some data without changing anything and it just replied happily here's how much uh you know near is attached to this uh uh this public key inside of the link drop contract right so that that's kind of the distinction that you're making right exactly yeah you you perfectly summarized it and what i also want for us to just play a little bit what if we uh just try to execute send methods as a view function right i think it's uh it's great to you know experiment with such uh things so i changed the method name i left it recently the same i even left the args for now to be the same which is a key instead of public key so let's go ahead and see what's going to happen so first this was gq would be easier so wasm execution failed uh because it couldn't decentralize input from json missing field uh public key so here we go it's the first error it couldn't really uh parse our right so it actually got to the method tried to execute it and and had a problem matching the parameter name in the method with the parameter name that you sent basically couldn't find the parameter name and what you said yeah so let's uh let's just try to fulfill this requirement and send the correct base64 parameter there okay now what we failed is a prohibited in view error so whenever you receive such a response it means that the function that you called tried to execute certain method in this case it was attached deposit here so it was try to execute the method that is forbidden in the view environment and oops like there is no way we can proceed so essentially you can call at any function but well and this is one of the the methods that's listed in the gotchas the documentation you're just looking at a minute ago so to kind of close the loop on the the docks that you started with you'll find attach deposit as the maybe the fourth item here in this potential gotchas list any method that uses any of these features of the platform can't be a view function yep as well as promises which create essentially a new um function call they cannot be used uh in a view function environment because they would create a new receipt and they would cause like more execution uh to to progress and that's why it's a crucial limitation of viewpoles you cannot do cross-contract calls uh in view methods um but you can simulate that you can always uh think about your um cross contract polls as a chain of uh call to one function it will return your result you send this result to the next function so from the point of view of your from your client you can simulate those executions just passing required parameters throughout the chain of cross contracts if if there is such a need yeah uh can we just talk for a couple of minutes about the first maybe five or six of these because i'm surprised that you can't i i have a guess but i'm surprised that you can't interrogate the you know virtual machine for signer account id or attach deposit or prepaid gas is it why is that why can't you just interrogate the environment and then return that value with attached deposit well i guess it's from the uh just you know strictness point of view we want to sign our county to be always validated that it is indeed a signer and in the in the context of the view call there is no signature involved i don't need to have a key i don't need to have having even account on me or to make a view call that's why you can i cannot confirm that i'm the user um that is signing uh this thing that's why instead what we usually require uh in view functions is to specify the account id explicitly as an argument and instead instead of trying to come up with some api uh how you would pass certain environment vari variables throughout this view function um okay so that makes perfect sense from the signer account id and pk so it's not a signed transaction so you can't get to that data predecessor makes sense for the same reasons attach deposit because in the end you're not signing any transaction there's no account to deposit it from so there's really that that's also nonsensical right uh prepaid gas and you prepaid gas same idea right like you you can't in the end without assigned transaction pre-pay any gas used gas you you could actually return use gas couldn't you well you could i guess i'm not sure why it's forbidden one thing i want to mention here is that you still cannot have arbitrarily huge functions view view functions they are by default limited by the json rpc endpoint uh so we for our public rpc services we limited to certain number i i don't recall from the top of my head but essentially sorry your certain number for what for the gas that you it's true i think it's 200 tera gas in genesis it's there's like two there's two max gas consumed values no it's it's a different value i mean this view view function is uh you can you can run it for for an hour no problem from like from network perspective it's fine but from our pc point of view it will be too expensive to allow everybody to call very expensive functions and that's why we limited on the uh jason rpc side uh view functions to be quite uh small in their allowance so they can't can only spend something like 100 milliseconds i guess how are you limiting that through gas so we essentially use the same gas technique we just set this value constant for so you cannot specify how much gas you want to essentially attach or spend we have a hard limit uh and it's just a you know time limit for execution like timeout for anything okay so it's a little bit confusing for me because there is there is a there are two max gas um kind of limits in genesis config um and and there are some some branches in near core that distinguish between view function calls and change function calls using those gas limits as a sort of the maximum limit of gas that can be brought if your masses do not use the genesis config they they use either either we use a hard coded value or can be configured at runtime uh like any essentially i as the owner of a node i can run any like i can run my own rpc node modify the value and allow to to view function calls to be executed for an hour no problem i can i can i can enable it for my my own rpc server i see it will not affect the network in any way it will it will it's just a matter of resource constraint uh we don't want to allow like our arbitrary computation happening on the on our public nodes it's only yeah i mean you could just as easily query your local node but the point is you're just reading from the network right yep that's that's what you're saying earlier yeah that makes sense correct so basically what to to to just uh you know push the boundary of this idea uh let's have this thought experiment essentially what a view function is needed let's have exactly a look what this function is needed is the this map of which is called accounts which is essentially public key to balance this is the only thing it's it needs to get executed if you can have this mapping locally you can run this function locally so there is another method in on on jason rp side is the view contract state you can download essentially the state you can download the state you have a contract you can run the contract on your local machine it's a vast binary any wasman time will do pass the state and it will just crunch it it can crunch it for minutes days no problem you are working with your own state on your local machine unlimited resources you don't need to modify the data that's why it's very different from the change methods in general so i even have a suggestion that we may explore in the future extension to near api jazz which will essentially download the state download the contract and execute certain methods that it's needed uh on the on the browser on the client side you can do it you know again and again whatever amount of times for whichever accounts it needs to compete to make the computation uh and this way avoid any uh interaction through json or pc so you don't need json or pc anymore if you have the state and you have the code you can just run it locally yeah that makes sense so so if you're if you're dealing with kind of some some uh application that that has a lot of reads from the network and you want to make it more responsive that's your point you can just download the the contract and and you can download the state of the of the account right there in your browser and just just interact with it locally and then update the cache whenever whenever you want to do that right yeah yeah that that's interesting i hadn't thought of that yeah yeah i'm this this has been great uh frol i don't think there's uh is there much else that you want to cover in terms of this or do you feel like this is this is enough i feel it it's enough uh for now uh we may dive into like more in details how they uh function like how the transactions essentially are construct constructed but i think we can go to with a different so it's it's a completely different topic uh yeah it's a huge one uh i would cover it in a separate session yeah okay cool um so should we stop recording here and then uh i think thanks everybody to for listening and uh hope you if you have any questions feel free to ask them in discord and reach me out uh give help so see","transcript_synced_at":"2026-11-04T04:16:06.965Z","segments":[{"start_seconds":7,"text":"so welcome uh we are here with vlad frolov he's uh heading up the team on the","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=7s"},{"start_seconds":14,"text":"api side and the explorer side of near protocol um and uh we're gonna talk uh today about um you know parts of the api uh that uh","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=14s"},{"start_seconds":23,"text":"you know vlad thinks uh are useful for us um and vlad should we call you frol or vlad or what's the right what's the right way","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=23s"},{"start_seconds":30,"text":"um whichever works for you uh yeah for all is better in terms of how like just to be unique on the team","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=30s"},{"start_seconds":40,"text":"that's right yeah cool okay so uh so for what is the focus of today going to be i think you have uh some some intent to talk about um","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=40s"},{"start_seconds":49,"text":"uh link drops accounts uh keys what's what's the right focus for today yeah uh first of all uh it's nice to","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=49s"},{"start_seconds":57,"text":"meet you sheriff and to welcome everybody to watch our series of videos uh yeah i was about to talk about","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=57s"},{"start_seconds":66,"text":"the view and change methods on nir in a perspective how they are different and","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=66s"},{"start_seconds":73,"text":"how they are useful in the first place um so let's uh","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=73s"},{"start_seconds":79,"text":"try to dive into it immediately you can find in the docs there are there is","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=79s"},{"start_seconds":88,"text":"some uh distilled information about potential gotchas so you may encounter with view","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=88s"},{"start_seconds":95,"text":"and change functions but today we are i'm going to dive into them from the point of view of api","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=95s"},{"start_seconds":102,"text":"and we'll navigate through how the data is flowing","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=102s"},{"start_seconds":109,"text":"and we'll follow it so for today's video i decided to go with an example of our","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=109s"},{"start_seconds":117,"text":"near link drop contract you can find it on github um","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=117s"},{"start_seconds":123,"text":"we are not going to dive much into the details it's implemented in rust and you can","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=123s"},{"start_seconds":131,"text":"read up the source code what they want us to focus on is that there are several methods like send","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=131s"},{"start_seconds":138,"text":"and claim and there is also like there are a bunch of other methods but","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=138s"},{"start_seconds":146,"text":"one that we are going to focus today uh is this get key balance","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=146s"},{"start_seconds":153,"text":"method specifically so this one is quite small and i suggest we just uh study it a little bit closer","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=153s"},{"start_seconds":162,"text":"uh essentially get key balance a is a function which you provide with the key and it","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=162s"},{"start_seconds":169,"text":"will return you a balance in unsigned one 28 bits uh integer","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=169s"},{"start_seconds":176,"text":"uh yoktanir precision so we have","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=176s"},{"start_seconds":184,"text":"and accounts map on the on our state and we can query","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=184s"},{"start_seconds":191,"text":"it by the given key and if everything is fine so the key is not missing","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=191s"},{"start_seconds":198,"text":"we will get have the the balance that is attached to this key so to look it up you can always","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=198s"},{"start_seconds":208,"text":"start from the beginning of the file and see that indeed there is a map with the public key and the balance","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=208s"},{"start_seconds":215,"text":"named account so that's how you read it when we have this send method","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=215s"},{"start_seconds":223,"text":"implementation we can see that there is something is going on but ultimately we just insert","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=223s"},{"start_seconds":231,"text":"our public key and the balance attached to this key into the","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=231s"},{"start_seconds":238,"text":"structure we just covered everything else is not important right now for us and let's focus only on this accounts","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=238s"},{"start_seconds":246,"text":"mapping so we essentially map not the accounts but the public keys to the balances that we uh","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=246s"},{"start_seconds":255,"text":"fund and that's how this contract is working in this","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=255s"},{"start_seconds":261,"text":"uh in regard to this the two methods um","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=261s"},{"start_seconds":268,"text":"so now i i want us to talk a little bit about the um","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=268s"},{"start_seconds":277,"text":"uh how do we make those calls from the rpc point of view from the like system","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=277s"},{"start_seconds":284,"text":"point of view before we leave the contract can we just point out that that you you are we started the conversation talking about view and change methods","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=284s"},{"start_seconds":292,"text":"and as a rust developer you can immediately tell uh the difference between a view and a change method because of the mutable reference to self","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=292s"},{"start_seconds":300,"text":"right so yeah so that's a little right thank you yeah yeah so basically in scent we can see that self is mutable reference","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=300s"},{"start_seconds":309,"text":"we can call the methods that are mutating the values on self","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=309s"},{"start_seconds":316,"text":"and with the get key balance as you can see itself is is immutable and it's","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=316s"},{"start_seconds":325,"text":"it's very handy as sheriff pointed out to immediately spot the method that","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=325s"},{"start_seconds":331,"text":"intend to be view methods um","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=331s"},{"start_seconds":338,"text":"so i would like to uh make this uh difference clear uh","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=338s"},{"start_seconds":344,"text":"what these like when we implement the methods on the contract level","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=344s"},{"start_seconds":351,"text":"they seem to be just the functions on the same level of abstraction they're kind of the same we just assume that one","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=351s"},{"start_seconds":360,"text":"you can call and change the data and call another and we don't need to change the data seems to be uh there is like there is no","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=360s"},{"start_seconds":368,"text":"distinction but on the blockchain level uh the calls that are not requiring us to","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=368s"},{"start_seconds":376,"text":"modify the data could be executed for free","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=376s"},{"start_seconds":383,"text":"we don't need to actually push the update to the whole network you can do it","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=383s"},{"start_seconds":390,"text":"on your own machine essentially if imagine if you have your","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=390s"},{"start_seconds":397,"text":"accounts mapping on your local machine what would you take to look up the","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=397s"},{"start_seconds":405,"text":"the key that is provided to you and know the balance it's it's a regular program there is no","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=405s"},{"start_seconds":413,"text":"problem to implement it and you just go and find the necessary key in the","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=413s"},{"start_seconds":419,"text":"hashmap or even in a sequential array you know but whenever you modify","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=419s"},{"start_seconds":426,"text":"the data on blockchain you need to make all the validators arrive to the same state and it is","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=426s"},{"start_seconds":435,"text":"expensive and you need to make sure that consensus is reached and all of that is uh","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=435s"},{"start_seconds":442,"text":"taking quite amount of resources across the network so that's the main distinct distinction between","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=442s"},{"start_seconds":450,"text":"those those two types of functions and even though they look very","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=450s"},{"start_seconds":457,"text":"similar on the contract level they could be they they are quite different on network level","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=457s"},{"start_seconds":465,"text":"so whenever you see transactions on on the network","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=465s"},{"start_seconds":472,"text":"those transactions that are call method transactions these are change methods so whenever you deposit the stake whenever","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=472s"},{"start_seconds":482,"text":"you set something when you send subtle race whatever you do","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=482s"},{"start_seconds":490,"text":"you modify the current state that's why you need to submit a transaction the transaction will","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=490s"},{"start_seconds":498,"text":"uh get processed and all of that will get executed and your contract will be","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=498s"},{"start_seconds":507,"text":"executed on a number of machines on the network and they will change the state","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=507s"},{"start_seconds":514,"text":"and the state will will need to be consistent across every single time execution so it should be","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=514s"},{"start_seconds":522,"text":"pure essentially a pure function meaning that whenever you have this input you will","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=522s"},{"start_seconds":528,"text":"have the same output exactly um","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=528s"},{"start_seconds":535,"text":"well and we only record such uh change methods on the network","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=535s"},{"start_seconds":542,"text":"uh every uh function call is essentially","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=542s"},{"start_seconds":552,"text":"let me pick some other example","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=552s"},{"start_seconds":566,"text":"so here we had a function called sent that was executed on near account","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=566s"},{"start_seconds":574,"text":"the arguments were just a single argument public key with this uh base 58 representation so","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=574s"},{"start_seconds":583,"text":"if we open the contract again we can see that there is a one","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=583s"},{"start_seconds":592,"text":"argument here it's a public key and this is exactly what we send it uh with our function call","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=592s"},{"start_seconds":600,"text":"method in a transaction action uh there is some execution process involved but","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=600s"},{"start_seconds":608,"text":"overall we can see this um on the network appearing and it it is what's","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=608s"},{"start_seconds":614,"text":"changing the state of network so just to illustrate how it is actually","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=614s"},{"start_seconds":623,"text":"essentially get here i will open the near account on explorer","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=623s"},{"start_seconds":631,"text":"and we'll use this handy wet packet service which essentially makes a send","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=631s"},{"start_seconds":640,"text":"method it creates a send transaction","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=640s"},{"start_seconds":648,"text":"call i don't want us to dive into too much","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=648s"},{"start_seconds":657,"text":"but let's do this right here so the amount i want to fund is 15 year","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=657s"},{"start_seconds":666,"text":"i call it and we are getting transferred to the wallet page to confirm that this transaction","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=666s"},{"start_seconds":674,"text":"will happen because we are attaching some near","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=674s"},{"start_seconds":679,"text":"and let me try to catch it actually","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=679s"},{"start_seconds":688,"text":"get this one wow um","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=688s"},{"start_seconds":700,"text":"i forgot to disable to persist logs","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=700s"},{"start_seconds":708,"text":"let's try again um","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=708s"},{"start_seconds":718,"text":"so clean them up we're transferring this post method","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=718s"},{"start_seconds":728,"text":"let's let's see what's inside so okay uh sheriff can you see the","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=728s"},{"start_seconds":738,"text":"screen well or should they change the text is pretty small um but it's uh it's it's fine um","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=738s"},{"start_seconds":746,"text":"maybe you could take it out of this and put it into another tool where we could look at it a little bit better what's your what's your goal what are we gonna look at the payload","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=746s"},{"start_seconds":754,"text":"it will it'll be quite short here the goal is essentially to display this we have a","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=754s"},{"start_seconds":762,"text":"call to to the rpc um it's very simple you provide json","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=762s"},{"start_seconds":770,"text":"standard json or pc parameters you specify the method we are going to submit a transaction","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=770s"},{"start_seconds":779,"text":"broadcast tx and here the transaction that is represented in","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=779s"},{"start_seconds":785,"text":"base uh 58 encoding uh and","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=785s"},{"start_seconds":793,"text":"before i think that one right whatever base64 i think right","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=793s"},{"start_seconds":799,"text":"um well it could be both let's inspect our documentation on","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=799s"},{"start_seconds":806,"text":"that um","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=806s"},{"start_seconds":817,"text":"broadcast i guess it's a basic base68","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=817s"},{"start_seconds":827,"text":"too many characters that are not on base 58 yeah so the base64","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=827s"},{"start_seconds":834,"text":"encoded uh byte stream uh which the byte stream is in its turn","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=834s"},{"start_seconds":844,"text":"serialized structure","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=844s"},{"start_seconds":847,"text":"of a","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=847s"},{"start_seconds":861,"text":"it's a structure that represents the transaction essentially the signed transaction it has actions it has","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=861s"},{"start_seconds":868,"text":"nones it has signer receiver account ids all of that information","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=868s"},{"start_seconds":876,"text":"that we don't want to focus right now on but what i wanted to show","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=876s"},{"start_seconds":882,"text":"is that there is no indication that we are calling the some sort of function","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=882s"},{"start_seconds":890,"text":"in the api from the api point of view from the api point of view we are setting a transaction it doesn't matter which kind of","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=890s"},{"start_seconds":898,"text":"transaction is sent it's always like this you send a broadcast tx you come up with a transaction you sign it","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=898s"},{"start_seconds":907,"text":"you you first you you craft it then you sign it and then you send it over the wire","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=907s"},{"start_seconds":914,"text":"and it will ultimately reach","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=914s"},{"start_seconds":922,"text":"the network and once it is there you can use","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=922s"},{"start_seconds":929,"text":"transaction status endpoint tx status","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=929s"},{"start_seconds":939,"text":"uh either experimental one or um even regular one let's take a look","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=939s"},{"start_seconds":948,"text":"into it so this one now we can see a response","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=948s"},{"start_seconds":955,"text":"actually yeah responses here let's uh","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=955s"},{"start_seconds":964,"text":"so essentially in response where it returned the same object we send it","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=964s"},{"start_seconds":971,"text":"uh in serialized way so uh just a reminder in response to broadcast tx we received the same transaction but","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=971s"},{"start_seconds":980,"text":"json serialized now so we can essentially just confirm that everything is what we expected to","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=980s"},{"start_seconds":989,"text":"send was there we have a status success value empty string and the","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=989s"},{"start_seconds":998,"text":"the initial transaction was the following uh the signer was frauled here with this public key i signed this transaction","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=998s"},{"start_seconds":1007,"text":"and all the rest is not very important right now and the actions of this uh transaction was that","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=1007s"},{"start_seconds":1015,"text":"the first the first action yeah and the receiver is near and the action is the following","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=1015s"},{"start_seconds":1024,"text":"it's a function call by the way i'm like really confused with this representation let me find","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=1024s"},{"start_seconds":1032,"text":"uh json","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=1032s"},{"start_seconds":1048,"text":"not strictly better but i still find it better um","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=1048s"},{"start_seconds":1059,"text":"so again you receive the json rpc response with the result in it with the status of","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=1059s"},{"start_seconds":1067,"text":"execution and the initial transactions here and the transaction is sending","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=1067s"},{"start_seconds":1076,"text":"from fraud.near to near with this pub signed with this public key and the actions","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=1076s"},{"start_seconds":1083,"text":"were only a single item it's a function call method call","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=1083s"},{"start_seconds":1089,"text":"method name is sent i reminded you that we are talking to this contract right here","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=1089s"},{"start_seconds":1097,"text":"this is ascend and the arcs are here","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=1097s"},{"start_seconds":1105,"text":"they are also base64 encoded we can quickly","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=1105s"},{"start_seconds":1113,"text":"use base64 decoder and see that the input was public key","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=1113s"},{"start_seconds":1122,"text":"this these are the arguments that we sent to this send method we","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=1122s"},{"start_seconds":1131,"text":"attached this amount of guess and this amount this amount of near tokens is a","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=1131s"},{"start_seconds":1139,"text":"value accompanying this function fall if you go back again you can see this","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=1139s"},{"start_seconds":1148,"text":"attached deposit is the variable that you can use inside the contracts to manipulate with that","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=1148s"},{"start_seconds":1157,"text":"attached balance and store it or send over somewhere else","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=1157s"},{"start_seconds":1164,"text":"um so this is the function call that is made uh through a transaction","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=1164s"},{"start_seconds":1171,"text":"it is changing the state we paid near talk we we paid near tokens to","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=1171s"},{"start_seconds":1181,"text":"issue the transaction we paid network tokens to execute the transaction we paid for gas","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=1181s"},{"start_seconds":1187,"text":"and we also attached some near tokens to the execution so we spend","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=1187s"},{"start_seconds":1195,"text":"our tokens we transfer them it's also change on the network so we made a bunch of uh changes only to the balance of our","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=1195s"},{"start_seconds":1204,"text":"own and also the method itself will also change certain state certain","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=1204s"},{"start_seconds":1214,"text":"data store it on the net now what i want us to","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=1214s"},{"start_seconds":1223,"text":"use is a another rpc method on on the network","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=1223s"},{"start_seconds":1230,"text":"uh here is a coral command that you essentially craft a json or pc","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=1230s"},{"start_seconds":1238,"text":"body with the method name query let me briefly","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=1238s"},{"start_seconds":1248,"text":"mentioned that we have a dock for it so we have a bunch of different query types to view access key or whatnot","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=1248s"},{"start_seconds":1257,"text":"and there is also a documentation how to make a contract function call through a query","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=1257s"},{"start_seconds":1265,"text":"but uh i want us to make sure we understand that it's a viewfind view method function call","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=1265s"},{"start_seconds":1272,"text":"so it's the only way to change something on the network it is through it calling making a transaction","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=1272s"},{"start_seconds":1280,"text":"and sending it but if we use this api we can still execute","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=1280s"},{"start_seconds":1288,"text":"function functions on the construct but they cannot change anything","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=1288s"},{"start_seconds":1295,"text":"they can only view the data so if we make a critical","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=1295s"},{"start_seconds":1303,"text":"request type call function account is near we need to specify the time frame that we're interested in we want","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=1303s"},{"start_seconds":1312,"text":"to get the latest final state that's why we use finality final method name is going to be get key","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=1312s"},{"start_seconds":1320,"text":"balance i get it from here so we were talking very beginning about the get key","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=1320s"},{"start_seconds":1327,"text":"balance it expects to receive a single argument key","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=1327s"},{"start_seconds":1334,"text":"in base 58 public key encoding and it will return me","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=1334s"},{"start_seconds":1342,"text":"a strain representation of the balance let's see so what we have we need to we","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=1342s"},{"start_seconds":1350,"text":"specify the method name get key balance and we also need to specify our arguments the argument is a key","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=1350s"},{"start_seconds":1359,"text":"and we need to encode it here in base64 because we","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=1359s"},{"start_seconds":1368,"text":"don't require everybody to use json you can write your own contract and expect","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=1368s"},{"start_seconds":1376,"text":"certain inputs in any format even binary uh most of our sdks you","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=1376s"},{"start_seconds":1383,"text":"by default use json encoding but we don't want to limit anybody that's why we choose to use base64 encoding here","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=1383s"},{"start_seconds":1392,"text":"so to come up with a proper uh rx parameter","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=1392s"},{"start_seconds":1400,"text":"i'm going to use base64 from a con line i will say okay i want to create the key","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=1400s"},{"start_seconds":1407,"text":"which key okay let's get back we just sent a transaction","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=1407s"},{"start_seconds":1413,"text":"uh where was it i think you decoded the response and","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=1413s"},{"start_seconds":1422,"text":"then you may have closed the result oh i guess the transaction was right there","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=1422s"},{"start_seconds":1430,"text":"as well huh yeah over here you're right i didn't close it so","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=1430s"},{"start_seconds":1437,"text":"but i i can just that's it right there use it so essentially","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=1437s"},{"start_seconds":1448,"text":"uh this is the body that i want to send as a argument to my function","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=1448s"},{"start_seconds":1458,"text":"and if the parameter name was the same for this uh getkeybalance function if the parameter name was public key you could have just used the original","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=1458s"},{"start_seconds":1466,"text":"base64 encoding and re-encode it because the parameter name server and after that i use","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=1466s"},{"start_seconds":1475,"text":"pipe to jq just to make the output a bit","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=1475s"},{"start_seconds":1483,"text":"more sane what we receive in result is a json rpc response","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=1483s"},{"start_seconds":1489,"text":"with a result and this result is represented as a","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=1489s"},{"start_seconds":1497,"text":"array of bytes of of the value that is returned from","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=1497s"},{"start_seconds":1507,"text":"the function here so get key balance returned to","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=1507s"},{"start_seconds":1514,"text":"128","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=1514s"},{"start_seconds":1521,"text":"which essentially is","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=1521s"},{"start_seconds":1528,"text":"a string so if we grab these bytes","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=1528s"},{"start_seconds":1539,"text":"and convert them each into","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=1539s"},{"start_seconds":1551,"text":"into the their character representation and then join just for the sake of","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=1551s"},{"start_seconds":1559,"text":"readability you can see that it's a and print you can see that it's a","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=1559s"},{"start_seconds":1566,"text":"quote encoded a quote encoded integer so let's grab this integer","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=1566s"},{"start_seconds":1575,"text":"and see that it's a 14 yoktaneer here","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=1575s"},{"start_seconds":1583,"text":"attached to this um public key yeah for 14 year which is the 15 that you send","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=1583s"},{"start_seconds":1590,"text":"less the one year for the access key fee that's removed by the contract exactly and we can inspect this","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=1590s"},{"start_seconds":1598,"text":"so there is no magic here if you read the code","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=1598s"},{"start_seconds":1606,"text":"you can see that we insert as a public key value we insert the value the the","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=1606s"},{"start_seconds":1614,"text":"previous value that we could have had for this public key previously we add the attached","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=1614s"},{"start_seconds":1622,"text":"balance and we subtract the access key allowance so","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=1622s"},{"start_seconds":1630,"text":"this is a uh this constant here it's exactly one near which is used for","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=1630s"},{"start_seconds":1640,"text":"contract operation later to cover storage and other needs","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=1640s"},{"start_seconds":1647,"text":"so whenever you create a dread packet you will","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=1647s"},{"start_seconds":1656,"text":"deposit one year for the account operation so that's why it's 14 not 15. that's","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=1656s"},{"start_seconds":1663,"text":"right um and and so in that you've you've now made a distinction between the change","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=1663s"},{"start_seconds":1671,"text":"function the view function right so the change function was originally sending the red packet you sent that broadcast tx","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=1671s"},{"start_seconds":1679,"text":"commit transaction we looked at the response to get an idea of what the original transaction being sent was because there was encoded as json we could read it more","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=1679s"},{"start_seconds":1687,"text":"easily than the base64 encoded signed transaction or whatever that was was actually being sent to the network and so you could see okay deposit on","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=1687s"},{"start_seconds":1696,"text":"that line uh as part of this original transaction was 15 near there's a signature uh you know the method name that you were calling send","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=1696s"},{"start_seconds":1705,"text":"etc right all these details so that was the change function that sent the transaction that the network arrived","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=1705s"},{"start_seconds":1712,"text":"at consensus over this transaction basically you were changing the truth of the network but then the second","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=1712s"},{"start_seconds":1720,"text":"example was this simple you know query that that you made where you made a function call using the query method function call as","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=1720s"},{"start_seconds":1728,"text":"a parameter asking the network for some truth for some data without changing anything and it just replied happily here's how much","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=1728s"},{"start_seconds":1735,"text":"uh you know near is attached to this uh uh this public key inside of the link drop contract right so that that's kind of the distinction that you're","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=1735s"},{"start_seconds":1744,"text":"making right exactly yeah you you perfectly summarized it and","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=1744s"},{"start_seconds":1751,"text":"what i also want for us to just play a little bit what if we uh","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=1751s"},{"start_seconds":1758,"text":"just try to execute send methods as a view function right i think it's uh","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=1758s"},{"start_seconds":1765,"text":"it's great to you know experiment with such uh things so i changed the method name","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=1765s"},{"start_seconds":1772,"text":"i left it recently the same i even left the args for now to be the same which is a","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=1772s"},{"start_seconds":1781,"text":"key instead of public key so let's go ahead and see what's going to happen so first this was gq","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=1781s"},{"start_seconds":1789,"text":"would be easier so wasm execution failed uh because it couldn't decentralize","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=1789s"},{"start_seconds":1797,"text":"input from json missing field uh public key so here we go it's the first error","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=1797s"},{"start_seconds":1804,"text":"it couldn't really uh parse our right so it actually got to the method tried to execute it and and had a problem matching the","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=1804s"},{"start_seconds":1812,"text":"parameter name in the method with the parameter name that you sent basically couldn't find the parameter name and what you said yeah so let's uh let's just try to","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=1812s"},{"start_seconds":1821,"text":"fulfill this requirement and send the correct base64","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=1821s"},{"start_seconds":1830,"text":"parameter there okay now what we failed is a prohibited in","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=1830s"},{"start_seconds":1839,"text":"view error so whenever you receive such a response it means that the function","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=1839s"},{"start_seconds":1847,"text":"that you called tried to execute certain method in this case it was attached deposit","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=1847s"},{"start_seconds":1856,"text":"here so it was try to execute the method that is forbidden in the view environment and oops","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=1856s"},{"start_seconds":1864,"text":"like there is no way we can proceed so essentially you can call at any function but","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=1864s"},{"start_seconds":1870,"text":"well and this is one of the the methods that's listed in the gotchas the documentation you're just looking at a minute ago so to kind of close the loop on the","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=1870s"},{"start_seconds":1879,"text":"the docks that you started with you'll find attach deposit as the maybe the fourth item here in this potential gotchas list any method that uses any of these","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=1879s"},{"start_seconds":1888,"text":"features of the platform can't be a view function yep as well as","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=1888s"},{"start_seconds":1896,"text":"promises which create essentially a new um function call they cannot be","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=1896s"},{"start_seconds":1903,"text":"used uh in a view function environment because they would create a new receipt","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=1903s"},{"start_seconds":1911,"text":"and they would cause like more execution uh to to progress","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=1911s"},{"start_seconds":1918,"text":"and that's why it's a crucial limitation of viewpoles you cannot","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=1918s"},{"start_seconds":1924,"text":"do cross-contract calls uh in view methods um but you can simulate that","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=1924s"},{"start_seconds":1932,"text":"you can always uh think about your um cross contract polls as a chain","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=1932s"},{"start_seconds":1940,"text":"of uh call to one function it will return your result you send this result to the next function","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=1940s"},{"start_seconds":1947,"text":"so from the point of view of your from your client you can simulate those executions","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=1947s"},{"start_seconds":1955,"text":"just passing required parameters throughout the chain of cross contracts if","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=1955s"},{"start_seconds":1964,"text":"if there is such a need yeah uh can we just talk for a couple of minutes about the first maybe","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=1964s"},{"start_seconds":1971,"text":"five or six of these because i'm surprised that you can't i i have a guess but i'm surprised that you can't interrogate the you know virtual machine","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=1971s"},{"start_seconds":1981,"text":"for signer account id or attach deposit or prepaid gas is it why is that why can't you just interrogate the environment and then","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=1981s"},{"start_seconds":1989,"text":"return that value with attached deposit well i guess it's from the uh just you know","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=1989s"},{"start_seconds":1997,"text":"strictness point of view we want to sign our county to be always validated that","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=1997s"},{"start_seconds":2004,"text":"it is indeed a signer and in the in the context of the view","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=2004s"},{"start_seconds":2011,"text":"call there is no signature involved i don't need to have a key i don't need to have having even account on me or to make a","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=2011s"},{"start_seconds":2019,"text":"view call that's why you can i cannot confirm that i'm the user um that is signing uh","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=2019s"},{"start_seconds":2028,"text":"this thing that's why instead what we usually require","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=2028s"},{"start_seconds":2034,"text":"uh in view functions is to specify the account id","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=2034s"},{"start_seconds":2041,"text":"explicitly as an argument and instead instead of trying to come up with","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=2041s"},{"start_seconds":2048,"text":"some api uh how you would pass certain environment vari variables throughout this","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=2048s"},{"start_seconds":2055,"text":"view function um okay so that makes perfect sense from the signer account id and pk so","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=2055s"},{"start_seconds":2063,"text":"it's not a signed transaction so you can't get to that data predecessor makes sense for the same reasons attach deposit because in the end you're","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=2063s"},{"start_seconds":2071,"text":"not signing any transaction there's no account to deposit it from so there's really that that's also nonsensical right uh prepaid gas and you","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=2071s"},{"start_seconds":2080,"text":"prepaid gas same idea right like you you can't in the end without assigned transaction pre-pay any gas used gas you you could actually return","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=2080s"},{"start_seconds":2090,"text":"use gas couldn't you well you could i guess i'm not sure why it's forbidden","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=2090s"},{"start_seconds":2099,"text":"one thing i want to mention here is that you still cannot have arbitrarily","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=2099s"},{"start_seconds":2106,"text":"huge functions view view functions they are by default limited by the","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=2106s"},{"start_seconds":2114,"text":"json rpc endpoint uh so we for our public","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=2114s"},{"start_seconds":2122,"text":"rpc services we limited to certain number i i don't recall from the top of my head but","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=2122s"},{"start_seconds":2129,"text":"essentially sorry your certain number for what for the gas that you it's true i think it's 200 tera gas in genesis it's","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=2129s"},{"start_seconds":2137,"text":"there's like two there's two max gas consumed values no it's it's a different value i mean","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=2137s"},{"start_seconds":2145,"text":"this view view function is uh you can you can run it for for an hour","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=2145s"},{"start_seconds":2152,"text":"no problem from like from network perspective it's fine but from","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=2152s"},{"start_seconds":2160,"text":"our pc point of view it will be too expensive to allow everybody to call very expensive functions","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=2160s"},{"start_seconds":2167,"text":"and that's why we limited on the uh jason rpc side","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=2167s"},{"start_seconds":2176,"text":"uh view functions to be quite uh small in their allowance so they can't","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=2176s"},{"start_seconds":2183,"text":"can only spend something like 100 milliseconds i guess how are you limiting that through gas so","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=2183s"},{"start_seconds":2190,"text":"we essentially use the same gas technique we just set this value","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=2190s"},{"start_seconds":2196,"text":"constant for so you cannot specify how much gas you want to essentially attach or spend we have a","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=2196s"},{"start_seconds":2205,"text":"hard limit uh and it's just a you know time limit for execution like timeout","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=2205s"},{"start_seconds":2214,"text":"for anything okay so it's a little bit confusing for me because there is there is a there are two max gas","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=2214s"},{"start_seconds":2221,"text":"um kind of limits in genesis config um and and there are some some branches in near core","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=2221s"},{"start_seconds":2229,"text":"that distinguish between view function calls and change function calls using those gas limits as a sort of the maximum limit of gas that can be brought if your masses","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=2229s"},{"start_seconds":2238,"text":"do not use the genesis config they they use either either we use a hard coded value or can be configured at runtime uh","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=2238s"},{"start_seconds":2247,"text":"like any essentially i as the owner of a node i can run","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=2247s"},{"start_seconds":2254,"text":"any like i can run my own rpc node modify the value and allow to","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=2254s"},{"start_seconds":2262,"text":"to view function calls to be executed for an hour no problem i can i can i can enable it for","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=2262s"},{"start_seconds":2269,"text":"my my own rpc server i see it will not affect the network in any way it will","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=2269s"},{"start_seconds":2277,"text":"it will it's just a matter of resource constraint uh we don't want to allow like our arbitrary","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=2277s"},{"start_seconds":2284,"text":"computation happening on the on our public nodes it's only yeah i mean you could just as easily query your local node but the point is you're just reading","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=2284s"},{"start_seconds":2292,"text":"from the network right yep that's that's what you're saying earlier yeah that makes sense correct so basically what to to to just uh you know push","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=2292s"},{"start_seconds":2300,"text":"the boundary of this idea uh let's have this thought experiment essentially what","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=2300s"},{"start_seconds":2306,"text":"a view function is needed let's have exactly a look","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=2306s"},{"start_seconds":2313,"text":"what this function is needed is the this map of which is called accounts which is essentially public key to","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=2313s"},{"start_seconds":2322,"text":"balance this is the only thing it's it needs to get executed if you can have this","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=2322s"},{"start_seconds":2331,"text":"mapping locally you can run this function locally so there is another method in on","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=2331s"},{"start_seconds":2340,"text":"on jason rp side is the view contract state you can download essentially the state","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=2340s"},{"start_seconds":2350,"text":"you can download the state you have a contract you can run the contract on your local machine it's","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=2350s"},{"start_seconds":2358,"text":"a vast binary any wasman time will do pass the state and it will just crunch","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=2358s"},{"start_seconds":2366,"text":"it it can crunch it for minutes days no problem you are working with your own","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=2366s"},{"start_seconds":2374,"text":"state on your local machine unlimited resources you don't need to modify the data","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=2374s"},{"start_seconds":2381,"text":"that's why it's very different from the change methods in general","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=2381s"},{"start_seconds":2392,"text":"so i even have a suggestion that we may explore in the future","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=2392s"},{"start_seconds":2400,"text":"extension to near api jazz which will essentially download the state download the contract and","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=2400s"},{"start_seconds":2409,"text":"execute certain methods that it's needed uh on the on the browser on the client side","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=2409s"},{"start_seconds":2417,"text":"you can do it you know again and again whatever amount of times for whichever accounts it needs to compete","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=2417s"},{"start_seconds":2425,"text":"to make the computation uh and this way avoid any uh interaction through json or pc so you don't need","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=2425s"},{"start_seconds":2433,"text":"json or pc anymore if you have the state and you have the code you can just run it locally yeah that makes sense so","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=2433s"},{"start_seconds":2441,"text":"so if you're if you're dealing with kind of some some uh application that that has a lot of reads from the network and you want to make it","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=2441s"},{"start_seconds":2448,"text":"more responsive that's your point you can just download the the contract and and you can download the state of the of the account right there","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=2448s"},{"start_seconds":2457,"text":"in your browser and just just interact with it locally and then update the cache whenever whenever you want to do that right yeah yeah that that's interesting i hadn't","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=2457s"},{"start_seconds":2464,"text":"thought of that yeah yeah i'm this this has been great uh","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=2464s"},{"start_seconds":2471,"text":"frol i don't think there's uh is there much else that you want to cover in terms of this or do you feel like this is this is enough","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=2471s"},{"start_seconds":2478,"text":"i feel it it's enough uh for now uh we may dive into like more in details how they","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=2478s"},{"start_seconds":2486,"text":"uh function like how the transactions essentially are construct constructed but i think we can go to with a different so it's","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=2486s"},{"start_seconds":2494,"text":"it's a completely different topic uh yeah it's a huge one uh i would cover it in a separate session","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=2494s"},{"start_seconds":2502,"text":"yeah okay cool um so should we stop recording here and then uh i think thanks everybody to for","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=2502s"},{"start_seconds":2511,"text":"listening and uh hope you if you have any questions feel free to ask them in discord and","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=2511s"},{"start_seconds":2518,"text":"reach me out uh give help so","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=2518s"},{"start_seconds":2528,"text":"see","url":"https://www.youtube.com/watch?v=9A7LvmBn0iQ&t=2528s"}],"youtube_url":"https://youtube.com/watch?v=9A7LvmBn0iQ","url":"https://near-pedia.xyz/videos/9A7LvmBn0iQ"}