{"id":"xWR2nlw0R_M","title":"L1C2 - Hello NEAR a brief introduction to the platform","description":"NEAR Certified Developer\n\nThis course is an opportunity for web developers to earn a Certificate of Completion that represents the ability to design, develop, test and deploy smart contracts on the NEAR platform.\n\nSlides: http://bit.ly/near-ncd\n\nOverview\n\nDuring this course we practice the following:\n\nperceiving web 3 in the context of human history\nreading contract code in Rust and AssemblyScript\nwriting contracts using Rust and AssemblyScript\ntesting contracts using unit and simulation tests\ndeploying contracts and a sensible user interface\n\n---\n\nFollow 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-14T00:00:00.000Z","thumbnail_url":"https://img.youtube.com/vi/xWR2nlw0R_M/hqdefault.jpg","transcript_text":"so hello near what is this technology let's talk about this so near is cheaper faster and easier to use uh for development and for production um contracts we write them in assembly script or rust they compile to wasm webassembly there are a million javascript and typescript developers out there maybe including some of you that can learn assembly script in a matter of hours or days and the rust tool chain is more mature so for high value contracts for very complex contracts we would choose rust but we can always have a mix of some assembly script and some rust contracts as part of the same decentralized application so of course they would be different contracts but these contracts can communicate using cross-contract calls and then near has this unique account system that makes it easy to reason about how how contracts uh you know interact and we'll talk about some of those details in production there are some of these optimizations that are built into the protocol so gas fees hundred to 10 000 times cheaper than ethereum very very low gas fees contract accounts earn 30 percent of fees and the network will automatically redistribute accounts across shards to make sure that that things are balanced and moving quickly and responsibly even though main net today has only one chart uh before the end of the year the plan is i think to have several of those and then of course one second block time three second finality so if you're not quite sure what all of this means that's okay feel free to ask a question what does this mean what does that mean in the questions list but i'm just going to keep moving on and of course you can watch the recording anytime after this we'll publish it within 24 hours of this meeting we'll clean it up and publish it online so you can watch the recording all right any questions at this point just a reminder to ask your questions let's dive into decentralized applications at a very high level so you've got your application and you've got this blockchain near protocol blockchain over here what are you gonna do so nier exposes this api called rpc this remote procedure call it's rpc that sends and receives json over http it's a little bit of text you send it over the wire just like a website but it's you're using an api so json rpc over http that's what that api is it's not rest api uh because rest has follows a bunch of conventions you know that that match um you know crud operations in a relational database typically but um the the rpc api is instructions that you send maybe send a transaction get the status of a transaction things like that and then around that rpc interface we give you near api js which is a javascript wrapper that lets you communicate with nir from javascript and your application uses that in your api.js in fact all of our applications also do this the examples you find at near.dev near explorer near wallet near cli all the tools that we're going to be seeing and using all use exactly the same uh infrastructure here and and the key there to understand is that you know we're dependent on the same technology that you are you could say we eat our own dog food and so in that sense we want to make sure that it's as useful and friendly as possible because we're also dependent on it and of course stable because all of these things are shared by the entire community including us all right any questions about that just a reminder please add your questions and i'm not going to spend so much time on this slide from now on it's just a reminder ask questions vote on ones that are already there let's dive a little bit deeper now maybe go low level hold on to your seat because this is going to be a pretty intense tour so you've got your application and you're wondering what are you gonna build you're not really sure you're thinking about it and then all of a sudden you have an idea and you say okay i know exactly what i'm gonna build and so you write some contracts for it that's what we're learning this week how to write contracts and assembly script and rust using these software development kits near sdk as for assembly script near sdk rs for rust you've gotten your protocol over here and so you create an account on your protocol and then you deploy your contract to your account so with ethereum if you're familiar with it the account gets created for you automatically not so with near you have to create the account and you deploy a contract to it any account can have a contract on it including yours near protocol is actually two things you can think of it this blockchain layer and a runtime layer so from your application we said already you're going to use near api js now that you're writing it and you're going to send some requests to the rpc interface to use your application the blockchain layer is going to catch that request and it's going to give it to the runtime layer where a virtual machine turns on a computer turns on looks at the storage on the chain and loads your code now your code is inside the virtual machine and it's running it might read and write your contract code might read and write to the blockchain and then the virtual machine responds you've only got 200 tara gas which is about 200 milliseconds to do work in your contract and the response goes back to your application so this is what the lower level not very low but a lower level than before of your application looks like and how it interacts with near you have your contracts you deploy them to an account and then from your application you use near apijs or you can talk directly to the rpc api to communicate with the blockchain layer that has the runtime layer turn on a computer load your code read and write data storage and then give you a response and shut down every time you call a function in your contract that's what happens and you've got 200 milliseconds 200 tera gas any questions just a reminder on your own time please ask let's talk about storage a little bit more and don't forget you can watch this video anytime so what's inside storage you can actually type using near cli near state account name whatever your account name is and you'll find this metadata here you know things like the amount that's in your your contract formatted this account has 42 near or unformatted in yakuto near 10 to the 24. you'll also see a code hash which is like a fingerprint for the contract binary actually so every contract after you compile it has this unique fingerprint and two accounts that have the same contract have exactly the same code hash exactly the same fingerprint and then of course how much storage is used because you have to pay for that storage in something called storage staking where we lock up your tokens at the price of 10 year per megabyte of data the data is actually key value pairs this data happens to be base64 encoded but you can see there's three key value pairs in the data storage and we give you some abstractions on top of that so actually the contract code lives in this one special key called state for rust and assembly script contracts there's a singleton pattern where you have the contract code sitting in a key called state and the other things that you want to store are just key value pairs some of them if you see towards the bottom persistent vector and the persistent set those are wrappers around the key value pair that give you the feeling of a vector or the feeling of a set and and the you know the related kind of behaviors let's talk about testing because we're going to be doing that this week with assembly script and rust what are you doing you're writing your contract in assembly script using near sdks or you're writing your contract in rust using near sdk rs and then to write tests unit tests against the contract you have two different technologies for assembly script you use something called aspect and for rust you use something that's baked into the language where you use this kind of macro directive pound you know test in between brackets and you'll see examples of this as you look at the code you can then build your contract into a wasm file and then simulate it using simulation testing you can do that kind of one shot simulation testing with near vm in the the near cli where you just call like a method but if you want to orchestrate several contracts or call several methods and have cross contract calls you need to use the near sdk sim the simulator and again you'll see that this week where you're actually simulating the behavior of the contract as if it were on chain but before you deploy it and then finally you deploy maybe to test net or local net you'll do both of those this week where you actually deploy the contract and then you can do some integration testing maybe with near apijs or with near cli both of those you'll see this week as well so those are the three kinds of testing unit testing integration testing sorry simulation testing and integration testing in that order let's talk about accounts so the account model in near we use human readable names like alice.testnet or app.alice.testnet and as far as i know there's no limit to how many of those sub accounts you can have we can read about it in the specification if you like and so here's an example of this you know pay with.near or payby.net or whatever these are just some random accounts that i took from mainnet and we also had this idea of an implicit account where this is an account that doesn't cost you any storage and it's basically been created to reserve a name in order to get that name you have to send some tokens to this implicit account so it's a little bit of extra detail these are close to the way ethereum account names are made but again the actual account name is going to be human readable so this is like a temporary account name this implicit account you pay for data using storage staking so when you have some account this is a screenshot from the wallet there is some minimum amount of near balance that you have to keep depending on how much data your account is holding so this account has 20 near cents that is holding it you know sharif.near because there's uh something like 20 kilobytes worth of data so it's one near per 100 kilobytes 10 near per megabyte of data this account has 20 kilobytes on it and so it's holding 20 cents and that i can't spend that i can clear out the data the contract if there is one data on the account keys those all take up space and cost storage taking money i can clear those things out and then that storage staking amount will be reduced if i want to removing a contract or deleting some of the data there's an unlimited number of access keys function call and full access keys and you can see here from this account uh there's a full access and function call two different kinds of keys that we have here this account has two of each and there's an unlimited number of these keys this is this is the keys that you use uh when you sign a transaction to prove that you have control of the account to prove that it's you and so with full access keys you can see that there's nothing but the public key and then the permission and nonce how many times have you used it number used once is what non stands for for the function call key we also have a budget this allowance so you can't spend any more than that there's a receiver id who can you call with this so this function call access key here that the yellow arrow is pointing at uh has a receiver idea of banana swap and that means uh i have if i have the private key to this i can spend my money up to 25 cents that's what that is calling functions on bananaswap.near if i give you the private key you can spend 25 cents of my money calling functions on banana swap in here as well so that's how these function call access keys work with the allowance there's some limit the receiver id and then method names if it's an empty array then there's no constraint otherwise you put in the names of the functions that can be called by this function call access and so if we think about what can you do with near actually you can work with identity money and code the function call access key lets you use this one action function call action while the full access key lets you do everything create account delete account add key delete key transfer stake deploy contract and function call so again function call access key lets you do this full access key lets you do all of that that's the difference and um contracts live on one and only one shard they actually call each other using cross-contract calls here's a little bit of code that we'll look at this week in an application that we've built for you and you can see here there's a method called payout and in this method i have this contract promise batch that transfers money to a winner and then promise.then calls itself back to say the payout is complete so transfer some money and then let me know that the payout's complete that's cross-contract calls and that's effectively how near scales across shards every account is assumed to live on its own shard even one account if it makes a call to itself will go through the same machinery that it would as if it was calling some other account somewhere else across charts and that's how you get the scalability let's talk about languages briefly assembly script and rust contracts pros here for assembly script it's easier for prototyping and trivial for you to learn if you're familiar with javascript or typescript the binaries are smaller actually and they're easier to read in webassembly as text format so that might be a really interesting thing for you to do let me compile this contract an assembly script a simple one and then read the webassembly as text to see what happens in rust the pro is that you've got this mature compiler it's it's been through the ringer it's it's the best tool chain actually in the industry to go from a programming language to web assembly uh rust to wasm is is the most mature pipeline for that um and and that's um that's not surprising because of mozilla's commitment to this technology and so um there is a thriving ecosystem there's lots of real world use cases and of course near sdk rs just like near sdk as makes life easy for you there are some cons here though on assembly script the compiler is a little bit immature the ecosystem is a little immature debugging tools are a little bit immature on rust it's a very steep learning curve might take you weeks or months to to get to the point with being literate writing a rust contract from a blank page and even experts you can see sometimes they'll fight with the compiler kind of struggling to get the right syntax because the compiler doesn't like something something about how some variable is declared or who has ownership of it or who borrowed it last and so that can be a little bit of a challenge with rust if you already know russ good for you but if you if you don't know it yet i would recommend against trying to learn it this week focus on assembly script much easier to learn and the concepts are the same you're still learning about near you're not giving anything up so here's what they look like contract data on the left and right assembly script and rust you can see this idea of a posted message in assembly script it's a class in rust it's destruct and again this is recorded and you have access to the slides so if you feel like you're missing some of this or if it's going too quickly for you remember you can always come back to it here is contract behavior assembly script and rust couple of methods in both export function add message export function get messages in assembly script and in rust here public function add message and public function get messages we also need destruct and rust because of the type system no matter what though the output is always a wasm file and this is what it looks like actually this web assembly is text you can see there get message add message this is from the assembly script compilation because the rust one is a little bit harder to read and you can see here the add message method if you compare this code to the assembly script code you'll recognize exactly what's happening as we push and and put pull things push and pop things off of the stack","transcript_synced_at":"2026-11-04T04:14:39.786Z","segments":[{"start_seconds":8,"text":"so hello near what is this technology let's talk about this","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=8s"},{"start_seconds":16,"text":"so near is cheaper faster and easier to use uh for development and for production um contracts we write them in assembly script or rust they compile to wasm","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=16s"},{"start_seconds":25,"text":"webassembly there are a million javascript and typescript developers out there maybe including some of you that can learn assembly script in a matter of hours or","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=25s"},{"start_seconds":32,"text":"days and the rust tool chain is more mature so for high value contracts for very complex contracts we","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=32s"},{"start_seconds":41,"text":"would choose rust but we can always have a mix of some assembly script and some rust contracts as part of the same decentralized","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=41s"},{"start_seconds":49,"text":"application so of course they would be different contracts but these contracts can communicate using cross-contract calls and then near has this unique account","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=49s"},{"start_seconds":58,"text":"system that makes it easy to reason about how how contracts uh you know interact and we'll talk about some of those details in","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=58s"},{"start_seconds":65,"text":"production there are some of these optimizations that are built into the protocol so gas fees hundred to 10 000 times cheaper than ethereum very very low","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=65s"},{"start_seconds":74,"text":"gas fees contract accounts earn 30 percent of fees and the network will automatically","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=74s"},{"start_seconds":82,"text":"redistribute accounts across shards to make sure that that things are balanced and moving quickly and responsibly even though main net","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=82s"},{"start_seconds":90,"text":"today has only one chart uh before the end of the year the plan is i think to have several of those and then of course one second block time three second finality so if you're not","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=90s"},{"start_seconds":98,"text":"quite sure what all of this means that's okay feel free to ask a question what does this mean what does that mean in the questions list but i'm just going","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=98s"},{"start_seconds":106,"text":"to keep moving on and of course you can watch the recording anytime after this we'll publish it within 24 hours of this meeting","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=106s"},{"start_seconds":113,"text":"we'll clean it up and publish it online so you can watch the recording all right any questions at this point","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=113s"},{"start_seconds":121,"text":"just a reminder to ask your questions let's dive into decentralized applications at a very high level so you've got your application and","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=121s"},{"start_seconds":130,"text":"you've got this blockchain near protocol blockchain over here what are you gonna do so nier exposes","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=130s"},{"start_seconds":137,"text":"this api called rpc this remote procedure call it's rpc that sends and receives json over http","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=137s"},{"start_seconds":145,"text":"it's a little bit of text you send it over the wire just like a website but it's you're using an api so json rpc over http that's what that","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=145s"},{"start_seconds":153,"text":"api is it's not rest api uh because rest has follows a bunch of conventions you know that that match um you know crud","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=153s"},{"start_seconds":161,"text":"operations in a relational database typically but um the the rpc api is instructions that you send maybe send a transaction get","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=161s"},{"start_seconds":169,"text":"the status of a transaction things like that and then around that rpc interface we give you near api js which is a","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=169s"},{"start_seconds":176,"text":"javascript wrapper that lets you communicate with nir from javascript and your application uses that in your api.js in fact","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=176s"},{"start_seconds":184,"text":"all of our applications also do this the examples you find at near.dev near explorer near wallet near cli","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=184s"},{"start_seconds":193,"text":"all the tools that we're going to be seeing and using all use exactly the same uh infrastructure here and and the key there to understand is","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=193s"},{"start_seconds":201,"text":"that you know we're dependent on the same technology that you are you could say we eat our own dog food and so in that sense we want to make sure that it's as useful and friendly as possible","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=201s"},{"start_seconds":210,"text":"because we're also dependent on it and of course stable because all of these things are shared by the entire community including us all right any questions about that just","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=210s"},{"start_seconds":219,"text":"a reminder please add your questions and i'm not going to spend so much time on this slide from now on it's just a reminder ask questions vote","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=219s"},{"start_seconds":226,"text":"on ones that are already there let's dive a little bit deeper now maybe go low level hold on to your seat because this is","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=226s"},{"start_seconds":234,"text":"going to be a pretty intense tour so you've got your application and you're wondering what are you gonna","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=234s"},{"start_seconds":242,"text":"build you're not really sure you're thinking about it and then all of a sudden you have an idea and you say okay i know exactly what i'm gonna build","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=242s"},{"start_seconds":251,"text":"and so you write some contracts for it that's what we're learning this week how to write contracts and assembly script and rust using these software development kits","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=251s"},{"start_seconds":258,"text":"near sdk as for assembly script near sdk rs for rust you've gotten your protocol over here","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=258s"},{"start_seconds":265,"text":"and so you create an account on your protocol and then you deploy your contract to your account","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=265s"},{"start_seconds":273,"text":"so with ethereum if you're familiar with it the account gets created for you automatically not so with near you have to create the account and you deploy a contract to it any account","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=273s"},{"start_seconds":282,"text":"can have a contract on it including yours near protocol is actually two things you","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=282s"},{"start_seconds":289,"text":"can think of it this blockchain layer and a runtime layer so from your application we said already","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=289s"},{"start_seconds":298,"text":"you're going to use near api js now that you're writing it and you're going to send some requests to the rpc interface to use your","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=298s"},{"start_seconds":306,"text":"application the blockchain layer is going to catch that request and it's going to give it to the runtime layer where a virtual machine turns on a","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=306s"},{"start_seconds":314,"text":"computer turns on looks at the storage on the chain and loads your code","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=314s"},{"start_seconds":323,"text":"now your code is inside the virtual machine and it's running it might read and write","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=323s"},{"start_seconds":332,"text":"your contract code might read and write to the blockchain and then the virtual machine responds you've only got","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=332s"},{"start_seconds":340,"text":"200 tara gas which is about 200 milliseconds to do work in your contract","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=340s"},{"start_seconds":348,"text":"and the response goes back to your application so this is what the lower level not very","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=348s"},{"start_seconds":357,"text":"low but a lower level than before of your application looks like and how it interacts with near you have your contracts you deploy them to an account","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=357s"},{"start_seconds":366,"text":"and then from your application you use near apijs or you can talk directly to the rpc api to communicate with the blockchain layer","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=366s"},{"start_seconds":374,"text":"that has the runtime layer turn on a computer load your code read and write data storage and then give you a response","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=374s"},{"start_seconds":381,"text":"and shut down every time you call a function in your contract that's what happens and","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=381s"},{"start_seconds":388,"text":"you've got 200 milliseconds 200 tera gas any questions just a reminder","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=388s"},{"start_seconds":396,"text":"on your own time please ask let's talk about storage a little bit more and don't forget you can watch this video anytime","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=396s"},{"start_seconds":404,"text":"so what's inside storage you can actually type using near cli near state account name whatever your account name is","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=404s"},{"start_seconds":412,"text":"and you'll find this metadata here you know things like the amount that's in your your contract formatted","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=412s"},{"start_seconds":419,"text":"this account has 42 near or unformatted in yakuto near 10 to the 24.","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=419s"},{"start_seconds":426,"text":"you'll also see a code hash which is like a fingerprint for the contract binary actually so","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=426s"},{"start_seconds":432,"text":"every contract after you compile it has this unique fingerprint and two accounts that have the same","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=432s"},{"start_seconds":440,"text":"contract have exactly the same code hash exactly the same fingerprint and then of course how much storage is used because you have to pay for that","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=440s"},{"start_seconds":448,"text":"storage in something called storage staking where we lock up your tokens at the price of 10 year per","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=448s"},{"start_seconds":454,"text":"megabyte of data the data is actually key value pairs this data happens to be base64 encoded","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=454s"},{"start_seconds":463,"text":"but you can see there's three key value pairs in the data storage and we give you some abstractions on top of that so","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=463s"},{"start_seconds":472,"text":"actually the contract code lives in this one special key called state for rust and assembly script contracts there's a singleton pattern","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=472s"},{"start_seconds":480,"text":"where you have the contract code sitting in a key called state and the other things that you want to store are just key value pairs some of them if you see towards the","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=480s"},{"start_seconds":488,"text":"bottom persistent vector and the persistent set those are wrappers around the key value pair that give you the feeling of a vector or the feeling of a set","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=488s"},{"start_seconds":497,"text":"and and the you know the related kind of behaviors let's talk about testing because we're going to be doing that this week with assembly script and rust what are","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=497s"},{"start_seconds":506,"text":"you doing you're writing your contract in assembly script using near sdks or you're writing your contract in rust","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=506s"},{"start_seconds":515,"text":"using near sdk rs and then to write tests unit tests against the contract you have two different technologies for","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=515s"},{"start_seconds":523,"text":"assembly script you use something called aspect and for rust you use something that's baked into the language where you use this kind of macro directive pound","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=523s"},{"start_seconds":531,"text":"you know test in between brackets and you'll see examples of this as you look at the code","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=531s"},{"start_seconds":539,"text":"you can then build your contract into a wasm file and then simulate it using simulation","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=539s"},{"start_seconds":547,"text":"testing you can do that kind of one shot simulation testing with near vm in the the near cli where you just call like a method but if","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=547s"},{"start_seconds":554,"text":"you want to orchestrate several contracts or call several methods and have cross contract calls you need to use the near sdk sim the simulator","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=554s"},{"start_seconds":562,"text":"and again you'll see that this week where you're actually simulating the behavior of the contract as if it were on chain but before you deploy it and then","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=562s"},{"start_seconds":571,"text":"finally you deploy maybe to test net or local net you'll do both of those this week where you actually deploy the contract and then you can do some integration","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=571s"},{"start_seconds":578,"text":"testing maybe with near apijs or with near cli both of those you'll see this week as well","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=578s"},{"start_seconds":586,"text":"so those are the three kinds of testing unit testing integration testing sorry simulation testing and integration testing in that order","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=586s"},{"start_seconds":594,"text":"let's talk about accounts so the account model in near we use","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=594s"},{"start_seconds":600,"text":"human readable names like alice.testnet or app.alice.testnet and as far as i know there's no limit to how many of those sub accounts you can have","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=600s"},{"start_seconds":608,"text":"we can read about it in the specification if you like and so here's an example of this you know pay with.near or payby.net or whatever","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=608s"},{"start_seconds":616,"text":"these are just some random accounts that i took from mainnet and we also had this idea of an implicit account where this is an account that doesn't cost you any storage and it's basically","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=616s"},{"start_seconds":625,"text":"been created to reserve a name in order to get that name you have to send some tokens to this implicit account so it's a little bit of extra","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=625s"},{"start_seconds":634,"text":"detail these are close to the way ethereum account names are made but again the actual account name is going","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=634s"},{"start_seconds":642,"text":"to be human readable so this is like a temporary account name this implicit account you pay for data using storage staking","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=642s"},{"start_seconds":651,"text":"so when you have some account this is a screenshot from the wallet there is some minimum amount of near balance that you have to keep","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=651s"},{"start_seconds":659,"text":"depending on how much data your account is holding so this account has 20 near cents that is holding it you know sharif.near because there's","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=659s"},{"start_seconds":667,"text":"uh something like 20 kilobytes worth of data so it's one near per 100 kilobytes 10 near per megabyte of data","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=667s"},{"start_seconds":675,"text":"this account has 20 kilobytes on it and so it's holding 20 cents and that i can't spend that i can clear out the data","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=675s"},{"start_seconds":683,"text":"the contract if there is one data on the account keys those all take up space and cost storage taking money i can clear those things out","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=683s"},{"start_seconds":692,"text":"and then that storage staking amount will be reduced if i want to removing a contract or deleting some of the data","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=692s"},{"start_seconds":700,"text":"there's an unlimited number of access keys function call and full access keys and you can see here from this account","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=700s"},{"start_seconds":707,"text":"uh there's a full access and function call two different kinds of keys that we have here this account has two of each and there's an unlimited number of these","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=707s"},{"start_seconds":715,"text":"keys this is this is the keys that you use uh when you sign a transaction to prove that you have control of the account to prove that it's you and so with full","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=715s"},{"start_seconds":724,"text":"access keys you can see that there's nothing but the public key and then the permission and nonce how many times have you used it number used once is","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=724s"},{"start_seconds":732,"text":"what non stands for for the function call key we also have a budget this allowance so you can't spend any more than that","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=732s"},{"start_seconds":739,"text":"there's a receiver id who can you call with this so this function call access key here that the yellow","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=739s"},{"start_seconds":747,"text":"arrow is pointing at uh has a receiver idea of banana swap and that means uh i have if i have the private key to this","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=747s"},{"start_seconds":755,"text":"i can spend my money up to 25 cents that's what that is calling functions on bananaswap.near if i give you the private key you can","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=755s"},{"start_seconds":763,"text":"spend 25 cents of my money calling functions on banana swap in here as well so that's how these function call access","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=763s"},{"start_seconds":771,"text":"keys work with the allowance there's some limit the receiver id and then method names if it's an empty array then there's no constraint otherwise you","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=771s"},{"start_seconds":779,"text":"put in the names of the functions that can be called by this function call access and so if we think about what can you do with near actually you can work with","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=779s"},{"start_seconds":787,"text":"identity money and code the function call access key lets you use this one action function call action while the","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=787s"},{"start_seconds":795,"text":"full access key lets you do everything create account delete account add key delete key transfer","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=795s"},{"start_seconds":802,"text":"stake deploy contract and function call so again function call access key lets you do this full access key lets you do all of","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=802s"},{"start_seconds":810,"text":"that that's the difference and um contracts live on one and only","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=810s"},{"start_seconds":818,"text":"one shard they actually call each other using cross-contract calls here's a little bit of code that we'll look at this week in an application that we've built for you","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=818s"},{"start_seconds":825,"text":"and you can see here there's a method called payout and in this method i have this contract promise batch","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=825s"},{"start_seconds":833,"text":"that transfers money to a winner and then promise.then","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=833s"},{"start_seconds":841,"text":"calls itself back to say the payout is complete so transfer some money and then let me know that the payout's complete","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=841s"},{"start_seconds":850,"text":"that's cross-contract calls and that's effectively how near scales across shards every account is assumed to live on its own shard","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=850s"},{"start_seconds":858,"text":"even one account if it makes a call to itself will go through the same machinery that it would as if it was calling some other account somewhere else","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=858s"},{"start_seconds":867,"text":"across charts and that's how you get the scalability let's talk about languages briefly assembly script and rust contracts","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=867s"},{"start_seconds":875,"text":"pros here for assembly script it's easier for prototyping and trivial for you to learn if you're familiar with javascript or typescript the binaries are smaller","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=875s"},{"start_seconds":883,"text":"actually and they're easier to read in webassembly as text format so that might be a really interesting thing for you to do let me compile this contract an assembly script a simple one","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=883s"},{"start_seconds":892,"text":"and then read the webassembly as text to see what happens in rust the pro is that you've got this mature compiler it's it's been through","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=892s"},{"start_seconds":899,"text":"the ringer it's it's the best tool chain actually in the industry to go from a programming language to web assembly uh rust to wasm is is the","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=899s"},{"start_seconds":908,"text":"most mature pipeline for that um and and that's um that's not surprising because of mozilla's commitment to this technology","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=908s"},{"start_seconds":916,"text":"and so um there is a thriving ecosystem there's lots of real world use cases and of course near sdk rs just like near sdk as makes life easy for you","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=916s"},{"start_seconds":924,"text":"there are some cons here though on assembly script the compiler is a little bit immature the ecosystem is a little immature debugging tools are a little bit","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=924s"},{"start_seconds":932,"text":"immature on rust it's a very steep learning curve might take you weeks or months to to get to the point with being","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=932s"},{"start_seconds":941,"text":"literate writing a rust contract from a blank page and even experts you can see sometimes they'll fight with the compiler kind of","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=941s"},{"start_seconds":949,"text":"struggling to get the right syntax because the compiler doesn't like something something about how some variable is declared or who has","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=949s"},{"start_seconds":955,"text":"ownership of it or who borrowed it last and so that can be a little bit of a challenge with rust if you already know russ good for you but if you if you don't know it yet","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=955s"},{"start_seconds":963,"text":"i would recommend against trying to learn it this week focus on assembly script much easier to learn and the concepts are the same you're still learning about near","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=963s"},{"start_seconds":971,"text":"you're not giving anything up so here's what they look like contract data on the left and right assembly script and rust","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=971s"},{"start_seconds":980,"text":"you can see this idea of a posted message in assembly script it's a class in rust it's destruct and again this is recorded and you have","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=980s"},{"start_seconds":989,"text":"access to the slides so if you feel like you're missing some of this or if it's going too quickly for you remember you can always come back to it here is contract behavior","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=989s"},{"start_seconds":997,"text":"assembly script and rust couple of methods in both export function add message export function get messages","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=997s"},{"start_seconds":1005,"text":"in assembly script and in rust here public function add message and public function get messages","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=1005s"},{"start_seconds":1012,"text":"we also need destruct and rust because of the type system no matter what though the output is","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=1012s"},{"start_seconds":1020,"text":"always a wasm file and this is what it looks like actually this web assembly is text you can see there get message add message this is from the assembly","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=1020s"},{"start_seconds":1029,"text":"script compilation because the rust one is a little bit harder to read and you can see here the add message method if you compare this code to the","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=1029s"},{"start_seconds":1038,"text":"assembly script code you'll recognize exactly what's happening as we push and and put pull things push","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=1038s"},{"start_seconds":1045,"text":"and pop things off of the stack","url":"https://www.youtube.com/watch?v=xWR2nlw0R_M&t=1045s"}],"youtube_url":"https://youtube.com/watch?v=xWR2nlw0R_M","url":"https://near-pedia.xyz/videos/xWR2nlw0R_M"}