{"id":"971dTz6nM2g","title":"Cross-contract calls in Rust","description":"We dive into cross-contract calls, the asynchronous nature of NEAR, and how receipts behave in the process. This video is especially great for folks wanting to hear about the details behind the magic.\n\nFollow the latest from NEAR Protocol on, \n\nWebsite: https://near.org/\nDiscord: https://near.ai/discord\nMedium: https://near.ai/medium\nTwitter: https://near.ai/twitter\nGitHub: https://near.ai/github\n\n#WhiteboardSeries #Blockchain #FutureIsNEAR","channel_name":"NEAR Protocol","published_at":"2020-12-03T00:00:00.000Z","thumbnail_url":"https://img.youtube.com/vi/971dTz6nM2g/hqdefault.jpg","transcript_text":"do we do like an intro yes um but I'm waiting this the first one that I've been on so who are we waiting for you were you were there before hey uh this Eugene and another episode of weekly contract live review and today going to do slightly different format instead of reviewing an existing contract uh I will try to explain some logic behind promises and that rises a lot of questions how they work and why and for this you'll code a little bit of life so uh today we have a new guest and the new regular met Locker do you want to introduce yourself did everybody introduce themselves before okay hi guys I'm back I'm working on like wallet uh I was working on multisig for a while um I'm transitioning a little bit to devil so I'll be working with Partners um I'm aspiring to be as good as Eugene is with writing uh rough smart contracts and working with Partners so right I'm here to learn let's let's go okay awesome uh let let me present um I haven't done this before in terms of uh I haven't used terminal as much in C line so if something goes wrong it going to be fun so this is near SDK RS and I will use a bunch of stuff to um to demonstrate how promises works we have contract cross contract high level and cross contract low level they both very complicated and have too much logic in them and uses unit test so today instead we are not going to use unit test and we'll do this live on the test net so for this I'll expert my environment to be test net so I don't mess on a minut um so the best way to start with contracts is I usually just copy something from one of them to another uh for this I probably need to I'll use status method message and I'll do carg clean first to delete Target out of this and then I'll just copy status message into not a MB but promise a so I created a new example I will modify some stuff there so examples in near SDK import near SDK directly instead of um instead of import them from crate because it's local um next thing I'll modify Target or build Target uh to to copy a proper file so this is done in a terminal I can now compile it oh gosh um all right let's just install it so recently the updated near DK does not support components um that's a bummer let's just remove this it's probably going to break anything for me um so if it works it should compile we are not going to use simulation test today that's why this uh rustal chain is not really needed but the rustal chain required for uh pull in one of the dependencies for uh simulation testing from near core so there's a branch that uses a table endpoint instead of nightly and it needs to be slightly later because it has uh features that are not available in the old stable version okay so let's while it compiles let's look at the code file is not included right so I'll do add file C bun examples promising that work Domo oh that's confusing we can't see whatever you're doing when you try to fix that message so you cannot see this window the file selection window no the overlays don't render yeah oh no well it doesn't matter it's even better than you don't see my local dis but you can see the car okay it's here here carg tab can you see a terminal yeah the terminal's coming through okay cool all right so so it does compile first thing we kill metadata and we also kill unit test so I will remove the terminal for now so it's fairly standard method that does a bunch of stuff you don't really need any of this um it uses default which is fine for our use case because we are not we do not need any anything at all about our structures that can be fully empty all we wanted to do is to create a method something like call B new s that will uh issue aod call to be and we also going to use a new fancy macro that's not live yet called log and what you can do you can log calling B let's call account a from a and we'll pass account with r and our account I all right let's see if it compiles I need to remove some stuff collection and use Imports save terminal rebuild okay compile it um so I build a binary called Promise a that um has a one method called B that all it does it just logs data using a new fancy macra which works like n vog so next thing I'm going to D deploy it on test net and so it's done I have this account ID Let's uh put it here PR account maybe so now we can call it and we can actually export Okay so when I type the keyboard should be pretty loud it's fine the volume of your keyboard is time okay so we're going to call it and just say we're going to call D for now we don't care or maybe BB because the links has to be at least uh two characters and we need to pass an account ID and I have a local account called place. MEA that I will used for testing okay so we see a log message that's uh that's good so we called this temporary contract at Dev blah blah blah and it's saying colon B at BB and a at this so it works this is good so next thing we're going to do we're going to create actual promise and today we're going to probably use a middle level API so we're not going to use f micro yet to be more explicit we're going to do count um function call explain the into rest thing briefly turn it into uh it's same thing as doing account ID account ID you basically testing one type into another uh this one expects a string or count ID and the so it's passed in as a valid account ID which is a different type and you're just turning it into an account ID is that they're both strings right so valid account ID is um is just a WRA around around account ID but when it does serialization it also um validates that the account is valid and is valid is using is account so basically when you call this method and you pass invalid account ID it will fail at distalization of the arguments but it's not an account ID so like unwraps it basically at distalization but this one is just casting it so what we need to do is change this API to accept valid account ID or kind of a value that is um I think it called something like convertiable into something I I don't remember the type name in Rust but there is a you can pass not only account IDs that accept it but anything that is convertible into the account ID type and that's way you can pass this directly so function call takes uh four arguments method name Vector arguments Vector amount and gas and then it just adds an action which is not public for some reason gu we don't like developers as much so method that we're going to call is let's call call C or maybe just log some then arguments uh we don't really need the arguments so I'm using the b in front of the string which makes it u8 type so then I can just do two back and it will cast it into vate then I need to pass amount how much deposit I want to do I like to do a more explicit which is no deposit and then I can pass a basic gas so let's defy this two basic gu we need about um for promises let's attach um for now just five guess is enough for no prise so what I'm doing I press Alt Enter on cine and say do you want to what do you want to do with this type I want to say I want to import that's added to dependencies or Imports okay so we are done so if I recile whatever you did there to automatically import those is that that's part of is this BS code this is a cine do you this this popup no oh gosh that's interesting so it doesn't display you context if I click right click do you see this no oh gosh okay fine um so basically when you click Alt Enter it pop ups a small context that has the red import option you click click it like not red but import you click it and it automatically adds it into the iners so you were seeing an error message that said something like balance is not defined and then uh balance is not it's available from this Library do you want to so I I removed it from Imports and now balance is red so it's saying I don't know what is balance but but I know it's available from uh one of the option so if I use like balance three now it's like I have no clue what you're trying to do so it's white it me it's like well it looks like a type that I just don't know but if it's became red it means like hey I know what it is you just didn't import it do you want to import it so you press uh like this you have this kind of light bulb red we see the light bulb with the outline so when you click that it says like hey you want it says import I click enter and it Imports it here great thanks for walking through that I never knew C Lions could be that intelligent well I also use T 9 so if I start taping mat uh it you probably cannot see my auto completes e do you see you obviously haven't been uh creating enough variables with my name hey um quick quick question about these consts that you defined um right this is just you know my own personal curiosity does I I see a lot of these in in every rust contract uh some of them are are really similar does it make sense uh to make them as part of the the SDK so that we can just import them or is that like a little bit too just too much like over the top so so we have a goal for like we wanted to improve his DEC and make um balance type and gas type explicit so they're not just u64 and like U 12 128 so right now it's just a U1 128 and for example you can add promise index to guas and for us it's going to be okay the problem is uh you can easily mess up AR positional arguments here so I can potentially try to do this it complaints because like okay this is different type but if I'll just uh put a promise index there and then it will be a problem so what we want to do we want to have explicit balance and gas type and then within it potentially it makes sense to introduce constants so so you can maybe say gas um I'm like base cost B cost but for this we'll need to do some work plus the Fe is going to change um and this cost may go down or go up depending on the well ideally down now deposit is really just a bad API like majority of time you don't need a deposit so it's um this thing can be worked essentially but it makes sense to add some constants later so anyway we compile this in um let's see slightly more like 10 10 kilobytes more for for including the promise so what I'm going to do I'm going to redeploy it on the same same name uh account we don't have a state so it's not a problem then I'm going to call it again okay so we still have this log and then we found a new receipt uh that went to account BB and said like okay I don't know there's no code on account BB so the result of this prom is failed uh but my transaction succeeded so let me actually return some data and I can say I want to okay a well I need to recompile and redeploy so even so the remote promise failed I still return okay a because I do not depend on the type of This Promise so like I don't care what's the execution around this promise happened and effectively um the transaction returned me a result before this uh promise execu it so transaction return me okay a before this receipt even started to to execute on B before flying because this value does not depend on the execution of This Promise so it's as synchronously started and forked out from my current value return so a question I have on that is it like that makes sense me that it would return the string before the promise returns uh what's happening in near CLI that it's actually waiting to show you the result of that promise yes before it logs the result of the first thing is that where is that happening I guess like um maybe that's near CLI holding up and not RPC yes so this is near s light that's saying you got to re I'm going to wait for both of these receipts to complete before I will return your result and um so the initial RPC call happens um and so if I can do this and just say I want to so here's my transaction ID and account ID is um what is so let's see what happens this the results so this is a low-level RPC end point actually can you scroll up a little bit more I have a question before we even get there so the transaction ID is the 99 zuu on the explorer link uh oh transaction ID 9zu what are the receipt IDs there are three different receipt IDs and how do they interact with or more so there's four or more it just doesn't display the initial receipt ID so this one is um execution from some unknown receipt that's not displayed here but it will be visible here so wait here's a transaction and here's the outcome it's saying outcome receipt ID this 2 y1x it's not part of any receipt here but this is a receipt that's actually executed on account where the contract is deployed so near sell I just didn't display it where the contract is deployed meaning this contract not the one where we're calling log sum yeah it it is oh yes yes this this contract so so this contract actually locked this information so this receipt contains this particular log and so let's scroll down to what else is there so this is outcome of the transaction it's saying result should depend on the result of this receipt so that's why my transaction still Waits for the result of this uh receipt so next transaction oh this is the next receipt so this is a receipt on promise a contract um here's a log so promise a receipt executed and here's the look then here is the two receipts that it displayed in your CLI one of them is calling um B and second of them is refund for guest so let me do something else before we Ty later I will make this contract payable and in addition to calling I will attach a small amount now I should have three receipts so if we go to transaction status is the new transaction then this particular call it did not oh because it succeeded right so because it succeeded it consumed my money without a refund but if I would fail then it will generate two receips anyway let's go back to the original um um okay so the original TX status was a log and two receipts first receipt is calling B second is a gas refund but at the same time status is Success value it means the transaction has ended and that's it so there is no more um no more receipts oh no it actually it does have receipts so I guess TX status expands all receipts that are already executed but if one of the receipt would be missing maybe it will not wait for this but what's important is at this point no matter what this receipts do the transaction is over and we have a final result okay so these receipts are basically saying like hey these things are going to happen next block but the initial RPC call returns immediately um and and it so the fact that it has these two receipts it knows that things are going to happen in the next block basically right like I'm I'm imagining that it doesn't make sense for the RPC to like sit there for the uh interaction with the chain right like we want to make sure that when RPC requests come in they get served as quick as possible so that the process serving them is freed up to like handle other RPC requests right so you don't want the process to sit there hanging so it's going to sit there for the minimum amount of time possible let's do something that's you probably don't want to do and we will call ourself and pass all the remaining gas except we will keep 10 10 CH gas for this stuff so what going to do what we it will immediately return okay a and then spawn the receipt this receipt will do a bunch of actions but I don't care about them because I already return okay a um for this I need to pass my own ID so I can call my own contract and I probably didn't need money so it's going to fail because the metod doesn't take money uh right uh so the second call failed because I didn't pass the argument properly so I need to pass account ID and we can do this the following way we can do sered Jason to Jason so can I guess you're you're going to recursively call yourself right until you run yeah yeah so this is what I'm doing I'm going to recursively call uh and then you turn the right white and instead of calling myself I'll call account ID so I need to clone this here uh okay let's recompile Json I need to import Jason not Jason um I guess there is some problem because I don't see where do we have Jason maybe it's behind Jason Jason okay how this works oh right I need to know pass it as a reference finally expected type maybe Chason um all right that's too too much too much struggle yeah that's just hard coding uh Eugene just just for reference the the Json macro was expecting brackets like like I think it needed the the Json struck to actually be in in round brackets like a function call that's what the documentation said so it might have been just complaining because it was like the macro was parsing yeah okay so uh I to wrap this maybe this okay seems good enough all right it compiled let's deploy it and what we would like to know if if I execute this then should I wait for the full execution and this is probably what happens here with the blocking API or um for the partial execution so at some point I'm out of gas and it failed but before this it basically generated a bunch of recursive calls and apparently decided to wait for all of them even so it doesn't need to wait for all of them but it's near CLI is waiting not RPC the RPC returns immediately and then near CLI is gonna like sit there and check on the status of the subsequent transaction Bea subsequent RPC calls it's possible that this is uh done by by near s to to complete all the receipts before returning the value it just seems like we are if RPC is blocking in that way and waiting for these long recursive calls to wrap up it seems like the servers handling RPC calls could get congested really quickly right I think RPC returns immediately whatever action it has so it's likely C depend depending it through and this is part of newer APS that does uh fetch an entire transaction until fully complete at the same time you should be able to add a flag that like don't wait this will make every transaction like twice faster because um right now you're waiting for three blocks uh the first one is going from Place meta account to this uh Dev account second is actually executing the account contract um and third you will wait for receip of the refund for the guest if you have a option to say um finish early so don't care kind of about execution and don't wait for finality then you should be able to speed up most of the calls by like one and a half x on a front end this this waited for the entire string though this weighted way more than three right like this this me the wait for all like six blocks or eight block right so if you have something like this it's you're probably not going to write because uh you most likely don't want to ignore your subsequent calls and instead you want to depend on them and this is how you actually depend on them uh you you can do if amount of gas is less than three then we going to return you something new so real okay before we do this so let's just PR it out and okay so so what I changed I changed my return value to be a promise um so what happens is now instead of returning a value immediate L I return a promise index um I probably also don't want to do recursive right now and just want to demonstrate something simple so let's just do actual contract d or we can call ourself and look okay oh maybe like turn okay so we your method return okay that will'll say okay so this is not needed instead we can again just don't need arguments and amount of gas I need is just um this okay so let's also add okay called by so what we saying is we're returning okay and we will called by or our account so we first redeploy promise a and we also going to deploy to the new account so we can have two different accounts so this going to be my account prb oops okay so now I have two different contracts well actually two different accounts with the same contract one of them is PR a and one of them is prb so same no no no fa uh Co PR a prb so this p a prb they have a different stuff oh right okay so now I'm going to call account prb all right so this is what I got I got log colon B I got log returning a k this is from b and a called me maybe I can and you can somehow it used the this number as a count Ed did supposed to generate it but in theory this is generated it so let's modify it it's fine so this is the current account ID for the contract a and it's saying calling contract B at this and now it's saying I'm what's a mixed position this one called me and this one um is who I am yeah yeah so I am let's modify call in b I am called by this calling this so we're going to modify it I am current account ID called by ressor and uh calling this account let just copy this P here return okay all right so we need to rebuild we can okay see um we can uh redeploy and we need to redeploy the new account again so let's use this one as promise see okay probably just call it promise B you don't need to keep two of them around well let's call it then promise a because I I lost my access to promise oh the the access to contct a because I can't redeploy it anymore all right so all right so it's saying I am this called by Place meta and I'm going to call this contract now I contract this I called by this contract and I'm returning okay and as you can see the result of the transaction is okay I feel like this is a great way to log things I like this yeah so this happened we return okay because um because we depended the first method depended on promise so it return This Promise instead of returning nothing so if I would return nothing instead of This Promise like I will return essentially white and I will again build and redeploy so now I changed promise a I didn't change contract B but I don't need to so if I do this um I got no value so my transaction resulted in no value even so this still returned okay and this is the difference between returning a promise and not returning a promise so what you're showing us here is that basically if you don't return the promise then uh essentially the promise will be fired async and then that that transaction that gets called from Le let's just use the the sort of the nomenclature like contract a called contract b as a promise but contract a is not waiting to return that promise contract B will just fire on its own and it will sort of just kind it'll it'll execute but we won't have a way to sort of look at that unless we're going back and we're reading TX status and we're looking at at Contract B right like like actually going through the receipts but if we want to look at the actual outcome like through the promis chain we have to make sure that uh like all the way back to CLI we have to make sure that contract a Returns the promise and then that way it's sort of going to it's going to do the cross contract call and then wait and then return and then come back in in one sort of TX status it's kind of like you're blocking with a weight a not blocking with a weight in javascri so so this is essentially created a new problems with traditional JavaScript API before creating a sync function now if you await on the result of This Promise then you will get it from this call but if you don't await then it just fires up and you immediately return we can try to demonstrate it uh through arrays because they actually execute in parallel in like in blocks I guess um before we do that um I want to point out you could also use the result of This Promise later on in that right like it doesn't have to be returning the promise immediately we could also like assign this to a variable um and then B for example and then you can return it like this but you could also wait for it to be evaluated and do something else with it within the body of this call B function um no you cannot do anything with this so it's not really spound so you can do some stuff here you can like uh look like it's gone right it can say it's gone I think I think I guess what Chad's asking is like for example could and you know correct me if this is different Chad could contract a return for example a Boolean but but still block on that promise call to contract B and could we look at Contract B and say oh you know it's greater than 10 so return true somewhat but not really like for this we'll need to look into the callbo now and explain how callbox Works sounds like sounds like sounds like NE next week huh yeah we are we can finish a callback and uh then more complicated we can do next week so you can create a callback again this the same kind level API on yourself and say um I'm going to call on data and this is a call back so now question which uh method you return so it's not a call back yet it's just another promise to to my own method I'll create a data and um and log on data so so I guess the rule of thumb here is that in order to in order to to to block and wait for cross contract calls you have to return a promise from the original method that you're calling and that but that promise could be could be kind of constructed in such a way that you're going to do another cross contract call to another account uh basically evaluate what what that returns and then and then return that within a promise to yourself yes and no but so no look at this so what we got we we basically issued two promises okay and on data so one of them go went to the promise to contract B one of them stayed an our contract but called as synchronously as well but we returned a value of Promise B so this one went just parallel to so that's why we got our call then we got on data and return in okay uh the order of this to is variable like I would imagine the order I don't see a receipt I don't see a receipt for this so like I don't know where this 5S it's probably messed up ever since here they've all been like that the second receipt like on the they've they've never been they've never matched any of the other receipts yeah I don't I I don't like the three receipts in the top have not matched or the usually it's been like two receipts at the top but they have not had um they have not matched the second receipt maybe it's just like receipts that were not displayed on top but uh yeah not sure why Weplay these ones so this is probably refunds this like refunds but it would be helpful for every log to be attributed to some receipt or like original receipt anyway yeah I'm not yeah that's so call back I guess I guess sorry go ahead no maybe you wanted to before Oh no I just I guess my like my biggest my biggest sort of question here would be um would be can we can we do a cross contract call and and evaluate evaluate the response and return like return a c like a custom response like it seems as though we we always must return the promise um and I get that that's might that might be the way it is right now but could what I can do now I can say promise B then call back a and that's going to be actual call back what I did I linked yeah uh this is because this type of um API is not is not a low level it's actually high level methods so let's see if this works should we return actual callback in sort of Promise uh no but it did consume it uh maybe what we need to do is like actually switch to low level API to make it like more obvious promise promise badge create and it takes um account Ed borrowed account Ed so I'll just return now prom is B look at me and just at the edge of our seat I'm I'm trying to follow along man it's exciting so what it does it takes index first which is promis B index then doesn't need to v l level should can work without taking the types so so it doesn't return anything so what I did is I created a promise similar to high level API but it's actual host function call it give me an ID promise ID instead of a promise type then I attached one action which is a functional to This Promise so before we do call back can leave like this for now and then we will do we cannot return a promise anymore because it doesn't expect it because of high level API instead what I can do is I can do promise return and let's see if it works you got rid of the return annotation though shouldn't you add that back oh you're not returning it I see right I cannot return it anymore uh let's see if it works you're you're going to return void but you're still going to force the weight right like well let's see like maybe nearest DK doesn't let me do this but maybe it does um it may handle it so yeah it seems like it works so I did return okay but then it means it works so this actually doesn't return anything from here but instead it like uses some cost method to say instead of returning value I'm actually returning the promise here's my promise and I find it very unexpected that the okay is returned in that near CLI call like so much so that I'm wondering if you remember to deploy a good question yeah I don't know why we would say okay right yeah we should just get all the receipts but but nothing gets returned am I misunderstanding why why we have okay we we might be misunderstanding so promise return actually calls the calls the near runtime method that takes the index and passes it so a function can end in four different actions so it either returns a promise or returns a value so somewhere here is a oh I think it returns B uh because b b is going to call uh on data right and then does on data return something on data is just a parallel call right now right why why does it return string okay though because I did promise return so this is actual host method on the runtime so the way wasm works it has like very uh complicated logic and it usually doesn't return any type from it function at least for us it always void and then nearest DEC at the end of your function execution decides what type to return oh oh so okay okay is not something we typed it's literally like okay like rust okay no no no it is okay it is here it is here uh okay okay yeah yeah okay now I understand a lot of okays going on I'm yeah I I'm actually still I find this syntax surprising it seems no return value on here I would not expect the like actual thing the output on the CLI to say okay that's that seems like some workaround we added in near fdk where like technically it was allowed because wasm but right it it violates my expectations about how rest code works so what I did I added early return to this type so I changed type from void to string so now it's a decision of near SDK how to handle it because uh yeah so it returned because when I did this it overrided my return value so I I did this return but I did it before saying well I changed my mind I don't want to return a promise anymore I want to return a value it works if you get rid of the semicolon on N promise return wait for this is the best part was like value return so similar to promise return you have a method value return so I will get rid of explicit return at ENT and do this um so right now because this is a second call it will override the value return but if I flip them uh it will return the value I don't like it Eugene I don't like it I Chad I think it's uh it's a is an artifact of the fact that Eugene is basically like hijacking like the transaction runtime and and like outputting stuff so it's like you're just basically explicitly returning right yeah so it's not intuitive all right let's ignore it for now and I'm not going to override it and let's assume this is actually returns a promise index as part of the function the and um I Eugene another way to rephrase this ref rephrase like me and Chad's sort of like desire for some sort of like ergonomic asyn a weight thing would would be a question like can we in this method can we await uh one of these promises from the near SDK or are they not real like rust promes no they're not like you cannot await because to await it you basically need to save your context into some temporary memory and then um and then block the execution until some promise is completed and then when it gives you a call back you recover it from some temporary memory or like persistent State and put it into memory and continue execution so you just haven't done the like the logic to do this so it makes sense to me that we wouldn't support that I I wonder so I guess show us the kind of the punchline then of like okay if you want to say like start do some stuff call this other function and then once that data once that function returns some data like deal with the data that's the call thing show us that reimplemented callback is a lowlevel API uh again I just need to do this so so the behavior shouldn't change let's just confirm it um but it's still issues so now it's very clear it's just another promise call that is uh called call a locally but I want return promise b um so what I can do now I change this API from promise badge create to a different method called Promise badge then it takes a promise index which is going to be promise B and my current account ID so what I do this this action I'm linking promise B to a new callback I'm saying this call back now depends it should only be executed once promise B returns a value I'm still going to return promise B effectively I'm creating a fort for this thing because I depend only on value from B but this thing depends on value from b as well but I don't return the result and I should still get okay because I returned the value from B but the difference now one data is called after the thing because it was executed in a block number three instead of parallel to block of uh B so this is what uh mat you were asking somewhat whether you can handle a logic but at the same time return a value so promise P or this call back on data actually receive the value from b as well so we have this magical argument called value of B okay so what this callback does it's saying when I receive a data from my dependency the first dependency put it in here so I put okay so now okay is going to be returned here and into a call box it will Fork a value and as you can see it get okay from this result what I also can do is now I can return the value from here and say like for example uh on data value of B can return that from the initial thing yes promise to return call back I want to just demonstrate that this thing doesn't really change anything at least on our side because no one depends on the value of on data because it was forked from original result so even so this thing returned the value uh it only recorded in like execution outcome of this so if we get now near TX status count take the uh Place me we should see it somewhere I think here it is so this thing should be yeah so did return it into the into the chain it just near CLI didn't use it and finally now instead of depending on this we can uh return call back a and if we do this then this is actually how the traditional callback Works where your where your value actually depends on the your call back so you get this on data okay well this was a long call I'm feeling um this was a great demo of the kinds of things that I can do with promises I still have a lot of questions about what exactly is happening at the RPC level if that's blocking and hanging on like the whatever test net Noe is serving the RPC request or if like near CI is quering RPC multiple times while it waits right like none of that has been cleared up in my head um and and the receipts feel like something I need to go dig through TX status like I need to walk through this myself and dig through TX status every single time and like start building up my mental model of what the f is happening with receipts um that but yeah that's that's where I feel like I'm at I'm like aware of what's possible but the exact behavior of receipts and what's happening in each block and what RPC is doing it's all still very very fuzzy for me so I guess that's what that's what I'm taking as my own next steps is to like dig in a little bit more in know um yeah and kind of like follow through on my own how are other people also I think I'm I think I'm like I'm roughly okay right now um the I I would just say the the lowlevel API like you know it's it's it's way less reminiscent of sort of just like a JavaScript like async await like I can await on this promise and then I can do some with that data and then I can and then I can return some final result and it it looks to me more like um it actually looks like uh I I used to do a lot of like openg programming back in the day and it looks like a graphics pipeline like it's like something you would like like I want to do like you know this this this and then I want to like pipe it all to the GPU and like let it sort it out and then it's G to return back from all those calls like it's something like how you have to kind of the low-level stuff like the promise batch stuff it seems like you have to you have to almost like slot everything in and then decide you know what which one of these am I GNA wait for at the end um yeah but it's it's uh I think it would be okay like once you get used to it um one one example that I would like to see actually and I I don't think we got to it but I think Eugene you were saying something about it was arrays um so for example like doing a c doing like three cross contract calls uh like so basically come to one contract uh method do three contract calls async wait for all of them to come back do something with all of their data and then return a final promise that would be very interesting so it's like kind of like goes from one block and then in the next block there's like three calls that are all happening hope hopefully within the next block and then in the final block you're bringing together all of the Val the return values from those three uh promises that that executed Asing that would be very interesting I think you have an example of that called it's like a merge sort in a contract right so so I want I want to just demonstrate quickly what happens so let's say we introduce a promise c um which going to be same as promise B except uh in parallel so what API allows you to do is kind of create a join promise which is you um join uh two promises or more together so you join for example promise B and promise C and then you have a call back on the join promise so now this thing going to return receive two values um and two call back values and we can just just while you're typing that Eugene I just wanted to say a great parallel for this uh sort of type of syntax is um goang and uh the weight groups um there like with with go sub routines and weight groups that's actually really really similar to this because you call like a wait group and then you you if you join if you call join on the group it waits until all of the sub routines like come back and then it come together it's pretty cool so so you designed it to around original JavaScript API um which is allows you to kind of you have promise so a new promise which will create actual it takes the sub rtin well not what it's called Lambda um that's not yet executed because JavaScript is a single traded but it will start executing once you exit the current Loop or like you exit the current method this is exactly what happens here the promise is not fired until you're done with your synchronous call so that's that's why when you were returning but but kind of forking out the promise you were getting like a like this is way way back at the beginning when you were returning okay but just making one call out that's why you would get the okay from the transaction but the other call was still going in the next block right but that yeah that transaction was actually returning within the first block yes this is really cool my mind is like on fire with all the possib okay um and we also have some weird stuff which is call back W uh if you expect the same type then you can outp put cobat R and I'm going to use thebug to to print it oops it works exactly as a callback but it handles them if they return the same type I think um the only the only thing that's a bit of a black box for me still is this is this callback macro and callback VC macro um yeah um assuming is that just some like is that just a very small amount of like syntax stuff from from from near SDK or is that something much it is kind of like a helper from near SDK that un rups all of this uh but what it lets us do now is like I got two calls right I can now write a loop um where I will isue let's say six calls to to be under the appropriate limit so I cannot do 10 because I only have 100 gas um promises so this is like how you would do this in JavaScript you may create an array a bunch of stuff you do and then you do promise all so this is similar to promise end and I'll just that's starting to look a little more little bit more palatable huh chat it's starting to look a little more wet palatable like it's a it's basically declare an array of promises uh you know push your promises onto the array and then promise and is sort of like a replacement for promise all and then do the call back a and then basically process all the values yeah it's pretty it's pretty verose but like I get the the general idea that that's actually something that's that's really really interesting it's yeah yeah I I feel like the POS I'm starting to get the possibilities and how I would write it the piece of the mental model I'm missing is just like what exactly is happening with receipts in RPC right like those are still the things that I want to figure out okay exceeded prepaid gu uh this happens because I did not have enough gu so let's attach B load bot load is always uh same boat load's the technical term right yes it's a technical term of Bo load of gas which indicates you attach the maximum amount so yeah we we basically scheduled six promises then I waited for all six to complete before processing it but in a perfect world Eugene like like in a in a very empty chain or if you're paying enough in gas you'd really just be calling the one method in in block a then you'd be you'd have six promises fire in Block B sorry my hands are reversed yeah it is how it worked it is essentially it only like as you can see it completes in like about four seconds right now am I am I correct in understanding like if the chain is busy if the if the the blocks or the shards or whatever if they're all busy we don't make guarantees about like when when your promises will be included we just sort of near near just says we'll do the best we can right right it well we say it will be completed um on time but let's say the chain was let's say the chain was like busy right and you couldn't get into the next block you'd have to wait until the block after right right but yeah we do only guarantee that you will eventually finish execution right wow okay well Okay cool so we got six okay um what else good amount of okays your pro this is actually what you wanted to do is um how you can do this uh you can basically use n random Sid and then you can convert it to hex what is this what is thex okay let's see if it compiles um not really the random seed uh is it's a it's it's 30 it's 32 uh 32 u u 128 I think no it's 32 u8 so it's like it's basically just 32 bytes of Randomness uh so what I'm going to do I'm going to sech the Json to string of this so I'm going to use our magical type which allows us to serialize into Bas 64 I'm going un rra it and it shouldn't do the trick um now I just need to do deploy it on B but I'll just call the same contract multiple times doesn't matter really so with the recent fix we did uh actually every promise and every like every action receives its own random SE so every transaction within one one block gets a different random SE before that they all get the same random SE for one block but now they're differ so we can build some some Mega casinos on the blockchain yeah I don't know what what uh what you're doing but it seems like some stuff is possible now yeah actually you know random randomness is uh is just so it's so beautiful it's like the B the basis for so much stuff like let's say me and Chad wanted to play you know Battleship or tic-tac-toe or something like that like it's just you can do well Tic Tac Toe no but Battleship uh if we wanted our board to be randomly assigned right um I mean you can always like force the player to pick the the setup of their boats before but like I mean just playing like Monopoly for example like I mean it's and then there's there's lots of possibilities for um for example like solo games like solitire or something um or playing like with a tamagachi like I could sell you um like a non-f fungible token like some some thing that you collect but it could actually um have like a ping method or like a feed method and when you feed it it then randomly desires something else like that you need to play with it within the next 12 hours otherwise it's going to be you know it's it's going to be unhappy you know so I mean like you could do so many of these these things that that would just create some crazy sort of gamification so I think important we have we do have Randomness the problem is like you don't have uh so you do have Randomness but what you don't have is like a you cannot hide hide the state of the game so you cannot really build a pocker on chain very easily because a pocker is like a limited knowledge game so you don't know for example what the board is or like what's the what's the cards of the other players but they need to know this so the contract cannot really tell you um unless you somehow use a VF or no notw of somehow you use um approvable Randomness so this commit and reveal and when you reveal you can see it like if you don't reveal you can see the game this way you know the cards they based on random uh but the problem you will have collisions on the board like you can randomly draw a new card but you cannot guarantee that I don't have the same card already so it will be a modification to a traditional pocker where you have like five Aces for example right so what you're saying is that if you if you uh I might use some different terminology but if you kind of like mask each player's hand with a commit reveal then there's no there's no way to globally know that somebody doesn't have like five Aces or something right yeah yes um another question just quickly uh before we sign off about our our vrf um I was in a conversation with with Bowen about it and there there was some some indication from him that a validator may be able to uh to see uh like a very very small uh amount of the vrf or is the vrf like is the vrf kind of like unknown to them until they have to validate the block like how how does that work because they could potentially um they could front run in front of a random like a random output that is beneficial to you and if they were the other party like the you know um on a transaction they could block maybe like they could they could they could right so so what happens is um they have a binary decision whether to publish a block or not so this is the only action they can do so they have some Advantage if the decision comes to their blog and if they don't publish a Blog then the next person going to publish a block so they have some Advantage if the validator plays against you and they have a option to not publish their blog and the decision comes to their um position in the list of validators but the next validator who publishes the blog will uh have it so so do they get do they get punished for choosing arbitrarily choosing not to not to publish blocks right so so if you miss too many blocks you will start losing rewards and eventually you may be kicked out of the list of validators so potentially they have some punishment but at the same time uh it's not as big comparing to like let's say you have a final price to be selected um but if you do this then you can try to upate it somehow as well but no not there's no 100% protection against this right all right okay well thanks everybody uh for watching this uh see you next time thank you","transcript_synced_at":"2026-11-04T04:21:46.990Z","segments":[{"start_seconds":12,"text":"do we do like an intro yes um but I'm waiting this the first one that I've been on so who are","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=12s"},{"start_seconds":19,"text":"we waiting for you were you were there before hey uh this Eugene and another episode of","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=19s"},{"start_seconds":28,"text":"weekly contract live review and today going to do slightly different format instead of reviewing an","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=28s"},{"start_seconds":36,"text":"existing contract uh I will try to explain some logic behind promises and that rises a","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=36s"},{"start_seconds":44,"text":"lot of questions how they work and why and for this you'll code a little bit of life","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=44s"},{"start_seconds":51,"text":"so uh today we have a new guest and the new regular met Locker do","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=51s"},{"start_seconds":58,"text":"you want to introduce yourself did everybody introduce themselves before okay hi guys I'm back I'm working","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=58s"},{"start_seconds":65,"text":"on like wallet uh I was working on multisig for a while um I'm transitioning a little bit to devil so","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=65s"},{"start_seconds":73,"text":"I'll be working with Partners um I'm aspiring to be as good as Eugene is with","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=73s"},{"start_seconds":79,"text":"writing uh rough smart contracts and working with Partners so right I'm here to learn let's let's go okay awesome uh","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=79s"},{"start_seconds":90,"text":"let let me present um I haven't done this before in terms","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=90s"},{"start_seconds":98,"text":"of uh I haven't used terminal as much in C line so if something goes wrong it","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=98s"},{"start_seconds":105,"text":"going to be fun so this is near SDK RS and I will use a bunch of","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=105s"},{"start_seconds":114,"text":"stuff to um to demonstrate how promises works we","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=114s"},{"start_seconds":121,"text":"have contract cross contract high level and cross contract low level they both very","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=121s"},{"start_seconds":130,"text":"complicated and have too much logic in them and uses unit test so today instead we are not going to use unit test and","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=130s"},{"start_seconds":138,"text":"we'll do this live on the test net so for this I'll expert my","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=138s"},{"start_seconds":146,"text":"environment to be test net so I don't mess on a minut um so the best way to start with","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=146s"},{"start_seconds":154,"text":"contracts is I usually just copy something from one of them to another uh","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=154s"},{"start_seconds":161,"text":"for this I probably need to I'll use status method message and I'll do carg","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=161s"},{"start_seconds":169,"text":"clean first to delete Target out of this and then I'll just","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=169s"},{"start_seconds":176,"text":"copy status message into not a MB but promise a so I","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=176s"},{"start_seconds":185,"text":"created a new example I will","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=185s"},{"start_seconds":194,"text":"modify some stuff there so examples in near SDK import","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=194s"},{"start_seconds":201,"text":"near SDK directly instead of um instead of import them from","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=201s"},{"start_seconds":211,"text":"crate because it's local um next thing I'll modify","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=211s"},{"start_seconds":222,"text":"Target or build Target uh","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=222s"},{"start_seconds":229,"text":"to to copy a proper file so this is done in a terminal I can now compile","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=229s"},{"start_seconds":238,"text":"it oh gosh um all right let's just install it so","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=238s"},{"start_seconds":247,"text":"recently the updated near DK does not support","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=247s"},{"start_seconds":253,"text":"components um that's a","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=253s"},{"start_seconds":260,"text":"bummer let's just remove this it's probably going to break anything for me","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=260s"},{"start_seconds":271,"text":"um so if it works it should compile we are not going to use simulation test today that's why this uh","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=271s"},{"start_seconds":279,"text":"rustal chain is not really needed but the rustal chain required","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=279s"},{"start_seconds":289,"text":"for uh pull in one of the dependencies","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=289s"},{"start_seconds":296,"text":"for uh simulation testing from near core so there's a branch that uses a","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=296s"},{"start_seconds":305,"text":"table endpoint instead of nightly and it needs to be slightly later because it has uh features that","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=305s"},{"start_seconds":313,"text":"are not available in the old stable version okay","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=313s"},{"start_seconds":322,"text":"so let's while it compiles let's look at the code","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=322s"},{"start_seconds":330,"text":"file is not included right so I'll do add file","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=330s"},{"start_seconds":339,"text":"C bun examples","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=339s"},{"start_seconds":346,"text":"promising that","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=346s"},{"start_seconds":352,"text":"work Domo","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=352s"},{"start_seconds":362,"text":"oh that's confusing we can't see whatever you're doing when you try to fix that","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=362s"},{"start_seconds":370,"text":"message so you cannot see this window the file selection window no the overlays don't render yeah oh no well it","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=370s"},{"start_seconds":379,"text":"doesn't matter it's even better than you don't see my local","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=379s"},{"start_seconds":386,"text":"dis but you can see the car okay it's here here carg tab can you see a","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=386s"},{"start_seconds":395,"text":"terminal yeah the terminal's coming through okay cool all right so so it does compile first thing we kill","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=395s"},{"start_seconds":403,"text":"metadata and we also kill unit test so I will remove the terminal for","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=403s"},{"start_seconds":410,"text":"now so it's fairly standard method that does a bunch of stuff you don't really","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=410s"},{"start_seconds":417,"text":"need any of this um it uses default which is fine for our","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=417s"},{"start_seconds":424,"text":"use case because we are not we do not need any anything at all about our structures","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=424s"},{"start_seconds":433,"text":"that can be fully empty all we wanted to do is","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=433s"},{"start_seconds":439,"text":"to create a method something like call B new","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=439s"},{"start_seconds":446,"text":"s that will uh issue aod call to be and we also going to use a new","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=446s"},{"start_seconds":454,"text":"fancy macro that's not live yet called log and what you can do you can log","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=454s"},{"start_seconds":463,"text":"calling B let's call account a","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=463s"},{"start_seconds":484,"text":"from a and we'll pass account with","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=484s"},{"start_seconds":493,"text":"r and our account","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=493s"},{"start_seconds":502,"text":"I all right let's see if it compiles I need to remove some stuff","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=502s"},{"start_seconds":512,"text":"collection and use Imports save terminal","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=512s"},{"start_seconds":517,"text":"rebuild okay compile it um so I build a binary called Promise a that um has a","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=517s"},{"start_seconds":528,"text":"one method called B that all it does it just logs data using a new fancy","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=528s"},{"start_seconds":535,"text":"macra which works like n vog so next thing I'm going to D deploy","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=535s"},{"start_seconds":546,"text":"it on test","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=546s"},{"start_seconds":555,"text":"net and so it's done I have this account ID Let's uh put it","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=555s"},{"start_seconds":566,"text":"here PR account","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=566s"},{"start_seconds":577,"text":"maybe so now we can call it and we can actually","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=577s"},{"start_seconds":588,"text":"export","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=588s"},{"start_seconds":597,"text":"Okay so when I type the keyboard should be pretty loud it's fine the volume of your","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=597s"},{"start_seconds":607,"text":"keyboard is time okay so we're going to call it and just say we're going to call D for now we","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=607s"},{"start_seconds":615,"text":"don't care or maybe BB because the links has to be at least uh two characters and we need to pass an account ID and I have","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=615s"},{"start_seconds":625,"text":"a local account called place. MEA that I will used for","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=625s"},{"start_seconds":633,"text":"testing okay so we see a log message that's uh that's good so we","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=633s"},{"start_seconds":643,"text":"called this temporary contract at Dev blah blah blah and it's saying colon B at BB and a","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=643s"},{"start_seconds":653,"text":"at this so it works this is good so","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=653s"},{"start_seconds":660,"text":"next thing we're going to do we're going to create actual promise and today we're going to","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=660s"},{"start_seconds":668,"text":"probably use a middle level API so we're not going to use f micro yet to be more","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=668s"},{"start_seconds":676,"text":"explicit we're going to do","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=676s"},{"start_seconds":684,"text":"count um function call explain the into rest thing briefly turn","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=684s"},{"start_seconds":693,"text":"it into uh it's same thing as doing account ID account","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=693s"},{"start_seconds":703,"text":"ID you basically testing one type into another uh this one expects a string or","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=703s"},{"start_seconds":712,"text":"count ID and the so it's passed in as a valid","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=712s"},{"start_seconds":722,"text":"account ID which is a different type and you're just turning it into an account ID is that they're both strings right so valid account ID is","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=722s"},{"start_seconds":731,"text":"um is just a WRA around around account ID but when it does serialization it","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=731s"},{"start_seconds":738,"text":"also um validates that the account is","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=738s"},{"start_seconds":745,"text":"valid and is valid is using is account so basically when you","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=745s"},{"start_seconds":753,"text":"call this method and you pass invalid account ID it will fail at distalization of the","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=753s"},{"start_seconds":760,"text":"arguments but it's not an account ID so like unwraps it","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=760s"},{"start_seconds":769,"text":"basically at distalization but this one is just casting it so what we need to do is change this API to accept valid account","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=769s"},{"start_seconds":778,"text":"ID or kind of a value that is","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=778s"},{"start_seconds":785,"text":"um I think it called something like convertiable into something I I","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=785s"},{"start_seconds":793,"text":"don't remember the type name in Rust but there is a you can pass not only account IDs that accept it but anything that is","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=793s"},{"start_seconds":801,"text":"convertible into the account ID type and that's way you can pass this directly","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=801s"},{"start_seconds":809,"text":"so function call takes uh four arguments method name Vector arguments Vector amount and","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=809s"},{"start_seconds":818,"text":"gas and then it just adds an action which is not public for some reason gu we don't like developers as","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=818s"},{"start_seconds":828,"text":"much so method that we're going to call is let's call call","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=828s"},{"start_seconds":835,"text":"C or maybe just log some then arguments uh we don't really need","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=835s"},{"start_seconds":842,"text":"the arguments so I'm using the b in front of the string which makes it u8 type so","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=842s"},{"start_seconds":852,"text":"then I can just do two back and it will cast it into vate then I need to pass amount how much","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=852s"},{"start_seconds":862,"text":"deposit I want to do I like to do a more explicit which is no deposit and then I","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=862s"},{"start_seconds":869,"text":"can pass a basic gas so let's defy this","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=869s"},{"start_seconds":889,"text":"two basic gu we need about um for promises let's","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=889s"},{"start_seconds":897,"text":"attach um for now just five guess is enough","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=897s"},{"start_seconds":904,"text":"for no prise so what I'm doing I press Alt Enter on cine and say do you want to what do you want to do with this type I","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=904s"},{"start_seconds":912,"text":"want to say I want to import that's added to dependencies or Imports okay so","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=912s"},{"start_seconds":918,"text":"we are done so if I recile whatever you did there to automatically import those","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=918s"},{"start_seconds":924,"text":"is that that's part of is this BS code this is a","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=924s"},{"start_seconds":931,"text":"cine do you this this popup no oh gosh that's interesting so it doesn't","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=931s"},{"start_seconds":941,"text":"display you context if I click right click do you see this no oh gosh okay","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=941s"},{"start_seconds":949,"text":"fine um so basically when you click Alt Enter it pop ups a small context that","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=949s"},{"start_seconds":956,"text":"has the red import option you click click it like not red but import you click it and it","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=956s"},{"start_seconds":964,"text":"automatically adds it into the iners so you were seeing an error message that said something like balance","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=964s"},{"start_seconds":971,"text":"is not defined and then uh balance is not it's available from this Library do you want to so I I removed it from","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=971s"},{"start_seconds":980,"text":"Imports and now balance is red so it's saying I don't know what is","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=980s"},{"start_seconds":988,"text":"balance but but I know it's available from uh one of the option so","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=988s"},{"start_seconds":997,"text":"if I use like balance three now it's like I have no clue what you're trying to","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=997s"},{"start_seconds":1003,"text":"do so it's white it me it's like well it looks like a type that I just don't know","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=1003s"},{"start_seconds":1010,"text":"but if it's became red it means like hey I know what it is you just didn't import it do you want to import it so you press","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=1010s"},{"start_seconds":1019,"text":"uh like this you have this kind of light bulb red we see the light bulb with the outline so when you","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=1019s"},{"start_seconds":1026,"text":"click that it says like hey you want it says import I click enter and it","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=1026s"},{"start_seconds":1033,"text":"Imports it here great thanks for walking through that I never knew C Lions could be that","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=1033s"},{"start_seconds":1042,"text":"intelligent well I also use T 9 so if I start taping mat uh","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=1042s"},{"start_seconds":1049,"text":"it you probably cannot see my auto completes e do you","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=1049s"},{"start_seconds":1059,"text":"see you obviously haven't been uh creating enough variables with my name hey um quick quick question about these","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=1059s"},{"start_seconds":1066,"text":"consts that you defined um right this is just you know my own personal curiosity","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=1066s"},{"start_seconds":1073,"text":"does I I see a lot of these in in every rust contract uh some of them are are really similar does it make sense uh to","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=1073s"},{"start_seconds":1083,"text":"make them as part of the the SDK so that we can just import them or is that like a little bit too just too much like over","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=1083s"},{"start_seconds":1092,"text":"the top so so we have a goal for like we wanted to improve his DEC and make","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=1092s"},{"start_seconds":1100,"text":"um balance type and gas type explicit so they're not just","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=1100s"},{"start_seconds":1107,"text":"u64 and like U 12 128 so right now it's just a U1 128 and for example you can","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=1107s"},{"start_seconds":1115,"text":"add promise index to guas and for us it's going to be okay the problem is uh you can easily","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=1115s"},{"start_seconds":1124,"text":"mess up AR positional arguments here so I can potentially try to do this it","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=1124s"},{"start_seconds":1132,"text":"complaints because like okay this is different type but if I'll just uh","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=1132s"},{"start_seconds":1139,"text":"put a promise index there and then it will be a problem so what we want to do we want to have","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=1139s"},{"start_seconds":1147,"text":"explicit balance and gas type and then within it potentially it makes sense to introduce constants so so you can maybe","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=1147s"},{"start_seconds":1156,"text":"say gas um I'm like base cost B","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=1156s"},{"start_seconds":1166,"text":"cost but for this we'll need to do some work plus the Fe is going to","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=1166s"},{"start_seconds":1172,"text":"change um and this cost may go down or go up depending on the well ideally","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=1172s"},{"start_seconds":1180,"text":"down now deposit is really just a bad API like majority of time you don't need a","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=1180s"},{"start_seconds":1189,"text":"deposit so it's","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=1189s"},{"start_seconds":1196,"text":"um this thing can be worked essentially but it makes sense to add","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=1196s"},{"start_seconds":1203,"text":"some constants later so anyway we compile this in","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=1203s"},{"start_seconds":1211,"text":"um let's see slightly more like 10 10 kilobytes more for for including the","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=1211s"},{"start_seconds":1220,"text":"promise so what I'm going to do I'm going to redeploy it on the","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=1220s"},{"start_seconds":1227,"text":"same same name uh account we don't have a state so it's","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=1227s"},{"start_seconds":1234,"text":"not a problem then I'm going to call it again","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=1234s"},{"start_seconds":1242,"text":"okay so we still have this log and then we found a new","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=1242s"},{"start_seconds":1250,"text":"receipt uh that went to account BB and said like okay I don't","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=1250s"},{"start_seconds":1257,"text":"know there's no code on account BB so the result of this prom is","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=1257s"},{"start_seconds":1270,"text":"failed uh but my transaction succeeded so let me actually return some","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=1270s"},{"start_seconds":1277,"text":"data and I can say I want to okay a","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=1277s"},{"start_seconds":1298,"text":"well I need to recompile and redeploy","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=1298s"},{"start_seconds":1318,"text":"so even so the remote promise failed I still return okay","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=1318s"},{"start_seconds":1325,"text":"a because I do not depend on the type of This Promise so like I don't care what's the execution around this promise","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=1325s"},{"start_seconds":1334,"text":"happened and effectively um the","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=1334s"},{"start_seconds":1342,"text":"transaction returned me a result before this uh promise execu","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=1342s"},{"start_seconds":1349,"text":"it so transaction return me okay a before this receipt even started to to","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=1349s"},{"start_seconds":1357,"text":"execute on B before flying because this value does not depend on","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=1357s"},{"start_seconds":1364,"text":"the execution of This Promise so it's as synchronously started and forked out from my current value","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=1364s"},{"start_seconds":1371,"text":"return so a question I have on that is it like that makes sense me that it","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=1371s"},{"start_seconds":1379,"text":"would return the string before the promise returns uh what's happening in near CLI that it's actually waiting to","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=1379s"},{"start_seconds":1386,"text":"show you the result of that promise yes before it logs the result of the first thing is that where is that happening I","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=1386s"},{"start_seconds":1395,"text":"guess like um maybe that's near CLI holding up and not","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=1395s"},{"start_seconds":1403,"text":"RPC yes so this is near s light that's saying you got to re I'm going to wait","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=1403s"},{"start_seconds":1409,"text":"for both of these receipts to complete before I will return your","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=1409s"},{"start_seconds":1417,"text":"result and um so the initial RPC call","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=1417s"},{"start_seconds":1424,"text":"happens um and so if I can do this and just say I","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=1424s"},{"start_seconds":1432,"text":"want to so here's my transaction ID and account ID is um what","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=1432s"},{"start_seconds":1440,"text":"is so let's see what happens this the results so this is a low-level RPC end","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=1440s"},{"start_seconds":1450,"text":"point actually can you scroll up a little bit more I have a question before we even get there so the transaction ID","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=1450s"},{"start_seconds":1456,"text":"is the 99 zuu on the explorer link uh oh transaction ID 9zu what are the receipt","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=1456s"},{"start_seconds":1464,"text":"IDs there are three different receipt IDs and how do they interact with or more so there's four or more it just","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=1464s"},{"start_seconds":1471,"text":"doesn't display the initial receipt ID so this one","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=1471s"},{"start_seconds":1476,"text":"is um execution from some unknown receipt that's not displayed","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=1476s"},{"start_seconds":1484,"text":"here but it will be visible here so wait here's a","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=1484s"},{"start_seconds":1492,"text":"transaction and here's the outcome it's saying outcome receipt ID this 2","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=1492s"},{"start_seconds":1501,"text":"y1x it's not part of any receipt here but this is a receipt that's actually","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=1501s"},{"start_seconds":1507,"text":"executed on account where the contract is","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=1507s"},{"start_seconds":1517,"text":"deployed so near sell I just didn't display it where the contract is deployed meaning this contract not the","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=1517s"},{"start_seconds":1525,"text":"one where we're calling log sum yeah it it is oh yes yes this this","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=1525s"},{"start_seconds":1533,"text":"contract so so this contract actually locked this information so this receipt contains","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=1533s"},{"start_seconds":1541,"text":"this particular log and so let's scroll down to what else is there so this is outcome of the","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=1541s"},{"start_seconds":1548,"text":"transaction it's saying result should depend on the result of this receipt so that's why my","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=1548s"},{"start_seconds":1556,"text":"transaction still Waits for the result of this uh receipt so next transaction oh this is the next receipt so this is a","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=1556s"},{"start_seconds":1564,"text":"receipt on promise a contract um here's a","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=1564s"},{"start_seconds":1574,"text":"log so promise a receipt executed and here's the look then here is the two","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=1574s"},{"start_seconds":1583,"text":"receipts that it displayed in your CLI one of them is","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=1583s"},{"start_seconds":1591,"text":"calling um B and second of them is refund for","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=1591s"},{"start_seconds":1604,"text":"guest so let me do something else before we Ty","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=1604s"},{"start_seconds":1610,"text":"later I will make this contract payable","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=1610s"},{"start_seconds":1620,"text":"and in addition to calling I will attach a small","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=1620s"},{"start_seconds":1642,"text":"amount now I should have three receipts","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=1642s"},{"start_seconds":1652,"text":"so if we go to transaction","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=1652s"},{"start_seconds":1662,"text":"status is the new","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=1662s"},{"start_seconds":1673,"text":"transaction then this particular call","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=1673s"},{"start_seconds":1680,"text":"it did not oh because it succeeded right so because it succeeded","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=1680s"},{"start_seconds":1687,"text":"it consumed my money without a refund but if I would fail then it will","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=1687s"},{"start_seconds":1695,"text":"generate two receips anyway let's go back to the","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=1695s"},{"start_seconds":1705,"text":"original um","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=1705s"},{"start_seconds":1722,"text":"um okay so the original TX status was a log and two receipts first receipt","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=1722s"},{"start_seconds":1731,"text":"is calling B second is a gas refund","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=1731s"},{"start_seconds":1739,"text":"but at the same time status is Success value it means the transaction has","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=1739s"},{"start_seconds":1746,"text":"ended and that's it so there is no more","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=1746s"},{"start_seconds":1762,"text":"um no more receipts oh no it actually it does have receipts so I guess TX","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=1762s"},{"start_seconds":1771,"text":"status expands all receipts that are already executed but if one of the receipt would","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=1771s"},{"start_seconds":1779,"text":"be missing maybe it will not wait for","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=1779s"},{"start_seconds":1794,"text":"this but what's important is at this point no matter what this receipts do the","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=1794s"},{"start_seconds":1801,"text":"transaction is over and we have a final result okay so these receipts are","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=1801s"},{"start_seconds":1811,"text":"basically saying like hey these things are going to happen next block but the initial RPC call returns immediately um","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=1811s"},{"start_seconds":1820,"text":"and and it so the fact that it has these two receipts it knows that things are going to happen in the next block","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=1820s"},{"start_seconds":1828,"text":"basically right like I'm I'm imagining that it doesn't make sense for the RPC to like sit there","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=1828s"},{"start_seconds":1836,"text":"for the uh interaction with the chain right like we want to make sure that when RPC requests come in they get served as quick as possible so that the","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=1836s"},{"start_seconds":1844,"text":"process serving them is freed up to like handle other RPC requests right so you don't want the process to sit there hanging so it's going to sit there for","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=1844s"},{"start_seconds":1853,"text":"the minimum amount of time possible let's do something that's you probably don't want to","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=1853s"},{"start_seconds":1861,"text":"do and we will call ourself and pass all the remaining gas","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=1861s"},{"start_seconds":1868,"text":"except we will keep 10 10 CH gas for this stuff so what going to do what","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=1868s"},{"start_seconds":1879,"text":"we it will immediately return okay a and then spawn the receipt this receipt will","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=1879s"},{"start_seconds":1886,"text":"do a bunch of actions but I don't care about them because I already return okay","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=1886s"},{"start_seconds":1898,"text":"a um for this I need to pass my own ID so I can call my own","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=1898s"},{"start_seconds":1905,"text":"contract and I probably didn't need money so it's going to fail because the metod doesn't take","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=1905s"},{"start_seconds":1916,"text":"money","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=1916s"},{"start_seconds":1932,"text":"uh right uh so the second call failed because I didn't pass the argument","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=1932s"},{"start_seconds":1939,"text":"properly so I need to pass account","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=1939s"},{"start_seconds":1944,"text":"ID and we can do this the following way we can","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=1944s"},{"start_seconds":1952,"text":"do sered Jason","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=1952s"},{"start_seconds":1960,"text":"to Jason so can I guess you're you're going","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=1960s"},{"start_seconds":1973,"text":"to recursively call yourself right until you run yeah yeah so this is what I'm doing I'm going to recursively","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=1973s"},{"start_seconds":1980,"text":"call uh and then you turn the","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=1980s"},{"start_seconds":1997,"text":"right white and instead of calling myself I'll call account ID so I need to","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=1997s"},{"start_seconds":2004,"text":"clone this here uh okay","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=2004s"},{"start_seconds":2015,"text":"let's recompile Json I need to","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=2015s"},{"start_seconds":2031,"text":"import Jason","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=2031s"},{"start_seconds":2056,"text":"not Jason","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=2056s"},{"start_seconds":2061,"text":"um I guess there is some problem because I don't see","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=2061s"},{"start_seconds":2069,"text":"where do we have Jason maybe it's behind Jason","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=2069s"},{"start_seconds":2080,"text":"Jason","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=2080s"},{"start_seconds":2094,"text":"okay how this works oh right I need to know pass it as a","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=2094s"},{"start_seconds":2101,"text":"reference","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=2101s"},{"start_seconds":2112,"text":"finally expected type maybe","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=2112s"},{"start_seconds":2121,"text":"Chason um all right that's too too much too much","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=2121s"},{"start_seconds":2128,"text":"struggle yeah that's just hard","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=2128s"},{"start_seconds":2156,"text":"coding uh Eugene just just for reference the the Json macro was expecting","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=2156s"},{"start_seconds":2163,"text":"brackets like like I think it needed the the Json struck to actually be in in round","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=2163s"},{"start_seconds":2172,"text":"brackets like a function call that's what the documentation said so it might have been just complaining because it was like the macro was","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=2172s"},{"start_seconds":2180,"text":"parsing yeah okay so uh I to wrap this maybe","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=2180s"},{"start_seconds":2191,"text":"this okay seems good enough all right it","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=2191s"},{"start_seconds":2197,"text":"compiled let's deploy it and what we would like to know if if","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=2197s"},{"start_seconds":2206,"text":"I execute this then should I wait for the full execution and this is probably what happens here with the blocking","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=2206s"},{"start_seconds":2214,"text":"API or um for the partial","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=2214s"},{"start_seconds":2225,"text":"execution so at some point I'm out of gas and it failed but before this it","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=2225s"},{"start_seconds":2232,"text":"basically generated a bunch of recursive calls and apparently decided to wait for all of them even so it doesn't need to","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=2232s"},{"start_seconds":2241,"text":"wait for all of them but it's near CLI is waiting not RPC the RPC returns immediately and then","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=2241s"},{"start_seconds":2249,"text":"near CLI is gonna like sit there and check on the status of the subsequent transaction Bea subsequent RPC","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=2249s"},{"start_seconds":2258,"text":"calls it's possible that this is uh done by by near s to to complete all the","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=2258s"},{"start_seconds":2265,"text":"receipts before returning the value it just seems like we are if RPC","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=2265s"},{"start_seconds":2275,"text":"is blocking in that way and waiting for these long recursive calls to wrap up it seems like the servers handling RPC","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=2275s"},{"start_seconds":2283,"text":"calls could get congested really quickly right I think RPC returns immediately","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=2283s"},{"start_seconds":2291,"text":"whatever action it has so it's likely C depend depending it","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=2291s"},{"start_seconds":2300,"text":"through and this is part of newer APS that does uh fetch an entire transaction until fully complete","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=2300s"},{"start_seconds":2309,"text":"at the same time you should be able to add a flag that like don't wait this will make","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=2309s"},{"start_seconds":2317,"text":"every transaction like twice faster because um right now you're waiting for","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=2317s"},{"start_seconds":2324,"text":"three blocks uh the first one is going","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=2324s"},{"start_seconds":2330,"text":"from Place meta account to this uh Dev account second is actually","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=2330s"},{"start_seconds":2339,"text":"executing the account contract um and third you will","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=2339s"},{"start_seconds":2346,"text":"wait for receip of the refund for the","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=2346s"},{"start_seconds":2353,"text":"guest if you have a option to say um finish early so don't care kind of about","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=2353s"},{"start_seconds":2361,"text":"execution and don't wait for finality then you should be able to speed up most of the","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=2361s"},{"start_seconds":2369,"text":"calls by like one and a half x on a front","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=2369s"},{"start_seconds":2377,"text":"end this this waited for the entire string though this weighted way more than three right like this this me the","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=2377s"},{"start_seconds":2384,"text":"wait for all like six blocks or eight block right so if you have something like this it's you're probably not going to write because","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=2384s"},{"start_seconds":2394,"text":"uh you most likely don't want to ignore your subsequent calls and instead you","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=2394s"},{"start_seconds":2401,"text":"want to depend on them and this is how you actually depend on them uh you you can do","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=2401s"},{"start_seconds":2409,"text":"if amount of gas is less than","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=2409s"},{"start_seconds":2417,"text":"three then we going to return you something new so real okay","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=2417s"},{"start_seconds":2428,"text":"before we do this so let's just PR it out","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=2428s"},{"start_seconds":2434,"text":"and okay so so what I changed I changed my return","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=2434s"},{"start_seconds":2445,"text":"value to be a promise um so what happens is now instead of","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=2445s"},{"start_seconds":2455,"text":"returning a value immediate L I return a promise","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=2455s"},{"start_seconds":2473,"text":"index um I probably also don't want to do recursive right now and just want to","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=2473s"},{"start_seconds":2479,"text":"demonstrate something simple so let's just do actual contract d","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=2479s"},{"start_seconds":2489,"text":"or we can call ourself and look","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=2489s"},{"start_seconds":2498,"text":"okay oh maybe like turn okay so we your method return","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=2498s"},{"start_seconds":2511,"text":"okay that will'll say okay","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=2511s"},{"start_seconds":2520,"text":"so this is not needed instead we can again just don't need","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=2520s"},{"start_seconds":2529,"text":"arguments and amount of gas I need is just um","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=2529s"},{"start_seconds":2544,"text":"this okay so let's also","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=2544s"},{"start_seconds":2556,"text":"add okay called","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=2556s"},{"start_seconds":2565,"text":"by so what we saying is we're returning okay and we will","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=2565s"},{"start_seconds":2573,"text":"called by or our","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=2573s"},{"start_seconds":2586,"text":"account so we first redeploy promise a and we also going to deploy to the new","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=2586s"},{"start_seconds":2595,"text":"account so we can have two different accounts so this going to be my","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=2595s"},{"start_seconds":2603,"text":"account prb oops okay so now I have two different","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=2603s"},{"start_seconds":2610,"text":"contracts well actually two different accounts with the same contract one of them is PR a and one of","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=2610s"},{"start_seconds":2618,"text":"them is prb so","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=2618s"},{"start_seconds":2624,"text":"same no no no fa uh Co PR a","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=2624s"},{"start_seconds":2633,"text":"prb so this p a prb","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=2633s"},{"start_seconds":2639,"text":"they have a different stuff oh right","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=2639s"},{"start_seconds":2646,"text":"okay so now I'm going to call account","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=2646s"},{"start_seconds":2655,"text":"prb all right so this is what I got I got","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=2655s"},{"start_seconds":2662,"text":"log colon B I got log returning a k this is from","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=2662s"},{"start_seconds":2672,"text":"b and a called me maybe I can and you can","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=2672s"},{"start_seconds":2682,"text":"somehow it used the this number as a count Ed did supposed to generate it but in theory this is generated it so let's","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=2682s"},{"start_seconds":2690,"text":"modify it it's fine so this is the current account ID for the contract","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=2690s"},{"start_seconds":2698,"text":"a and it's saying calling contract B at this and now it's saying I'm what's a","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=2698s"},{"start_seconds":2706,"text":"mixed position this one called me and this one","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=2706s"},{"start_seconds":2715,"text":"um is who I am yeah yeah so I am let's","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=2715s"},{"start_seconds":2725,"text":"modify call in b I am called","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=2725s"},{"start_seconds":2732,"text":"by this calling this so we're going to modify it","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=2732s"},{"start_seconds":2740,"text":"I am current account ID called by","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=2740s"},{"start_seconds":2750,"text":"ressor and uh calling this account let just copy this","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=2750s"},{"start_seconds":2758,"text":"P here return","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=2758s"},{"start_seconds":2767,"text":"okay all right so we need to rebuild we","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=2767s"},{"start_seconds":2777,"text":"can okay see um we can","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=2777s"},{"start_seconds":2784,"text":"uh redeploy and we need to redeploy the new account","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=2784s"},{"start_seconds":2796,"text":"again so let's use this one as promise","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=2796s"},{"start_seconds":2809,"text":"see okay probably just call it promise B you don't need to keep two of them around","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=2809s"},{"start_seconds":2819,"text":"well let's call it then promise a because I I lost my access to promise","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=2819s"},{"start_seconds":2827,"text":"oh the the access to contct a because I can't redeploy it anymore all right","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=2827s"},{"start_seconds":2838,"text":"so all right so it's saying I am this called by Place meta and I'm","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=2838s"},{"start_seconds":2845,"text":"going to call this contract now I contract this I called by this contract","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=2845s"},{"start_seconds":2853,"text":"and I'm returning okay and as you can see the result of the transaction is","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=2853s"},{"start_seconds":2861,"text":"okay I feel like this is a great way to log things I like this","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=2861s"},{"start_seconds":2870,"text":"yeah so this happened we return okay because um because we depended the first","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=2870s"},{"start_seconds":2879,"text":"method depended on promise so it return This Promise instead of returning nothing so if I would return nothing","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=2879s"},{"start_seconds":2887,"text":"instead of This Promise like I will return essentially","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=2887s"},{"start_seconds":2895,"text":"white and I will again build and","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=2895s"},{"start_seconds":2904,"text":"redeploy so now I changed promise a I didn't change contract B but I don't","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=2904s"},{"start_seconds":2910,"text":"need to so if I do this","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=2910s"},{"start_seconds":2916,"text":"um I got no value so my transaction resulted in no value even so this still returned","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=2916s"},{"start_seconds":2925,"text":"okay and this is the difference between returning a promise and not returning a","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=2925s"},{"start_seconds":2934,"text":"promise so what you're showing us here is that basically if you don't return the","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=2934s"},{"start_seconds":2942,"text":"promise then uh essentially the promise will be fired async and then that that","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=2942s"},{"start_seconds":2951,"text":"transaction that gets called from Le let's just use the the sort of the nomenclature like contract a called","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=2951s"},{"start_seconds":2959,"text":"contract b as a promise but contract a is not waiting to return that promise","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=2959s"},{"start_seconds":2965,"text":"contract B will just fire on its own and it will sort of just kind it'll it'll execute but we won't have a way to sort","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=2965s"},{"start_seconds":2975,"text":"of look at that unless we're going back and we're reading TX status and we're looking at at Contract B right like like","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=2975s"},{"start_seconds":2983,"text":"actually going through the receipts but if we want to look at the actual outcome like through the promis chain we have to","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=2983s"},{"start_seconds":2991,"text":"make sure that uh like all the way back to CLI we have to make sure that contract a Returns the promise and then that way","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=2991s"},{"start_seconds":3000,"text":"it's sort of going to it's going to do the cross contract call and then wait and then return and then come back in in","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=3000s"},{"start_seconds":3008,"text":"one sort of TX status it's kind of like you're blocking with a weight a not blocking","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=3008s"},{"start_seconds":3015,"text":"with a weight in javascri so so this is essentially created a new problems with traditional JavaScript API before","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=3015s"},{"start_seconds":3024,"text":"creating a sync function now if you await on the result of This Promise then you will get","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=3024s"},{"start_seconds":3032,"text":"it from this call but if you don't await then it just fires up and you immediately","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=3032s"},{"start_seconds":3039,"text":"return we can try to demonstrate it uh through arrays because they actually","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=3039s"},{"start_seconds":3045,"text":"execute in parallel in like in blocks I guess um before we do that um I","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=3045s"},{"start_seconds":3053,"text":"want to point out you could also use the result of This Promise later on in that right like it doesn't have to be returning the promise immediately we","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=3053s"},{"start_seconds":3062,"text":"could also like assign this to a variable um and","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=3062s"},{"start_seconds":3069,"text":"then B for example and then you can return it like this but you could also wait for","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=3069s"},{"start_seconds":3077,"text":"it to be evaluated and do something else with it within the body of this call B","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=3077s"},{"start_seconds":3085,"text":"function um no you cannot do anything with this so it's not really","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=3085s"},{"start_seconds":3092,"text":"spound so you can do some stuff here you can like uh look","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=3092s"},{"start_seconds":3099,"text":"like it's gone right it can say it's gone I think I think I guess what Chad's","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=3099s"},{"start_seconds":3107,"text":"asking is like for example could and you know correct me if this is different Chad could contract","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=3107s"},{"start_seconds":3115,"text":"a return for example a Boolean but but still block on that promise call to contract B","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=3115s"},{"start_seconds":3125,"text":"and could we look at Contract B and say oh you know it's greater than 10 so return true somewhat but not really like","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=3125s"},{"start_seconds":3134,"text":"for this we'll need to look into the callbo now and explain how callbox Works sounds like sounds like sounds","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=3134s"},{"start_seconds":3142,"text":"like NE next week huh yeah we are we can finish a callback and uh then","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=3142s"},{"start_seconds":3152,"text":"more complicated we can do next week so you can create a callback again","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=3152s"},{"start_seconds":3158,"text":"this the same kind level API on yourself and","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=3158s"},{"start_seconds":3165,"text":"say um I'm going to","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=3165s"},{"start_seconds":3171,"text":"call on data and this is a call back","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=3171s"},{"start_seconds":3181,"text":"so now question which uh method you return so it's not a call back yet it's just another promise to to my own","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=3181s"},{"start_seconds":3191,"text":"method I'll create a data and","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=3191s"},{"start_seconds":3197,"text":"um and log on data","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=3197s"},{"start_seconds":3208,"text":"so so I guess the rule of thumb here is that in order to in order to to to block","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=3208s"},{"start_seconds":3215,"text":"and wait for cross contract calls you have to return a promise from the original method that you're calling and","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=3215s"},{"start_seconds":3223,"text":"that but that promise could be could be kind of constructed in such a way that you're going to do another cross contract call to another account uh","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=3223s"},{"start_seconds":3232,"text":"basically evaluate what what that returns and then and then return that within a promise to","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=3232s"},{"start_seconds":3241,"text":"yourself yes and no but so no look at this so what we got we","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=3241s"},{"start_seconds":3251,"text":"we basically issued two promises okay and on data so one of them go went to","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=3251s"},{"start_seconds":3258,"text":"the promise to contract B one of them stayed an our contract but called as synchronously as well","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=3258s"},{"start_seconds":3267,"text":"but we returned a value of Promise B so this one went just parallel to so that's why we","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=3267s"},{"start_seconds":3275,"text":"got our call then we got on data and return in okay uh the order of this","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=3275s"},{"start_seconds":3292,"text":"to is variable like I would imagine the order I don't see a receipt I don't see a receipt for this so like I don't know","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=3292s"},{"start_seconds":3300,"text":"where this 5S it's probably messed up ever since here they've all been like that the","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=3300s"},{"start_seconds":3309,"text":"second receipt like on the they've they've never been they've never matched any of the other receipts yeah I don't I I don't like the","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=3309s"},{"start_seconds":3318,"text":"three receipts in the top have not matched or the usually it's been like two receipts at the top but they have not had um they have not matched the","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=3318s"},{"start_seconds":3327,"text":"second receipt maybe it's just like receipts that were not displayed on top but uh yeah not sure why Weplay","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=3327s"},{"start_seconds":3336,"text":"these ones so this is probably refunds this like refunds but it would be helpful for every log to be attributed","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=3336s"},{"start_seconds":3343,"text":"to some receipt or like original receipt anyway yeah I'm not yeah that's so call","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=3343s"},{"start_seconds":3350,"text":"back I guess I guess sorry go ahead no maybe you wanted to before Oh no I just I guess my like my","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=3350s"},{"start_seconds":3360,"text":"biggest my biggest sort of question here would be um would be can we can we do a cross","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=3360s"},{"start_seconds":3368,"text":"contract call and and evaluate evaluate the response and return like return a c","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=3368s"},{"start_seconds":3375,"text":"like a custom response like it seems as though we we always must return the","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=3375s"},{"start_seconds":3382,"text":"promise um and I get that that's might that might be the way it is right now but","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=3382s"},{"start_seconds":3390,"text":"could what I can do now I can say promise B then call","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=3390s"},{"start_seconds":3399,"text":"back a and that's going to be actual call","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=3399s"},{"start_seconds":3409,"text":"back what I did I linked yeah","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=3409s"},{"start_seconds":3417,"text":"uh this is because this type of um","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=3417s"},{"start_seconds":3423,"text":"API is not is not a low level it's actually high","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=3423s"},{"start_seconds":3432,"text":"level methods so let's see if this works should we return actual callback in sort of","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=3432s"},{"start_seconds":3440,"text":"Promise uh no but it did consume it","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=3440s"},{"start_seconds":3449,"text":"uh maybe what we need to do is like actually switch to low level API to make it like more","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=3449s"},{"start_seconds":3456,"text":"obvious promise promise","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=3456s"},{"start_seconds":3465,"text":"badge create and it takes um account Ed","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=3465s"},{"start_seconds":3472,"text":"borrowed account Ed so I'll just return","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=3472s"},{"start_seconds":3481,"text":"now prom is B look at me and just at the edge of our","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=3481s"},{"start_seconds":3493,"text":"seat I'm I'm trying to follow along man it's exciting so what it does it takes index","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=3493s"},{"start_seconds":3503,"text":"first which is promis B index then doesn't need to v l level should","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=3503s"},{"start_seconds":3514,"text":"can work without taking the types so so it doesn't return anything so what","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=3514s"},{"start_seconds":3523,"text":"I did is I created a promise similar to high level API but it's actual host function call it give me an ID promise","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=3523s"},{"start_seconds":3532,"text":"ID instead of a promise type then I attached one action which is a functional to This","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=3532s"},{"start_seconds":3539,"text":"Promise so before we do call back can leave like this for now and then we will","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=3539s"},{"start_seconds":3546,"text":"do we cannot return a promise anymore because it doesn't expect it because of high level API instead what I","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=3546s"},{"start_seconds":3554,"text":"can do is I can do promise return and let's see if it works","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=3554s"},{"start_seconds":3566,"text":"you got rid of the return annotation though shouldn't you add that back oh you're not returning it I see right I cannot return it anymore uh let's see if","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=3566s"},{"start_seconds":3575,"text":"it works you're you're going to return void but you're still going to force the weight right like well let's see like maybe nearest DK doesn't let me do this","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=3575s"},{"start_seconds":3584,"text":"but maybe it does um it may handle it so yeah it seems like it works so I did return okay but","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=3584s"},{"start_seconds":3592,"text":"then it means it works so this actually doesn't return anything from here but","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=3592s"},{"start_seconds":3600,"text":"instead it like uses some cost method to say instead of returning value I'm actually returning the promise here's my","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=3600s"},{"start_seconds":3611,"text":"promise and I find it very unexpected that the okay is returned in that near CLI call like so much so that I'm","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=3611s"},{"start_seconds":3618,"text":"wondering if you remember to deploy a good question yeah I don't know why we would","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=3618s"},{"start_seconds":3626,"text":"say okay right yeah we should just get all the receipts","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=3626s"},{"start_seconds":3634,"text":"but but nothing gets returned am I misunderstanding why why we have okay we we might be","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=3634s"},{"start_seconds":3641,"text":"misunderstanding so promise return actually calls","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=3641s"},{"start_seconds":3648,"text":"the calls the near runtime","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=3648s"},{"start_seconds":3654,"text":"method that takes the index and passes it so a function can end in four","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=3654s"},{"start_seconds":3662,"text":"different actions so it either returns a promise or returns a","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=3662s"},{"start_seconds":3669,"text":"value so somewhere here is a oh I think it returns B","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=3669s"},{"start_seconds":3676,"text":"uh because b b is going to call uh on data right","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=3676s"},{"start_seconds":3683,"text":"and then does on data return something on data is just a parallel","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=3683s"},{"start_seconds":3691,"text":"call right now right why why does it return string okay though because I did","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=3691s"},{"start_seconds":3698,"text":"promise return so this is actual host method on the runtime so the","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=3698s"},{"start_seconds":3706,"text":"way wasm works it has like very uh complicated logic and it usually doesn't return any","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=3706s"},{"start_seconds":3715,"text":"type from it function at least for us it always void and then nearest DEC at the end of your function execution decides","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=3715s"},{"start_seconds":3724,"text":"what type to return oh oh so okay okay is not something we typed it's literally like okay like rust okay no no no it is","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=3724s"},{"start_seconds":3733,"text":"okay it is here it is here uh okay okay yeah yeah okay now I understand a lot of","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=3733s"},{"start_seconds":3740,"text":"okays going on I'm yeah I I'm actually still I find this syntax surprising it seems no return value on here I would","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=3740s"},{"start_seconds":3750,"text":"not expect the like actual thing the output on the CLI to say okay","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=3750s"},{"start_seconds":3757,"text":"that's that seems like some workaround we added in near fdk where like technically it was allowed because wasm","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=3757s"},{"start_seconds":3766,"text":"but right it it violates my expectations about how rest code works so what I did I added early return","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=3766s"},{"start_seconds":3775,"text":"to this type so I changed type from void to string so now it's a decision of near","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=3775s"},{"start_seconds":3783,"text":"SDK how to handle it because","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=3783s"},{"start_seconds":3791,"text":"uh yeah so it returned because when I did this it overrided my return value so I I did","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=3791s"},{"start_seconds":3800,"text":"this return but I did it before saying well I changed my mind I don't want to return a","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=3800s"},{"start_seconds":3807,"text":"promise anymore I want to return a value it works if you get rid of the","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=3807s"},{"start_seconds":3814,"text":"semicolon on N promise return wait for this is the best part","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=3814s"},{"start_seconds":3822,"text":"was like value return so similar to promise return you have a method value","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=3822s"},{"start_seconds":3831,"text":"return so I will get rid of explicit return at","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=3831s"},{"start_seconds":3837,"text":"ENT and do this um so right now because this is a second call it will override","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=3837s"},{"start_seconds":3844,"text":"the value return but if I flip them uh it will return the value I don't like it Eugene I don't","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=3844s"},{"start_seconds":3853,"text":"like it I Chad I think it's uh it's a is an artifact of the fact","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=3853s"},{"start_seconds":3862,"text":"that Eugene is basically like hijacking like the transaction runtime and and like outputting stuff so it's like","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=3862s"},{"start_seconds":3871,"text":"you're just basically explicitly returning right yeah so it's not intuitive all right let's","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=3871s"},{"start_seconds":3881,"text":"ignore it for now and I'm not going to override it and let's assume this is actually returns a promise index as part of the","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=3881s"},{"start_seconds":3891,"text":"function the and um I Eugene another way to","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=3891s"},{"start_seconds":3898,"text":"rephrase this ref rephrase like me and Chad's sort of like desire for some sort of like ergonomic asyn a weight thing","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=3898s"},{"start_seconds":3906,"text":"would would be a question like can we in this method can we await uh one of these","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=3906s"},{"start_seconds":3913,"text":"promises from the near SDK or are they not real like rust promes no they're not","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=3913s"},{"start_seconds":3921,"text":"like you cannot await because to await it you basically need to save your context into some temporary","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=3921s"},{"start_seconds":3930,"text":"memory and then um and","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=3930s"},{"start_seconds":3936,"text":"then block the execution until some promise is completed and then when it","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=3936s"},{"start_seconds":3944,"text":"gives you a call back you recover it from some temporary memory or like persistent State and put it into memory","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=3944s"},{"start_seconds":3951,"text":"and continue execution so you just haven't done the like the logic to do this so it makes sense to me that we","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=3951s"},{"start_seconds":3959,"text":"wouldn't support that I I wonder so I guess show us the kind of the punchline then of like okay if you want to say","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=3959s"},{"start_seconds":3968,"text":"like start do some stuff call this other function and then once that data once that function returns some data like","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=3968s"},{"start_seconds":3976,"text":"deal with the data that's the call thing show us that reimplemented","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=3976s"},{"start_seconds":3983,"text":"callback is a lowlevel API uh again I just need to do","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=3983s"},{"start_seconds":3991,"text":"this so so the behavior shouldn't change let's just confirm","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=3991s"},{"start_seconds":4001,"text":"it um but it's still issues so now it's very clear it's","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=4001s"},{"start_seconds":4008,"text":"just another promise call that is uh called call a locally but I want return","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=4008s"},{"start_seconds":4016,"text":"promise b um so what I can do now I change this","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=4016s"},{"start_seconds":4023,"text":"API from promise badge create to a different method called Promise","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=4023s"},{"start_seconds":4030,"text":"badge then it takes a promise","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=4030s"},{"start_seconds":4038,"text":"index which is going to be promise B and my current account ID so what I do this","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=4038s"},{"start_seconds":4045,"text":"this action I'm linking promise B","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=4045s"},{"start_seconds":4053,"text":"to a new callback I'm saying this call back now depends it should only be","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=4053s"},{"start_seconds":4060,"text":"executed once promise B returns a","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=4060s"},{"start_seconds":4069,"text":"value I'm still going to return promise B","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=4069s"},{"start_seconds":4079,"text":"effectively I'm creating a fort for this thing because I depend only on value","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=4079s"},{"start_seconds":4086,"text":"from B but this thing depends on value","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=4086s"},{"start_seconds":4092,"text":"from b as well but I don't return the","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=4092s"},{"start_seconds":4101,"text":"result and I should still get okay because I","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=4101s"},{"start_seconds":4109,"text":"returned the value from B but the difference now one data is called after the thing because it was","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=4109s"},{"start_seconds":4118,"text":"executed in a block number three instead of parallel to block of uh","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=4118s"},{"start_seconds":4128,"text":"B so this is what uh mat you were asking somewhat","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=4128s"},{"start_seconds":4136,"text":"whether you can handle a logic but at the same time return a","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=4136s"},{"start_seconds":4143,"text":"value so promise P or this call back on data actually receive the value from b","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=4143s"},{"start_seconds":4152,"text":"as well so we have this magical argument called value of B","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=4152s"},{"start_seconds":4179,"text":"okay so what this callback does it's saying when I receive a data from my","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=4179s"},{"start_seconds":4189,"text":"dependency the first dependency put it in here so I put","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=4189s"},{"start_seconds":4196,"text":"okay so now okay is going to be returned","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=4196s"},{"start_seconds":4202,"text":"here and into a call box it will Fork a","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=4202s"},{"start_seconds":4222,"text":"value and as you can see it get okay from this","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=4222s"},{"start_seconds":4233,"text":"result what I also can do is now I can return the value from here and say like for","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=4233s"},{"start_seconds":4242,"text":"example uh on","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=4242s"},{"start_seconds":4249,"text":"data value of B can return that from the initial thing","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=4249s"},{"start_seconds":4257,"text":"yes promise to return call back I want to just demonstrate that this thing doesn't really change","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=4257s"},{"start_seconds":4266,"text":"anything at least on our side because no one depends on the value of on data because it was forked from original","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=4266s"},{"start_seconds":4274,"text":"result so even so this thing returned the value uh it only recorded in like","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=4274s"},{"start_seconds":4282,"text":"execution outcome of this so if we get now near TX","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=4282s"},{"start_seconds":4292,"text":"status count take the uh Place","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=4292s"},{"start_seconds":4304,"text":"me we should see it somewhere I think here it is so this","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=4304s"},{"start_seconds":4313,"text":"thing should be","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=4313s"},{"start_seconds":4323,"text":"yeah so did return it into the into the chain it just near CLI","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=4323s"},{"start_seconds":4333,"text":"didn't use it and finally now instead of depending on","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=4333s"},{"start_seconds":4340,"text":"this we can uh return call back a","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=4340s"},{"start_seconds":4346,"text":"and if we do this then this is actually how the","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=4346s"},{"start_seconds":4353,"text":"traditional callback Works where","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=4353s"},{"start_seconds":4363,"text":"your where your value actually depends on the your call back so you get this on","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=4363s"},{"start_seconds":4370,"text":"data okay well this was a long call I'm feeling","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=4370s"},{"start_seconds":4381,"text":"um this was a great demo of the kinds of things that I can do with promises I still have a lot of questions about what","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=4381s"},{"start_seconds":4388,"text":"exactly is happening at the RPC level if that's blocking and hanging on like the whatever test net Noe is serving the RPC","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=4388s"},{"start_seconds":4397,"text":"request or if like near CI is quering RPC multiple times while it waits right like none of that has been cleared up in my head um and and the receipts feel","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=4397s"},{"start_seconds":4406,"text":"like something I need to go dig through TX status like I need to walk through this myself and dig through TX status","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=4406s"},{"start_seconds":4414,"text":"every single time and like start building up my mental model of what the f is happening with receipts um that but","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=4414s"},{"start_seconds":4422,"text":"yeah that's that's where I feel like I'm at I'm like aware of what's possible but the exact behavior of receipts and","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=4422s"},{"start_seconds":4430,"text":"what's happening in each block and what RPC is doing it's all still very very fuzzy for me so I guess that's what","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=4430s"},{"start_seconds":4438,"text":"that's what I'm taking as my own next steps is to like dig in a little bit more in know um yeah and kind of like","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=4438s"},{"start_seconds":4447,"text":"follow through on my own how are other people also I think I'm I think I'm like","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=4447s"},{"start_seconds":4455,"text":"I'm roughly okay right now um the I I would just say the the lowlevel","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=4455s"},{"start_seconds":4463,"text":"API like you know it's it's it's way less reminiscent of sort of just like a JavaScript like","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=4463s"},{"start_seconds":4471,"text":"async await like I can await on this promise and then I can do some with that data and then I can and then I can return some final result and it it looks","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=4471s"},{"start_seconds":4480,"text":"to me more like um it actually looks like uh I I used to do a lot of like openg programming back in the day and it","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=4480s"},{"start_seconds":4489,"text":"looks like a graphics pipeline like it's like something you would like like I want to do like you know this this this","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=4489s"},{"start_seconds":4496,"text":"and then I want to like pipe it all to the GPU and like let it sort it out and then it's G to return back from all those calls like it's something like how","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=4496s"},{"start_seconds":4505,"text":"you have to kind of the low-level stuff like the promise batch stuff it seems like you have to you have to almost like","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=4505s"},{"start_seconds":4512,"text":"slot everything in and then decide you know what which one of these am I GNA wait for at the end um yeah but it's","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=4512s"},{"start_seconds":4519,"text":"it's uh I think it would be okay like once you get used to it um one one example that I would like to see","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=4519s"},{"start_seconds":4528,"text":"actually and I I don't think we got to it but I think Eugene you were saying something about it was arrays um so for","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=4528s"},{"start_seconds":4535,"text":"example like doing a c doing like three cross contract calls uh like so basically come to one contract uh method","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=4535s"},{"start_seconds":4544,"text":"do three contract calls async wait for all of them to come back do something with all of their data and then return a","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=4544s"},{"start_seconds":4553,"text":"final promise that would be very interesting so it's like kind of like goes from one block and then in the next block there's like three calls that are","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=4553s"},{"start_seconds":4562,"text":"all happening hope hopefully within the next block and then in the final block you're bringing together all of the Val","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=4562s"},{"start_seconds":4570,"text":"the return values from those three uh promises that that executed Asing that would be very interesting I think you have an example of that called it's like","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=4570s"},{"start_seconds":4578,"text":"a merge sort in a contract right so so I want I want to just demonstrate quickly what happens","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=4578s"},{"start_seconds":4586,"text":"so let's say we introduce a promise c um which going to be same as promise B","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=4586s"},{"start_seconds":4595,"text":"except uh in parallel so what API allows you to do is kind of create a join","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=4595s"},{"start_seconds":4601,"text":"promise which is you","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=4601s"},{"start_seconds":4607,"text":"um join uh two promises or more together","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=4607s"},{"start_seconds":4617,"text":"so you join for example promise B and promise C and then you have a call back on the join","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=4617s"},{"start_seconds":4625,"text":"promise so now this thing going to return receive two","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=4625s"},{"start_seconds":4631,"text":"values um and two call back values and we can just just while you're","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=4631s"},{"start_seconds":4640,"text":"typing that Eugene I just wanted to say a great parallel for this uh sort of type of syntax is um goang","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=4640s"},{"start_seconds":4649,"text":"and uh the weight groups um there like with with go sub routines and weight groups","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=4649s"},{"start_seconds":4658,"text":"that's actually really really similar to this because you call like a wait group and then you you if you join if you call","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=4658s"},{"start_seconds":4666,"text":"join on the group it waits until all of the sub routines like come back and then it come together it's pretty cool so so","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=4666s"},{"start_seconds":4674,"text":"you designed it to around original","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=4674s"},{"start_seconds":4680,"text":"JavaScript API um which is allows you to kind","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=4680s"},{"start_seconds":4688,"text":"of you have promise so a new promise which will create","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=4688s"},{"start_seconds":4696,"text":"actual it takes the sub rtin well not what it's called Lambda","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=4696s"},{"start_seconds":4705,"text":"um that's not yet executed because JavaScript is a","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=4705s"},{"start_seconds":4714,"text":"single traded but it will start executing once you exit the current Loop or like you","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=4714s"},{"start_seconds":4723,"text":"exit the current method this is exactly what happens here the promise is not fired until you're done with your","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=4723s"},{"start_seconds":4731,"text":"synchronous call so that's that's why when you were returning but but kind of forking out","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=4731s"},{"start_seconds":4738,"text":"the promise you were getting like a like this is way way back at the beginning when you were returning okay but just making one call out that's why you would","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=4738s"},{"start_seconds":4746,"text":"get the okay from the transaction but the other call was still going in the next block right but that yeah that transaction was actually returning","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=4746s"},{"start_seconds":4755,"text":"within the first block yes this is really cool my mind is like","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=4755s"},{"start_seconds":4763,"text":"on fire with all the possib okay","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=4763s"},{"start_seconds":4769,"text":"um and we also have some weird stuff which is call back","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=4769s"},{"start_seconds":4775,"text":"W uh if you expect the same","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=4775s"},{"start_seconds":4782,"text":"type then you can outp put cobat","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=4782s"},{"start_seconds":4791,"text":"R and I'm going to use thebug to to print it","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=4791s"},{"start_seconds":4798,"text":"oops it works exactly as a","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=4798s"},{"start_seconds":4806,"text":"callback but it handles them if they return the same type I","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=4806s"},{"start_seconds":4815,"text":"think um the only the only thing that's a bit of a black box for me still is this is this callback macro and callback","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=4815s"},{"start_seconds":4822,"text":"VC macro um yeah um assuming is that just some like is that just a very small","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=4822s"},{"start_seconds":4829,"text":"amount of like syntax stuff from from from near SDK or is that something much it is kind of like a helper from near","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=4829s"},{"start_seconds":4838,"text":"SDK that un rups all of this uh but what it lets us do now is like I got two calls","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=4838s"},{"start_seconds":4846,"text":"right I can now write a loop","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=4846s"},{"start_seconds":4853,"text":"um where I will","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=4853s"},{"start_seconds":4859,"text":"isue let's say six calls to to be under the appropriate limit so I cannot do 10","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=4859s"},{"start_seconds":4868,"text":"because I only have 100 gas","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=4868s"},{"start_seconds":4875,"text":"um promises so this is like how you would do this in JavaScript you may create an","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=4875s"},{"start_seconds":4882,"text":"array a bunch of stuff you do and then you do promise all so this is similar to promise","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=4882s"},{"start_seconds":4897,"text":"end and I'll just that's starting to look a little","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=4897s"},{"start_seconds":4904,"text":"more little bit more palatable huh chat it's starting to look a little more","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=4904s"},{"start_seconds":4913,"text":"wet palatable like it's a it's basically declare an array of promises uh you know push your promises onto the array and","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=4913s"},{"start_seconds":4922,"text":"then promise and is sort of like a replacement for promise all and then do the call back a and then basically","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=4922s"},{"start_seconds":4930,"text":"process all the values yeah it's pretty it's pretty verose but like I get the the general idea that that's actually","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=4930s"},{"start_seconds":4937,"text":"something that's that's really really interesting it's yeah yeah I I feel like the POS I'm starting to get the","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=4937s"},{"start_seconds":4945,"text":"possibilities and how I would write it the piece of the mental model I'm missing is just like what exactly is happening with receipts in RPC right","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=4945s"},{"start_seconds":4952,"text":"like those are still the things that I want to figure out okay exceeded prepaid gu uh this happens because I did not","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=4952s"},{"start_seconds":4961,"text":"have enough gu so let's attach B load bot load is always","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=4961s"},{"start_seconds":4970,"text":"uh same boat load's the technical term right yes it's a technical term of Bo load of","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=4970s"},{"start_seconds":4978,"text":"gas which indicates you attach the maximum amount so yeah we we basically scheduled","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=4978s"},{"start_seconds":4985,"text":"six promises then I waited for all six to complete before processing it but in","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=4985s"},{"start_seconds":4993,"text":"a perfect world Eugene like like in a in a very empty chain or if you're paying enough in gas you'd really just be","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=4993s"},{"start_seconds":5001,"text":"calling the one method in in block a then you'd be you'd have six promises","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=5001s"},{"start_seconds":5008,"text":"fire in Block B sorry my hands are reversed yeah it is how it worked it is essentially it only like as you can see","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=5008s"},{"start_seconds":5018,"text":"it completes in like about four seconds right now am I am I correct in","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=5018s"},{"start_seconds":5024,"text":"understanding like if the chain is busy if the if the the blocks or the shards or whatever if they're all busy we don't","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=5024s"},{"start_seconds":5032,"text":"make guarantees about like when when your promises will be included we just sort of near near just says we'll do the","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=5032s"},{"start_seconds":5040,"text":"best we can right right it well we say it will be","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=5040s"},{"start_seconds":5046,"text":"completed um on time but let's say the chain was let's","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=5046s"},{"start_seconds":5054,"text":"say the chain was like busy right and you couldn't get into the next block you'd have to wait until the block after right right but yeah we do only","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=5054s"},{"start_seconds":5063,"text":"guarantee that you will eventually finish execution","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=5063s"},{"start_seconds":5069,"text":"right wow okay well Okay cool so we got six","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=5069s"},{"start_seconds":5079,"text":"okay um what else good amount of okays your pro this is actually what you","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=5079s"},{"start_seconds":5086,"text":"wanted to do is um how you can do this uh you can basically","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=5086s"},{"start_seconds":5094,"text":"use n random Sid and then you can convert it","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=5094s"},{"start_seconds":5105,"text":"to hex what is this what is thex okay let's see if it","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=5105s"},{"start_seconds":5113,"text":"compiles um not","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=5113s"},{"start_seconds":5120,"text":"really the random seed uh is it's a it's it's 30 it's","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=5120s"},{"start_seconds":5130,"text":"32 uh 32 u u 128 I think no it's 32 u8 so it's","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=5130s"},{"start_seconds":5141,"text":"like it's basically just 32 bytes of","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=5141s"},{"start_seconds":5150,"text":"Randomness uh so what I'm going to do I'm going to sech the Json to","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=5150s"},{"start_seconds":5157,"text":"string of this so I'm going to use our magical type which allows us to serialize into","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=5157s"},{"start_seconds":5166,"text":"Bas 64 I'm going un rra","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=5166s"},{"start_seconds":5173,"text":"it and it shouldn't do the trick um now I just need to do deploy it","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=5173s"},{"start_seconds":5184,"text":"on B but I'll just call the same contract multiple times doesn't matter","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=5184s"},{"start_seconds":5194,"text":"really so with the recent fix we","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=5194s"},{"start_seconds":5200,"text":"did uh actually every promise and","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=5200s"},{"start_seconds":5207,"text":"every like every action receives its own random SE so every transaction within","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=5207s"},{"start_seconds":5214,"text":"one one block gets a different random SE before that they all get the same random","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=5214s"},{"start_seconds":5221,"text":"SE for one block but now they're differ so we can build some some Mega","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=5221s"},{"start_seconds":5230,"text":"casinos on the blockchain yeah I don't know what what uh what you're doing but it seems like some stuff is possible now","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=5230s"},{"start_seconds":5240,"text":"yeah actually you know random randomness is uh is just so it's so beautiful it's like the B the basis for so much stuff","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=5240s"},{"start_seconds":5248,"text":"like let's say me and Chad wanted to play you know Battleship or tic-tac-toe or something like that like it's just","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=5248s"},{"start_seconds":5255,"text":"you can do well Tic Tac Toe no but Battleship uh if we wanted our board to be randomly assigned right um I mean you","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=5255s"},{"start_seconds":5265,"text":"can always like force the player to pick the the setup of their boats before but like I mean just playing like Monopoly","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=5265s"},{"start_seconds":5272,"text":"for example like I mean it's and then there's there's lots of possibilities for um for example like solo games like","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=5272s"},{"start_seconds":5282,"text":"solitire or something um or playing like with a tamagachi like I could sell you um like a non-f fungible token like some","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=5282s"},{"start_seconds":5291,"text":"some thing that you collect but it could actually um have like a ping method or","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=5291s"},{"start_seconds":5297,"text":"like a feed method and when you feed it it then randomly desires something else like that you need to play with it","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=5297s"},{"start_seconds":5305,"text":"within the next 12 hours otherwise it's going to be you know it's it's going to be unhappy you know so I mean like you","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=5305s"},{"start_seconds":5313,"text":"could do so many of these these things that that would just create some crazy sort of gamification so I think","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=5313s"},{"start_seconds":5321,"text":"important we have we do have Randomness the problem is like you don't have uh so you do have Randomness but what you","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=5321s"},{"start_seconds":5329,"text":"don't have is like a you cannot hide hide the state of the game so you cannot really build a pocker on chain very","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=5329s"},{"start_seconds":5337,"text":"easily because a pocker is like a limited knowledge game so you don't know for example what the board is or like","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=5337s"},{"start_seconds":5346,"text":"what's the what's the cards of the other players but they need to know this so the contract cannot really tell","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=5346s"},{"start_seconds":5355,"text":"you um unless you somehow use a","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=5355s"},{"start_seconds":5362,"text":"VF or no notw of somehow you use um approvable","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=5362s"},{"start_seconds":5371,"text":"Randomness so this commit and reveal and when you reveal you can see it like if you don't reveal you can see the","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=5371s"},{"start_seconds":5379,"text":"game this way you know the cards they based on random uh but the problem you will have","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=5379s"},{"start_seconds":5387,"text":"collisions on the board like you can randomly draw a new card but you cannot guarantee that I","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=5387s"},{"start_seconds":5395,"text":"don't have the same card already so it will be a modification to a traditional","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=5395s"},{"start_seconds":5401,"text":"pocker where you have like five Aces for example right so what you're saying is","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=5401s"},{"start_seconds":5410,"text":"that if you if you uh I might use some different terminology but if you kind of like mask each player's hand with a","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=5410s"},{"start_seconds":5418,"text":"commit reveal then there's no there's no way to globally know that somebody doesn't have like five Aces or something","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=5418s"},{"start_seconds":5425,"text":"right yeah yes um another question just quickly uh before we sign off about our","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=5425s"},{"start_seconds":5433,"text":"our vrf um I was in a conversation with with Bowen about it and there there was","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=5433s"},{"start_seconds":5439,"text":"some some indication from him that a validator may be able to uh to see uh","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=5439s"},{"start_seconds":5448,"text":"like a very very small uh amount of the vrf or is the vrf like is the vrf kind","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=5448s"},{"start_seconds":5456,"text":"of like unknown to them until they have to validate the block like how how does that work because they could potentially","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=5456s"},{"start_seconds":5464,"text":"um they could front run in front of a random like a random output that is beneficial to you and if they were the","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=5464s"},{"start_seconds":5472,"text":"other party like the you know um on a transaction they could block maybe like they could they could they could right","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=5472s"},{"start_seconds":5479,"text":"so so what happens is um they have a binary decision whether to publish a block or","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=5479s"},{"start_seconds":5486,"text":"not so this is the only action they can do so they have some Advantage if the","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=5486s"},{"start_seconds":5494,"text":"decision comes to their blog and if they don't publish a Blog then the next person going to publish a block so they","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=5494s"},{"start_seconds":5503,"text":"have some Advantage if the validator plays against you and they have a option to not publish their blog and the","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=5503s"},{"start_seconds":5511,"text":"decision comes to their um position in the list of validators but the next validator who publishes the","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=5511s"},{"start_seconds":5520,"text":"blog will uh have it so so do they get do they get punished","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=5520s"},{"start_seconds":5530,"text":"for choosing arbitrarily choosing not to not to publish blocks right so so if you miss too many","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=5530s"},{"start_seconds":5537,"text":"blocks you will start losing rewards and eventually you may be kicked out of the list of validators so potentially","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=5537s"},{"start_seconds":5544,"text":"they have some punishment but at the same time uh it's not as big comparing to like let's say you have a final price","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=5544s"},{"start_seconds":5553,"text":"to be selected um but if you do this then you","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=5553s"},{"start_seconds":5560,"text":"can try to upate it somehow as well but no not there's no 100%","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=5560s"},{"start_seconds":5571,"text":"protection against this right all right okay well thanks","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=5571s"},{"start_seconds":5580,"text":"everybody uh for watching this uh see you next time thank you","url":"https://www.youtube.com/watch?v=971dTz6nM2g&t=5580s"}],"youtube_url":"https://youtube.com/watch?v=971dTz6nM2g","url":"https://near-pedia.xyz/videos/971dTz6nM2g"}