{"id":"fQpZPdoSm18","title":"NEAR Blockchain Concepts (5/6) -- Account Details and Contracts","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/fQpZPdoSm18/hqdefault.jpg","transcript_text":"thank you so much for uh being here um and taking the time to talk to us about the rpc interface for uh near protocol this has been a kind of one of these very mysterious parts of the platform we don't spend a lot of time talking about it we don't have a lot of examples where we we talk about this normally we're interfacing with the rpc through near cli or near api js and and so obviously for developers that want to build either new apis new wrappers or they want to directly communicate with the rpc api this will be invaluable for them and what we've agreed to do for this is we have a list of questions prepared to kind of shape the conversation but but maybe not limit it and so we'll just start answering those questions you will be speaking as if to a developer with you know five ten years experience and i will slow you down if i feel like you know maybe something i don't understand or you know too many other people won't understand and this way we'll just move through this the conversation and we can see uh where we land with it yeah sure uh it's great sheriff thanks for intro we i definitely see that we usually don't notice how rpc is used but as you said it's very core piece of infrastructure that is used across the board and that's why it feels like it's still very important to know exactly what this it is capable of so let's uh let's start let's talk about uh you know this this kind of uh one of the questions that we have in the document here that we're tracking how can i find out which contracts are deployed how can i find out which contracts are deployed yeah so first of all i just want to briefly mention that the contracts are the accounts in here that has uh code wisdom code uploaded to the network so whenever you talk about the contracts you usually need to look into account section and it is it is sharing the same account id all that information so every contract has account information though not every account has the code uploaded deployed to it so keep that in mind so whenever we are talking about contracts you can always make a view account uh call to jason rpc this is a query you need to issue you essentially specify that your request type is view account specify the time frame that you are interested in usually you on to be on the safe side of things you prefer to be and pull the latest data that is final uh you can read more about other options like other finality states uh or how to specify the specific block hash or hate uh to create the historical data but with this example you can see how to query the latest uh here's the example where we use testnet account near cat and the example response would be one that contained the account balance it's a liquid balance locked the balance that the the account can have natively staked and the most important part here is a code hash so code hash is essentially a um a checksum of the uploaded contract in base 58 encoding it is unusual and we essentially consider it to provide more expected uh hex encoded hashes but overall right now uh it is base 58 and when you see all ones here it essentially means that there is no code it is 32 0 bytes which are when when you encode them in base 58 gives us this representation so this is uh this is an indicator that there is nothing uh no code deployed to this account uh other uh info here just for fyi is that the storage usage is the amount of bytes this account reserves for itself when you don't have code deployed to the account and this number is only used to store the amounts the account id and that's pretty much it and just heads up here as well this field is duplicated soft duplicated we prefer to keep backwards compatible that's why it's not deleted and this information is the one that you could refer to as a like the reference when this data when this response was uh essentially generated because you have independent nodes peer-to-peer some nodes could be outdated and you can essentially end up creating final latest state for that node but you you can't um be sure that it's up to date this uh reference here uh serves you the purpose to be um on the safe page you can estimate how like outdated the data is uh or it is uh not so uh okay so it sounds like there's a couple of things that you've covered here so the first thing that you said is that accounts and contracts have this one-to-one relationship near has accounts that have friendly names human readable names you may or may not deploy a contract to an account if there's no contract deployed to an account code hashes all once that's the default when you deploy a contract to an account then the code hash will change to be something like the checksum or the checksum of the contract uh binary code actually so that's how you know and so that it's like a fingerprint for the contract if two accounts have the same code hash you know they have the same contract that's kind of the part there there's some of this metadata that some people may recognize this when they're using near cli they basically get this metadata back this response back about the account uh it's basically a pass-through from from the rpc api and and then the last thing that you said about block height and block hash is that because we're asking for final finale final the block height and block hash of this data we can assume and this is a question i'm asking you we can assume this is the the the that any any node which is uh tracking this shard any any node in the network and you interrogate this this block height or this block hash has basically come to consensus about this account state yep that is what you're saying yeah because yeah yeah and uh and also like when the network progresses the new changes could be made to the account but certain node could fall out of sync and that's why it's very important to not blindly rely on the like whenever i ask for final state i can just ignore the fact that uh like the the data could be outdated you you're saying that you should you shouldn't just ignore the date you should actually verify that this is a current block height or a variable if if you care uh about the latest you need to double check that you are on the on the same page with the tip of the network so that's that's news to me actually so so are you saying that there is a scenario where the query can be finality final and somehow the the rpc interface that i'm interrogating might get a response from an outdated node yeah okay and and and then what would be your your recommendation then the block height that i get back i ask the network again how far it is from the current tip something like that yeah you would probably want to check the status uh very first probably the very first yeah so some status endpoint and we can yeah yeah yeah so essentially you issue an empty a method with empty parameters that is and you will receive all all the useful data from the node uh what you want to learn is the latest block heat and make sure that the latest block time is somewhat recent uh according to your expectations you can also check if it if the node is syncing if it's uh if it's false it's mean that the node is uh reasonably up to date it could be just a few blocks behind and just because of the latency across the network but if it's uh if it's not too too outdated the flag will be false and this will uh help you to understand that this latest blockade is essentially uh quite recent you can pair this latest blockade with the one that you receive from the uh query account response and this way you can read about the the freshness of the data okay so so this this is um i think uh a key a key point that you're making let me see if i can restate it um with any one of these rpc endpoints not just this first one that we happen to start with the block height is included in the response uh typically uh and i would assume it's just sort of part of the response i i actually haven't checked if they all did lock height but it seems reasonable so even if the finality is set to final because there's other uh uh parameters or other values for the for the parameter finality there right um so if i assume functionality is set to final when i make my query i there is a there is a chance i don't know if it's a good chance or not but a chance that i'm getting back very the most recent data but there's also a non-zero chance that the data is actually outdated and so the the the there's a requirement here that i query again to maybe a more general endpoint the status end point you're saying and from this status end point make sure that the node is not syncing the reply in the status otherwise if it's syncing it it also might be out of date so syncing should be false in that reply and then compare the block heights and maybe the time stamps uh of the status to get a sense of actually how recent this data is so this is how you would think about it when you're pulling this data back right and we know that blocks are produced once a second and so if it's more than a few seconds out of sync it's entirely possible that something else has happened on that account to change its state at that point a new contract could have been deployed or the amount could have changed or whatever right i just want to clarify uh if the account is not under um heavy updates it does not get a lot of traffic usually the the changes would be invisible and like that it's rare when something would go wrong i just wanted to make sure that we are understanding that the implications of why it is here why it is it could be useful and what it could indicate that something is not working fine so you could imagine the situation when you have a system in built that is constantly querying the status page in background and saves this like well the latest is this you just have it in your program and the rest of the program is querying various endpoints like viewing accounts viewing some other data and it instead of just requesting all the time like i do one query and then make a credit to status i i even i would suggest probably to have it in status checks in background sitting checking what is the latest and then you can whenever you credit the view account you can immediately uh write in your program compare with the latest okay i i recently requested status page and now i just see that well this uh blockade has been reasonably up to date so yeah i think that makes perfect sense the way you just described it so the way i was suggesting it was inefficient that you would sort of have this query every time in the end you you know for a fact because of the nature of this system and as blocks progress nodes are going to come to consensus when you query from the rpc you may be querying a node that that's a little bit out of date or you know it doesn't have the latest sort of information and so why not just have this heartbeat constantly monitoring the the state of the network right and and just have have this continually progressing and just verify your queries against this cached uh you know sort of tracer of the tip of the network that you've made right that makes perfect sense yeah yeah so getting back to the original question how do we query the contract and what what exactly do you want to learn about the contract what is the original question so yeah so so the way i was thinking about this is if if if i want to ask a question you know how do i know which contract is deployed on a specific account i might be for example working against a staking pool about to send my money uh you know to stake my money in this uh tokens in this staking pool and i want to know like is it actually the correct version of this thing is it is it the one that i expect or maybe it's a dao that i'm working with and i want to make sure that it's it's the dow that you know that i can see locally the source code that i can see locally is actually deployed in this particular account before i you know uh send a proposal to the dao so this kind of reasoning about the integrity of the contract that's been deployed on chain uh being able to verify that it's what i'm looking at in the source code that i have locally um i want to sort of factor out the idea of like deterministic compiles like if you compile the contract on your machine or i compile it on my machine it produces the same code hash i'm not sure if that's currently even the case but let's say that were the case then the question it's it seems like it would be one of the most common questions actually that you would ask about a system like this is the code that's currently running the code that i'm looking at and so that's where this uh this question comes from but um that's the single account question we can expand it and say do these two accounts have the same contract on them and the answer is easy if they share the same code hash the answer is yes and you're done at that point there's nothing more complicated to think about and if i ask for example which which accounts have this contract on them across all accounts in the system uh the rpc interface maybe isn't the right way to ask that right you were saying yeah uh let me answer when the one by one so there is still a lot of ongoing work uh in terms of like um defining the interfaces of the contracts um or learning what exactly is the code so i will start attacking this problem with from the technical point of view what what is currently what is the state so currently you can upload any wasm code to the network this means that you can produce this wasm code from like even write it down manually you can use wazi it wasn't text format to write down the assembly assembly code and compile to wasm binary and applaud it you don't need to use sdks you don't need to use rust or assembly script you can use c c plus plus even raw format raw assembly web assembly and ultimately you will just upload a binary blob to the storage and the network will happily accept it and store it your storage usage will increase your code hash will be updated and that's pretty much it uh there is no hard requirements as to provide certain methods you can apply the code which has no methods you can apply some code which does not compile it's not a valid version binary you still can upload it you will only notice that something is going wrong when you try to call it and you will receive certain errors like okay it's it's not a valid binary it's it's an image like it was like you can apply jpeg or png uh image there it's useless but you could um your point is it doesn't even have to be a wasm exactly exactly you won't be able to execute the code if there is no correct code in it and this is a this turns to be a very good flexibility from one point of view but it turns out to be quite problematic for those who really expect the code to be there and they want to verify that the code is what they expect to be so currently there is no way to throw from just another pc to learn what what code is doing and what what it is there uh what we tried to build is essentially so as as you mentioned there is a concept of reproducible builds when you whenever you compile on any computer out there the same code will produce the same binary this is implemented for rust sdk we have a docker image with all the environment fixed to to the point that if you upload download the same docker file you will try to compile the same code you will receive the same binary so it is reproducible now but and the idea was our idea was to keep track of our core contracts when we recompile them we record this binary has this code hash and this way you could probably you could verify that lookup essentially what this code hash is referring to what which which contracted it there is currently no implementation it's still under construction but this is the reasonable way to think about this problem and another approach to to this problem is to target from different angle instead of defining exactly this is a binary and this binary represents that code uh you could build into your code a special method um which you can query uh so for example the the the method would be like get contract info so it would be sitting right in the contract it would be just a function and given the nature of uh near protocol you can make a view function calls they are free of charge you don't need to pay for them it's not a transaction you cannot do any mutation inside the function inside the function you are calling but you can return certain values you can read and in this particular case that i'm trying to explain you can you can return always a constant set of fields saying well i am a contract lockup i'm a lock-up contract i'm i have a version 1.0 i have uh these methods i comply with this nap standard and that way you could build uh a convention to provide your like contracts out there if if we build a convention and have such a method on every contract that would be the way to get some idea what the contract is capable of doing all of this is hypothetical like we are still trying to shape it together but hopefully somebody in the community could be also interested in this problem and we can arrive to a generic solution we have some discussions and there are different requirements people want different things that's why i didn't really progress into a final decision and if you want to participate you can still chip in uh there are nap nap discussions i guess we will link to the discussions in the video notes yeah and then just just to kind of to kind of summarize what you're saying is so we were talking about the contract that is deployed to an account and asking the question how do i know what contract is deployed to an account and we were saying if we have deterministic compiles which we do in the docker image that is standardized i can compile the code on this docker image and expect to see a consistent output no matter what the platform is where this image is running i get the same code hash i know that this source code is deployed to this contract you went on then to say maybe an improvement or an enhancement of this answering this question would be to actually discover what code is running or what the contract is you could interrogate the account and ask you know by sending a function call here as you have on the screen tell me about yourself some sort of a reflection api or maybe it's an exact name abstract binary interface api or some json blob that represents the interface somehow or maybe as you said even simply just a string message that represents the specification that it adheres to or the url of the nep that it adheres to anything like that it's still not quite clear what the best way to implement something like that is there's ongoing discussions but and you know uh there's there's no at this point there's no wrong way to implement that so if people want to allow their contracts to be discoverable to be something that the developers can interrogate in the community just add a method and document it if you query this method my contract will tell you all about itself right something like that yeah so my current take usually is that i try to so i have some idea what the contract could be uh for example i have an idea that they um contract could be a lockup contract i would open it on our repo scroll down to interfaces section and come on yeah so here is the list of like owner methods they usually are protected for owner usage staking methods and then i'm scrolling down to view methods so any or anything that starts with get is usually the case um i'm just trying to make those view calls to make this free of charge poll to the method to certain methods and try to understand what what the contract that is deployed there so you're saying you're saying yet another method of discovering the contract that is deployed on an account yeah so it's it's it's all kind of just just experiment with the interface to see if it matches the documented interface yeah that makes sense yeah so it's i mean sort of a workaround right now given that we don't have a spec special way to create a exact uh exactly what what the contract is and this way you can uh build your knowledge just just poking around you can also query in explorer you can open the account and this might be a bit confusing but but the account named near is actually uh has the lock-up account or the lock-up contract deployed to it uh sorry yeah the um the link drop a contract yeah sorry yeah so here's a link dropper a contract it's a separate repo by the way it's not very well documented in terms of like i just described that you could look up so let's uh let's use another way uh just to i will walk you through i usually open the open the uh libras implementation i scroll down to find the main contract implementation uh i ignore those that are payable because they are not going to work very well for me you can still actually call this method as a view method it will just fail it will say that well it does not work in view call context but it still will give you an idea that the the method is essentially there so the method exists um but you can uh scroll down and see well there is a get key balance for example method you can call it uh it's it's definitely not changing the state and that's why vuequal will succeed yeah and and in rust you can tell it's a view call because it there it's not mutable uh self exactly yeah this itself is is either borrowed or owned by the method right either there's an ampersand or no ampersand right something like that yep yeah so another way would be to just search for the self oh it's always borrowed yeah yeah or uh or as i said before you can try with get usually usually by conventionally also prefix them with get um yeah and as as you mentioned the uh mirror account is essentially a contract uh with this link drop on it and there are plenty of useful methods like create account and create account and claim and you can see that there are quite a few create account calls and there is send call so uh by looking into explorer you can also build some um expectations what this country could be if it's it's not answering your question you know in programmatic way but it it is a way to just at least discover what it is yeah sure if it cracks like a duck it's a duck if it if it adheres to the interface then it's close enough to that contract it may not be exactly that contract yeah okay so so i think that makes sense um i i don't know if we've covered sort of the the other piece of this so so right now we've covered how do i discover uh something uh uh meaningful about the contract uh deployed to an account and it's the code hash is the answer that's the fingerprint the the uh the hash of of the binary of the contract effort's been compiled so that that's useful if i want to compare two accounts to see if they have the same contract i just compare the code hash there's other things that we've discussed here in in terms of you know how i can check the interface test it poke edit to see if it's behaving the same way what if we kind of zoom out with a different framing of the question unless there's more to say about this what if we zoom out and say how do i ask or answer the question what contracts have been deployed on this account throughout history so i have an account i want to know has this account always had the same contract or has the contract changed over time how do i answer something like that uh you kind of do it uh like in a single call uh what i could suggest is to use this block id and instead of creating the latest data of view account you query certain block height you essentially have the monotonically increasing block height over the time and you can start with the quitting the latest check if a binary search kind of uh binary search yes to to identify the certain uh boundaries yeah where is the where is the point that it changed did it change halfway in the history or you know exactly upper lower bounds or whatever and and try and collapse that window yeah i mean so so this this would be uh i think useful for sort of course changes big changes if the if the account version if the contract on an account changed once or twice in history i might be able to kind of use something like this kind of get blame you know approach to trying to figure out where did it change in the block height history but if if it's if it's an account that sort of changes you know periodically or just for a moment that changes back i wouldn't be able to detect this actually very very well with this approach i would maybe need like an indexing service and then i could query you know how many times has this changed or something like that so we wouldn't be able to query the rpc api we would need the entire history of the of the chain and to be able to query that maybe using an indexing server right yeah so all the data you can see in explorer is collected throughout the history within every single block starting from genesis and recorded in its own database this is the only way right now and i guess in the future as well near core protocol does not try to come up with all the different sorts of aggregations data instead it provides a very raw access to certain points in history if you need to build some high level view you essentially are required to build a service that will go through every single block in the history and collect the data that you are interested in one approach is to use our indexer framework it's implemented in rust it essentially builds on top of the regular near node and it it serves all the data in memory about the historical block information about blocks chunks transactions receipts and their execution outcomes uh and changes so all of that is streamed to you and it's it's up to you you could use that framework you can you you could build it on top of json rpc using the using the blocks api and fetching all the data through it but yes there is no easy way to navigate the history uh other than specifying the blockade so that's that's the limitation of our near protocol modes but as i said it's a huge scope of work and you could easily decouple it that's why we decided to decouple it and the indica framework is just another piece of software and you it's it's easily integrated and after that you you are free to um do whatever you want with the data and index it in a way that you it makes sense to you that's totally correct you know that and there is no such method in jsonpc right now yeah an aggregate method you mean there's no way to do that you you need to use an indexer or something yeah and the indexer framework is pretty pretty straightforward to set up actually it's well documented and there's a couple of examples for the wallet and explorer already there implemented and i think badan wrote a tutorial that works quite well you","transcript_synced_at":"2026-11-04T04:15:53.454Z","segments":[{"start_seconds":7,"text":"thank you so much for uh being here um and taking the time to talk to us about the rpc interface","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=7s"},{"start_seconds":15,"text":"for uh near protocol this has been a kind of one of these very mysterious parts of the platform we don't spend a","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=15s"},{"start_seconds":22,"text":"lot of time talking about it we don't have a lot of examples where we we talk about this normally we're interfacing with the rpc through near cli or","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=22s"},{"start_seconds":30,"text":"near api js and and so obviously for developers that want to build either new apis new wrappers or they want to","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=30s"},{"start_seconds":37,"text":"directly communicate with the rpc api this will be invaluable for them and what we've agreed to do for this is we have a list of questions prepared","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=37s"},{"start_seconds":45,"text":"to kind of shape the conversation but but maybe not limit it and so we'll just start answering those questions you will be speaking as if to","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=45s"},{"start_seconds":53,"text":"a developer with you know five ten years experience and i will slow you down if i feel like you know maybe something i don't understand","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=53s"},{"start_seconds":61,"text":"or you know too many other people won't understand and this way we'll just move through this the conversation and we can see uh where we land with it","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=61s"},{"start_seconds":69,"text":"yeah sure uh it's great sheriff thanks for intro we i definitely see that","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=69s"},{"start_seconds":75,"text":"we usually don't notice how rpc is used but as you said it's very","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=75s"},{"start_seconds":83,"text":"core piece of infrastructure that is used across the board and that's why it feels like it's still","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=83s"},{"start_seconds":92,"text":"very important to know exactly what this it is capable of so let's uh let's start let's talk about","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=92s"},{"start_seconds":99,"text":"uh you know this this kind of uh one of the questions that we have in the document here that we're tracking how can i find out which contracts are deployed how can i","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=99s"},{"start_seconds":108,"text":"find out which contracts are deployed yeah so first of all i just want to briefly mention that the contracts are the accounts in here","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=108s"},{"start_seconds":117,"text":"that has uh code wisdom code uploaded to the network so whenever you","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=117s"},{"start_seconds":125,"text":"talk about the contracts you usually need to look into account section and it is","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=125s"},{"start_seconds":132,"text":"it is sharing the same account id all that information so every contract has account","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=132s"},{"start_seconds":139,"text":"information though not every account has the code uploaded deployed to it","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=139s"},{"start_seconds":146,"text":"so keep that in mind so whenever we are talking about contracts you can always make a view account uh","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=146s"},{"start_seconds":155,"text":"call to jason rpc this is a query you need to issue you essentially specify","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=155s"},{"start_seconds":163,"text":"that your request type is view account specify the time frame that you are interested in","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=163s"},{"start_seconds":170,"text":"usually you on to be on the safe side of things you prefer to be and","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=170s"},{"start_seconds":177,"text":"pull the latest data that is final uh you can read more about other options","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=177s"},{"start_seconds":183,"text":"like other finality states uh or how to specify the specific block hash or hate","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=183s"},{"start_seconds":191,"text":"uh to create the historical data but with this example you can see how to query the latest","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=191s"},{"start_seconds":199,"text":"uh here's the example where we use testnet account near cat and the example response would be","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=199s"},{"start_seconds":208,"text":"one that contained the account","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=208s"},{"start_seconds":214,"text":"balance it's a liquid balance locked the balance that the the account","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=214s"},{"start_seconds":221,"text":"can have natively staked and the most important part here is a code hash","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=221s"},{"start_seconds":230,"text":"so code hash is essentially a um a checksum of the uploaded contract","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=230s"},{"start_seconds":238,"text":"in base 58 encoding it is unusual and we essentially consider it to","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=238s"},{"start_seconds":247,"text":"provide more expected uh hex encoded","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=247s"},{"start_seconds":254,"text":"hashes but overall right now uh it is base 58 and when you see all ones here it essentially means","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=254s"},{"start_seconds":264,"text":"that there is no code it is 32 0 bytes which are when when you encode them","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=264s"},{"start_seconds":273,"text":"in base 58 gives us this representation so this is uh this is","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=273s"},{"start_seconds":281,"text":"an indicator that there is nothing uh no code deployed to this account","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=281s"},{"start_seconds":287,"text":"uh other uh info here just for fyi is that the storage usage is the amount of bytes","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=287s"},{"start_seconds":295,"text":"this account reserves for itself when you don't have code deployed to the account","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=295s"},{"start_seconds":302,"text":"and this number is only used to store the amounts the account id","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=302s"},{"start_seconds":310,"text":"and that's pretty much it and just heads up here as well this field is duplicated","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=310s"},{"start_seconds":318,"text":"soft duplicated we prefer to keep backwards compatible that's why it's not deleted and this information is the one that you","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=318s"},{"start_seconds":326,"text":"could refer to as a like the reference when this data when this response","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=326s"},{"start_seconds":334,"text":"was uh essentially generated because you have","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=334s"},{"start_seconds":342,"text":"independent nodes peer-to-peer some nodes could be outdated and you can essentially end up creating","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=342s"},{"start_seconds":351,"text":"final latest state for that node but you you can't um","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=351s"},{"start_seconds":359,"text":"be sure that it's up to date this uh reference here uh","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=359s"},{"start_seconds":365,"text":"serves you the purpose to be um on the safe page you can estimate how like outdated the data is","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=365s"},{"start_seconds":374,"text":"uh or it is uh not so uh okay so it sounds like there's a couple of things that you've covered here so","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=374s"},{"start_seconds":381,"text":"the first thing that you said is that accounts and contracts have this one-to-one relationship near has accounts that have friendly names human readable names","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=381s"},{"start_seconds":390,"text":"you may or may not deploy a contract to an account if there's no contract deployed to an account code hashes all once that's the","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=390s"},{"start_seconds":397,"text":"default when you deploy a contract to an account then the code hash will change to be something like the checksum or the","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=397s"},{"start_seconds":405,"text":"checksum of the contract uh binary code actually so that's how you know and so that it's like a fingerprint for the contract if two accounts have the same code hash","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=405s"},{"start_seconds":413,"text":"you know they have the same contract that's kind of the part there there's some of this metadata that some people may recognize this when they're using near cli they basically","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=413s"},{"start_seconds":422,"text":"get this metadata back this response back about the account uh it's basically a pass-through from from the rpc api","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=422s"},{"start_seconds":429,"text":"and and then the last thing that you said about block height and block hash is that because we're asking for final","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=429s"},{"start_seconds":437,"text":"finale final the block height and block hash of this data we can assume and this is a question i'm asking you we can assume","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=437s"},{"start_seconds":444,"text":"this is the the the that any any node which is uh tracking this shard any any node in the network","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=444s"},{"start_seconds":452,"text":"and you interrogate this this block height or this block hash has basically come to consensus about this account state","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=452s"},{"start_seconds":459,"text":"yep that is what you're saying yeah because yeah yeah and uh and also like when the network progresses","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=459s"},{"start_seconds":468,"text":"the new changes could be made to the account but certain node could fall out of sync","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=468s"},{"start_seconds":477,"text":"and that's why it's very important to not blindly rely on the like whenever i","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=477s"},{"start_seconds":484,"text":"ask for final state i can just ignore the fact that uh like the","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=484s"},{"start_seconds":492,"text":"the data could be outdated you you're saying that you should you shouldn't just ignore the date you should actually verify that this is a current block height or a variable","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=492s"},{"start_seconds":500,"text":"if if you care uh about the latest you need to double check that you are","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=500s"},{"start_seconds":507,"text":"on the on the same page with the tip of the network so that's that's news to me actually so so are you saying that there is a scenario","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=507s"},{"start_seconds":516,"text":"where the query can be finality final and somehow the the rpc interface that i'm interrogating might get a response from an outdated","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=516s"},{"start_seconds":524,"text":"node yeah okay and and and then what would be your your recommendation then the block height that i get back i","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=524s"},{"start_seconds":533,"text":"ask the network again how far it is from the current tip something like that yeah you would","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=533s"},{"start_seconds":540,"text":"probably want to check the status uh very first probably the very first","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=540s"},{"start_seconds":550,"text":"yeah so some status endpoint and we can yeah yeah yeah so essentially you issue an empty a method with empty parameters","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=550s"},{"start_seconds":558,"text":"that is and you will receive all all the useful data from the node","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=558s"},{"start_seconds":567,"text":"uh what you want to learn is the latest block heat and make sure that the latest block time","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=567s"},{"start_seconds":576,"text":"is somewhat recent uh according to your expectations you can also check if it if the node is syncing if it's uh","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=576s"},{"start_seconds":584,"text":"if it's false it's mean that the node is uh reasonably up to date it could be just a few blocks behind","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=584s"},{"start_seconds":591,"text":"and just because of the latency across the network but if it's uh if it's not too","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=591s"},{"start_seconds":599,"text":"too outdated the flag will be false and this will uh help you to understand that this","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=599s"},{"start_seconds":607,"text":"latest blockade is essentially uh quite recent you can pair this latest blockade with the one that you receive from the","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=607s"},{"start_seconds":616,"text":"uh query account response and this way","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=616s"},{"start_seconds":624,"text":"you can read about the the freshness of the data okay so so","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=624s"},{"start_seconds":633,"text":"this this is um i think uh a key a key point that you're making let me see if i can restate it um","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=633s"},{"start_seconds":641,"text":"with any one of these rpc endpoints not just this first one that we happen to start with the block height is included in the response uh typically","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=641s"},{"start_seconds":649,"text":"uh and i would assume it's just sort of part of the response i i actually haven't checked if they all did lock height but it seems reasonable","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=649s"},{"start_seconds":657,"text":"so even if the finality is set to final because there's other uh uh parameters or other values for the for the parameter finality there","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=657s"},{"start_seconds":665,"text":"right um so if i assume functionality is set to final when i make my query i there is a there is a chance i don't","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=665s"},{"start_seconds":673,"text":"know if it's a good chance or not but a chance that i'm getting back very the most recent data but there's also a non-zero chance that the data is actually outdated and so","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=673s"},{"start_seconds":681,"text":"the the the there's a requirement here that i query again to maybe a more general endpoint the","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=681s"},{"start_seconds":688,"text":"status end point you're saying and from this status end point make sure that the node is not syncing the","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=688s"},{"start_seconds":695,"text":"reply in the status otherwise if it's syncing it it also might be out of date so syncing should be false in that reply and then compare the block heights and maybe the time","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=695s"},{"start_seconds":704,"text":"stamps uh of the status to get a sense of actually how recent this data is so this is how you would think about it when you're pulling this data back right","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=704s"},{"start_seconds":712,"text":"and we know that blocks are produced once a second and so if it's more than a few seconds out of sync it's entirely possible that something else has","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=712s"},{"start_seconds":719,"text":"happened on that account to change its state at that point a new contract could have been deployed or the amount could have changed or","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=719s"},{"start_seconds":726,"text":"whatever right i just want to clarify uh if the","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=726s"},{"start_seconds":732,"text":"account is not under um heavy updates it does not get a lot of traffic","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=732s"},{"start_seconds":740,"text":"usually the the changes would be invisible and like that","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=740s"},{"start_seconds":747,"text":"it's rare when something would go wrong i just wanted to make sure that we are understanding that","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=747s"},{"start_seconds":754,"text":"the implications of why it is here why it is it could be useful and","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=754s"},{"start_seconds":762,"text":"what it could indicate that something is","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=762s"},{"start_seconds":767,"text":"not working fine so you could imagine the situation when you have a system in built","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=767s"},{"start_seconds":776,"text":"that is constantly querying the status page in background and saves this","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=776s"},{"start_seconds":782,"text":"like well the latest is this you just have it in your program and the rest of the program","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=782s"},{"start_seconds":790,"text":"is querying various endpoints like viewing accounts viewing some other data and it instead of just","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=790s"},{"start_seconds":798,"text":"requesting all the time like i do one query and then make a credit to status i i even i would suggest","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=798s"},{"start_seconds":806,"text":"probably to have it in status checks in background sitting checking what is the latest and then you can whenever you credit the","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=806s"},{"start_seconds":814,"text":"view account you can immediately uh write in your program compare with the latest okay i i recently","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=814s"},{"start_seconds":822,"text":"requested status page and now i just see that well this uh","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=822s"},{"start_seconds":829,"text":"blockade has been reasonably up to date so yeah i think that makes perfect sense the way you just described it so","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=829s"},{"start_seconds":836,"text":"the way i was suggesting it was inefficient that you would sort of have this query every time in the end you you know for a fact because of the nature of this","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=836s"},{"start_seconds":843,"text":"system and as blocks progress nodes are going to come to consensus when you query from the rpc you may be querying a node that that's a little bit","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=843s"},{"start_seconds":851,"text":"out of date or you know it doesn't have the latest sort of information and so why not just have this heartbeat constantly monitoring the the","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=851s"},{"start_seconds":859,"text":"state of the network right and and just have have this continually progressing and just verify your queries against this cached","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=859s"},{"start_seconds":866,"text":"uh you know sort of tracer of the tip of the network that you've made right that makes perfect sense yeah yeah so","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=866s"},{"start_seconds":875,"text":"getting back to the original question how do we query the contract and","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=875s"},{"start_seconds":882,"text":"what what exactly do you want to learn about the contract what is the original question so yeah so so the way i was thinking about this is if","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=882s"},{"start_seconds":890,"text":"if if i want to ask a question you know how do i know which contract is deployed on a specific account","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=890s"},{"start_seconds":897,"text":"i might be for example working against a staking pool about to send my money uh you know to stake my money in this uh","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=897s"},{"start_seconds":904,"text":"tokens in this staking pool and i want to know like is it actually the correct version of this thing is it is it the one that i expect or maybe it's a dao","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=904s"},{"start_seconds":912,"text":"that i'm working with and i want to make sure that it's it's the dow that you know that i can see locally the source code that i can see locally is actually deployed in this particular account","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=912s"},{"start_seconds":921,"text":"before i you know uh send a proposal to the dao so this kind of reasoning about the integrity of the contract that's been deployed on chain","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=921s"},{"start_seconds":929,"text":"uh being able to verify that it's what i'm looking at in the source code that i have locally um i want to sort of factor out the idea","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=929s"},{"start_seconds":938,"text":"of like deterministic compiles like if you compile the contract on your machine or i compile it on my machine it produces the same code hash i'm not sure if that's currently even the case","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=938s"},{"start_seconds":946,"text":"but let's say that were the case then the question it's it seems like it would be one of the most common questions actually that you would ask about a","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=946s"},{"start_seconds":955,"text":"system like this is the code that's currently running the code that i'm looking at and so that's where this uh this question comes from but","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=955s"},{"start_seconds":963,"text":"um that's the single account question we can expand it and say do these two accounts have the same contract on them and the answer is easy","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=963s"},{"start_seconds":971,"text":"if they share the same code hash the answer is yes and you're done at that point there's nothing more complicated to think about","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=971s"},{"start_seconds":977,"text":"and if i ask for example which which accounts have this contract on them","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=977s"},{"start_seconds":985,"text":"across all accounts in the system uh the rpc interface maybe isn't the right way to ask that right you were saying yeah uh let me","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=985s"},{"start_seconds":993,"text":"answer when the one by one so there is still a lot of ongoing work uh","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=993s"},{"start_seconds":1000,"text":"in terms of like um defining the interfaces of the contracts um or","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=1000s"},{"start_seconds":1007,"text":"learning what exactly is the code so i will start attacking this problem with","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=1007s"},{"start_seconds":1014,"text":"from the technical point of view what what is currently what is the state so currently you can upload any","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=1014s"},{"start_seconds":1023,"text":"wasm code to the network this means that you can produce this wasm code from","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=1023s"},{"start_seconds":1030,"text":"like even write it down manually you can use wazi it wasn't text format","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=1030s"},{"start_seconds":1038,"text":"to write down the assembly assembly code and compile to wasm binary and applaud it","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=1038s"},{"start_seconds":1045,"text":"you don't need to use sdks you don't need to use rust or assembly script","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=1045s"},{"start_seconds":1052,"text":"you can use c c plus plus even raw format raw","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=1052s"},{"start_seconds":1059,"text":"assembly web assembly and ultimately you will","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=1059s"},{"start_seconds":1066,"text":"just upload a binary blob to the storage and","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=1066s"},{"start_seconds":1073,"text":"the network will happily accept it and store it your storage usage will increase your","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=1073s"},{"start_seconds":1081,"text":"code hash will be updated and that's pretty much it uh there is no","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=1081s"},{"start_seconds":1087,"text":"hard requirements as to provide certain methods you can apply the code which has no methods you can apply some code which","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=1087s"},{"start_seconds":1095,"text":"does not compile it's not a valid version binary you still can upload it you will only notice that something is","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=1095s"},{"start_seconds":1103,"text":"going wrong when you try to call it and you will receive certain errors like okay it's it's not a valid binary it's","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=1103s"},{"start_seconds":1111,"text":"it's an image like it was like you can apply jpeg or png uh image there it's useless","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=1111s"},{"start_seconds":1119,"text":"but you could um your point is it doesn't even have to be a wasm exactly","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=1119s"},{"start_seconds":1127,"text":"exactly you won't be able to execute the code if there is no","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=1127s"},{"start_seconds":1135,"text":"correct code in it and this is a this turns to be","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=1135s"},{"start_seconds":1142,"text":"a very good flexibility from one point of view but it turns out to be quite problematic","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=1142s"},{"start_seconds":1148,"text":"for those who really expect the code to be there and they want to verify that the code","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=1148s"},{"start_seconds":1156,"text":"is what they expect to be so currently there is no way to throw","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=1156s"},{"start_seconds":1163,"text":"from just another pc to learn what what code is doing and what what it is there uh","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=1163s"},{"start_seconds":1172,"text":"what we tried to build is essentially so as as you","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=1172s"},{"start_seconds":1179,"text":"mentioned there is a concept of reproducible builds when you whenever you compile on any","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=1179s"},{"start_seconds":1188,"text":"computer out there the same code will produce the same binary this","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=1188s"},{"start_seconds":1194,"text":"is implemented for rust sdk we have a docker image","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=1194s"},{"start_seconds":1203,"text":"with all the environment fixed to to the point that if you upload","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=1203s"},{"start_seconds":1210,"text":"download the same docker file you will try to compile the same code you will receive the same binary so","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=1210s"},{"start_seconds":1217,"text":"it is reproducible now but and the idea was","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=1217s"},{"start_seconds":1225,"text":"our idea was to keep track of our core contracts when we recompile them we record","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=1225s"},{"start_seconds":1233,"text":"this binary has this code hash and this way you could probably","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=1233s"},{"start_seconds":1240,"text":"you could verify that lookup essentially what this code hash is","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=1240s"},{"start_seconds":1249,"text":"referring to what which which contracted it there is currently no implementation it's still under construction","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=1249s"},{"start_seconds":1257,"text":"but this is the reasonable way to think about this problem and another approach to to this","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=1257s"},{"start_seconds":1266,"text":"problem is to target from different angle instead of defining exactly this is a binary and this binary","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=1266s"},{"start_seconds":1275,"text":"represents that code uh you could build into your code a special method","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=1275s"},{"start_seconds":1283,"text":"um which you can query uh so for example the the the method would be like","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=1283s"},{"start_seconds":1290,"text":"get contract info so it would be sitting right in the contract it would be just a function","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=1290s"},{"start_seconds":1299,"text":"and given the nature of uh near protocol you can make a view function calls","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=1299s"},{"start_seconds":1306,"text":"they are free of charge you don't need to pay for them it's not a transaction you cannot","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=1306s"},{"start_seconds":1312,"text":"do any mutation inside the function inside the function you are calling","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=1312s"},{"start_seconds":1320,"text":"but you can return certain values you can read and in this particular case that i'm","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=1320s"},{"start_seconds":1328,"text":"trying to explain you can you can return always a constant","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=1328s"},{"start_seconds":1335,"text":"set of fields saying well i am a contract","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=1335s"},{"start_seconds":1341,"text":"lockup i'm a lock-up contract i'm i have a version 1.0 i have uh","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=1341s"},{"start_seconds":1349,"text":"these methods i comply with this nap standard","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=1349s"},{"start_seconds":1356,"text":"and that way you could build uh a convention","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=1356s"},{"start_seconds":1363,"text":"to provide your like contracts out there if if we build a convention and have","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=1363s"},{"start_seconds":1370,"text":"such a method on every contract that would be the way to get some idea what the contract","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=1370s"},{"start_seconds":1379,"text":"is capable of doing all of this is hypothetical like we are still","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=1379s"},{"start_seconds":1386,"text":"trying to shape it together but hopefully somebody in the community could be also","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=1386s"},{"start_seconds":1394,"text":"interested in this problem and we can arrive to a generic solution we have some","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=1394s"},{"start_seconds":1405,"text":"discussions and there are different requirements people want different things that's why i didn't really progress into","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=1405s"},{"start_seconds":1415,"text":"a final decision and if you want to participate you can still chip in uh there are nap nap discussions i guess we will link","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=1415s"},{"start_seconds":1424,"text":"to the discussions in the video notes yeah and then just just to kind of to kind of summarize what you're saying is","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=1424s"},{"start_seconds":1432,"text":"so we were talking about the contract that is deployed to an account and asking the question how do i know what contract is deployed","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=1432s"},{"start_seconds":1439,"text":"to an account and we were saying if we have deterministic compiles which we do in the docker image that is standardized i can compile the code on this docker","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=1439s"},{"start_seconds":1448,"text":"image and expect to see a consistent output no matter what the platform is where this image is running i get the same code hash i know that this source","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=1448s"},{"start_seconds":1457,"text":"code is deployed to this contract you went on then to say maybe an improvement or an enhancement","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=1457s"},{"start_seconds":1464,"text":"of this answering this question would be to actually discover what code is running or what the contract is you could interrogate the account","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=1464s"},{"start_seconds":1472,"text":"and ask you know by sending a function call here as you have on the screen tell me about yourself some sort of a reflection api","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=1472s"},{"start_seconds":1480,"text":"or maybe it's an exact name abstract binary interface api or some json blob that represents the interface somehow or maybe as you said","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=1480s"},{"start_seconds":1488,"text":"even simply just a string message that represents the specification that it adheres to or the url of the nep that it adheres to","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=1488s"},{"start_seconds":1495,"text":"anything like that it's still not quite clear what the best way to implement something like that is there's ongoing discussions","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=1495s"},{"start_seconds":1503,"text":"but and you know uh there's there's no at this point there's no wrong way to implement that so if people want to allow their contracts to be discoverable","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=1503s"},{"start_seconds":1512,"text":"to be something that the developers can interrogate in the community just add a method and document it if you query this method my contract will tell you all about itself","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=1512s"},{"start_seconds":1520,"text":"right something like that yeah so my current take usually is that i try to","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=1520s"},{"start_seconds":1527,"text":"so i have some idea what the contract could be uh","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=1527s"},{"start_seconds":1537,"text":"for example i have an idea that they um contract could be a lockup contract i would open","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=1537s"},{"start_seconds":1545,"text":"it on our repo","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=1545s"},{"start_seconds":1549,"text":"scroll down to interfaces section","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=1549s"},{"start_seconds":1557,"text":"and come on yeah so here is the list of like owner methods","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=1557s"},{"start_seconds":1565,"text":"they usually are protected for owner usage staking methods and then i'm scrolling down to","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=1565s"},{"start_seconds":1572,"text":"view methods so any or anything that starts with get is usually the case um","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=1572s"},{"start_seconds":1579,"text":"i'm just trying to make those view calls to make this free of charge poll","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=1579s"},{"start_seconds":1586,"text":"to the method to certain methods and try to understand what what the contract that","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=1586s"},{"start_seconds":1596,"text":"is deployed there so you're saying you're saying yet another method of discovering the contract that is deployed on an account yeah so","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=1596s"},{"start_seconds":1605,"text":"it's it's it's all kind of just just experiment with the interface to see if it matches the documented interface yeah that makes sense","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=1605s"},{"start_seconds":1611,"text":"yeah so it's i mean sort of a workaround right now","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=1611s"},{"start_seconds":1618,"text":"given that we don't have a spec special way to create a exact uh","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=1618s"},{"start_seconds":1626,"text":"exactly what what the contract is and this way you can uh build your","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=1626s"},{"start_seconds":1634,"text":"knowledge just just poking around you can also query","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=1634s"},{"start_seconds":1642,"text":"in explorer you can open the account and this might be a bit confusing but","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=1642s"},{"start_seconds":1650,"text":"but the account named near is actually uh has the lock-up account or the lock-up contract deployed to it uh","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=1650s"},{"start_seconds":1657,"text":"sorry yeah the um the link drop a contract yeah sorry yeah","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=1657s"},{"start_seconds":1665,"text":"so here's a link dropper a contract it's a separate repo by the way it's not very well documented","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=1665s"},{"start_seconds":1674,"text":"in terms of like i just described that you could look up so let's uh let's use another way uh just to","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=1674s"},{"start_seconds":1683,"text":"i will walk you through i usually open the open the uh libras","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=1683s"},{"start_seconds":1690,"text":"implementation i scroll down to find the main","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=1690s"},{"start_seconds":1698,"text":"contract implementation uh i ignore those that are payable because they are not going to","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=1698s"},{"start_seconds":1706,"text":"work very well for me you can still actually call this method as a view method it will just fail","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=1706s"},{"start_seconds":1713,"text":"it will say that well it does not work in view call context but it still will","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=1713s"},{"start_seconds":1720,"text":"give you an idea that the the method is essentially there so the method exists","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=1720s"},{"start_seconds":1727,"text":"um but you can uh scroll down and see well there is a get key balance","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=1727s"},{"start_seconds":1736,"text":"for example method you can call it uh it's it's definitely not changing the state and that's why","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=1736s"},{"start_seconds":1743,"text":"vuequal will succeed yeah and and in rust you can tell it's a view call because it there it's not mutable uh self exactly yeah this itself","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=1743s"},{"start_seconds":1752,"text":"is is either borrowed or owned by the method right either there's an ampersand or no ampersand right something like that yep yeah so another","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=1752s"},{"start_seconds":1761,"text":"way would be to just search for the self oh it's always borrowed yeah yeah or uh or as i said","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=1761s"},{"start_seconds":1770,"text":"before you can try with get usually usually by conventionally also prefix them with get um","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=1770s"},{"start_seconds":1778,"text":"yeah and as as you mentioned the uh mirror account is essentially a contract uh","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=1778s"},{"start_seconds":1785,"text":"with this link drop on it and there are plenty of useful methods","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=1785s"},{"start_seconds":1793,"text":"like create account and create account and claim and you can see that there are quite a few create","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=1793s"},{"start_seconds":1801,"text":"account","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=1801s"},{"start_seconds":1804,"text":"calls and there is send call so uh by looking into","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=1804s"},{"start_seconds":1811,"text":"explorer you can also build some um expectations what this country could be","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=1811s"},{"start_seconds":1818,"text":"if it's it's not answering your question you know in programmatic way but it","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=1818s"},{"start_seconds":1825,"text":"it is a way to just at least discover what it is yeah sure if it cracks like a duck it's a duck if it if it adheres to the interface then it's close enough to that","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=1825s"},{"start_seconds":1833,"text":"contract it may not be exactly that contract yeah okay so so i think that makes sense um i i don't know if we've covered sort","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=1833s"},{"start_seconds":1842,"text":"of the the other piece of this so so right now we've covered how do i discover","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=1842s"},{"start_seconds":1849,"text":"uh something uh uh meaningful about the contract uh deployed to an account and it's the code hash is the answer that's the fingerprint the","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=1849s"},{"start_seconds":1856,"text":"the uh the hash of of the binary of the contract effort's been compiled so that that's useful if i want to compare two accounts to see if they have","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=1856s"},{"start_seconds":1865,"text":"the same contract i just compare the code hash there's other things that we've discussed here in in terms of you know how i can check the interface test it poke edit to see if it's","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=1865s"},{"start_seconds":1873,"text":"behaving the same way what if we kind of zoom out with a different framing of the question unless there's more to say about this","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=1873s"},{"start_seconds":1880,"text":"what if we zoom out and say how do i ask or answer the question what contracts have been deployed on this","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=1880s"},{"start_seconds":1889,"text":"account throughout history so i have an account i want to know has this account always had the same contract or has the contract changed","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=1889s"},{"start_seconds":1897,"text":"over time how do i answer something like that uh you kind of do it uh like in a single call","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=1897s"},{"start_seconds":1906,"text":"uh what i could suggest is to use this block id","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=1906s"},{"start_seconds":1912,"text":"and instead of creating the latest data of view account you query certain block height you essentially have","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=1912s"},{"start_seconds":1922,"text":"the monotonically increasing block height over the time and you can start with the","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=1922s"},{"start_seconds":1930,"text":"quitting the latest check if a binary search kind of uh binary search yes to to identify the","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=1930s"},{"start_seconds":1937,"text":"certain uh boundaries yeah where is the where is the point that it changed did it change halfway in the history or you know exactly upper lower bounds or whatever","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=1937s"},{"start_seconds":1946,"text":"and and try and collapse that window yeah i mean so so this this would be uh i think useful for sort of course","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=1946s"},{"start_seconds":1954,"text":"changes big changes if the if the account version if the contract on an account changed once or twice in history i might be able to kind of","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=1954s"},{"start_seconds":1962,"text":"use something like this kind of get blame you know approach to trying to figure out where did it change in the block height history but","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=1962s"},{"start_seconds":1969,"text":"if if it's if it's an account that sort of changes you know periodically or just for a moment that changes back i wouldn't be able to detect this","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=1969s"},{"start_seconds":1978,"text":"actually very very well with this approach i would maybe need like an indexing service and then i could query","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=1978s"},{"start_seconds":1985,"text":"you know how many times has this changed or something like that so we wouldn't be able to query the rpc api we would need","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=1985s"},{"start_seconds":1992,"text":"the entire history of the of the chain and to be able to query that maybe using an indexing server right yeah so all the data you can see in explorer","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=1992s"},{"start_seconds":2000,"text":"is collected throughout the history within every single block","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=2000s"},{"start_seconds":2007,"text":"starting from genesis and recorded in its own database this is the only","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=2007s"},{"start_seconds":2014,"text":"way right now and i guess in the future as well near core protocol does not try to","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=2014s"},{"start_seconds":2022,"text":"come up with all the different sorts of aggregations data instead it provides a very raw","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=2022s"},{"start_seconds":2029,"text":"access to certain points in history if you need to build some high level view","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=2029s"},{"start_seconds":2036,"text":"you essentially are required to build a service that will go through every single block in the history and","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=2036s"},{"start_seconds":2044,"text":"collect the data that you are interested in one approach is to use our indexer framework","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=2044s"},{"start_seconds":2051,"text":"it's implemented in rust it essentially builds on top of the regular near node and it","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=2051s"},{"start_seconds":2058,"text":"it serves all the data in memory about the historical","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=2058s"},{"start_seconds":2065,"text":"block information about blocks chunks transactions receipts and their execution","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=2065s"},{"start_seconds":2073,"text":"outcomes uh and changes so all of that is streamed to you and","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=2073s"},{"start_seconds":2080,"text":"it's it's up to you you could use that framework you can you you could build it on top of json rpc","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=2080s"},{"start_seconds":2088,"text":"using the using the blocks api","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=2088s"},{"start_seconds":2097,"text":"and fetching all the data through it but yes there is no easy way to","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=2097s"},{"start_seconds":2105,"text":"navigate the history uh other than specifying the blockade so that's","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=2105s"},{"start_seconds":2112,"text":"that's the limitation of our near protocol modes but as i said it's a huge","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=2112s"},{"start_seconds":2122,"text":"scope of work and you could easily decouple it that's why we decided to decouple it and the indica framework is just another piece of","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=2122s"},{"start_seconds":2131,"text":"software and you it's it's easily integrated and after that you you are free to um do whatever you want","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=2131s"},{"start_seconds":2140,"text":"with the data and index it in a way that you it makes sense to you that's totally correct you know that and there is no such","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=2140s"},{"start_seconds":2149,"text":"method in jsonpc right now yeah an aggregate method you mean there's no way to do that you you need to use an indexer or something yeah and the indexer framework is pretty pretty","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=2149s"},{"start_seconds":2157,"text":"straightforward to set up actually it's well documented and there's a couple of examples for the wallet and explorer already there implemented and i think badan wrote a tutorial that","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=2157s"},{"start_seconds":2166,"text":"works quite well","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=2166s"},{"start_seconds":2175,"text":"you","url":"https://www.youtube.com/watch?v=fQpZPdoSm18&t=2175s"}],"youtube_url":"https://youtube.com/watch?v=fQpZPdoSm18","url":"https://near-pedia.xyz/videos/fQpZPdoSm18"}