{"id":"DDmf6qAHEKs","title":"Block Zero Stage | Explore Elegant Prototyping With NEAR SDK Contract Tools","description":"Explore Elegant Prototyping With NEAR-SDK-Contract-Tools, presented by Jacob Lindahl of Pagoda, at NEARCON 2023.\n\nExplore near-sdk-contract-tools: where intricacy meets elegance. Experience simple, efficient prototyping without compromising on extensibility or security.\n\nJoin NEAR's community:\nWebsite: https://near.org/\nReddit:   / nearprotocol  \nDiscord: https://near.chat/\nMedium:   / nearprotocol  \nBlog: https://near.org/blog/\nTwitter:   / nearprotocol  \nGitHub: https://github.com/near  https://github.com/nearprotocol\nDev Docs: https://docs.near.org/\nCreate a wallet: https://wallet.near.org/create\nApps on NEAR: https://awesomenear.com/\nLearn to Build On NEAR: https://www.near.university/\nGrants & Funding: https://near.org/grants/\n#Blockchain #FutureisNEAR #NEAR #nearprotocol\n#nft #dao","channel_name":"NEAR Protocol","published_at":"2023-11-29T00:00:00.000Z","thumbnail_url":"https://img.youtube.com/vi/DDmf6qAHEKs/hqdefault.jpg","transcript_text":"uh so next up we have pigot's Jacob lindal that's going to talk to us about uh exploring elegant prototyping with near SDK contract tools so let's give a round of applause for Jacob everybody hey everybody how's it going my name is Jacob and we're going to be talking about elegant smart contracts going to get into a little bit of smart contract security talk about a little bit of coding uh and then we have a product announcement or maybe two at the end all right so writing smart contracts is hard you know uh we've been in the this is the hacker HQ I'm sure we've all had uh a taste of coding in our lives and writing smart contracts is hard because in order for a smart contract to be ready for production it needs to be two things it needs to be correct and it needs to be secure what does that mean correct well it's pretty simple it just means it does the thing it does the thing correctly it does the right thing it works right that's what correct means well that's how I'm going to use it in this presentation and it also needs to be secure basically that means our smart contract doesn't do the wrong things so we want our smart contract to do the right thing and to not do the wrong things unfortunately this is not it's not really a balanced issue here because if we have a smart contract that is incorrect but highly secure we basically have a rock and a rock is not very useful but I guess it's secure right uh but if we have a smart contract that is correct but insecure you can actually build an app around that because it's functional it works you can build an app around that you can build an ecosystem around that people will see oh this application works and I might deposit money in it I can maybe it's a defi contract or a market maker or something and I can deposit money into the smart contract contract and it works unfortunately if it's insecure you end up with charts that look like this this is uh from chainalysis it's a graph of the total value that's been lost through crypto related hacks over the past seven years and we're not trending in the right direction last year according to this particular analysis uh around $3.8 billion worth of value were lost in cryptocurrency Rel hacks and uh that's not good so what could a potential solution to this problem look like well one of the first things that might jump into your head is auditing and that's a good thing auditing is great but auditing should not be the only security measure that you have in your development uh in your development process it's really great as a last step it's that final third party check saying yes I'm signing off on this this this looks secure but it shouldn't be the first step in your security process and it definitely shouldn't be the only step let's try and get into a security mindset here and have a little quiz so we're going to do a little bit of audience interaction here um I have two different code Snippets that we're going to look at they are derived from uh either real life smart contracts that have been exploited or from audit reports that I have read so these are uh they're not exactly real life Snippets because they've been simplified down and they fit on a slide now uh but these are actual real life vulnerabilities that existed at some point in the wild so this is the first one imagine we have a smart contract that allows users to deposit the native token of our Network in this case near to our smart contract and then this function the idea is it allows you to withdraw the number of tokens that you have deposited so let's read through this line by line first we're going to grab the collar of the function and call it sender ID then we're going to remove the entry from our balance record because we're withdrawing all of our near all of our near tokens from the smart contract and then we'll send the number of near tokens that we have in our balance record in our balance sheet to the collar of the function does anyone see what might be wrong with this particular function here raise a hand call it out David in the back yes that is exactly right we are deleting the record uh in our balance table before we then try and read that record and so of course this code never works properly because every single time we run this function the balance record will not exist because we already deleted it all right uh that was the first one pretty easy here's our second one it's a little bit longer and it's fairly similar in intent to the to the first code snippet except in this one instead of the user depositing native near tokens we are depositing fungible tokens that implement the NEP 141 contract standard the idea here is okay maybe the user doesn't want to withdraw all of their tokens they just want to withdraw some of them that is intended that's not a bug in this particular piece of code uh they might want to just leave some of the tokens in the smart contract so let's step through this line by line again we get the caller then we Loop through all of the tokens we want to withdraw we make sure that the balance record in our balance table uh says that the color of the function has enough tokens that they say they want to withdraw then we send them that number of tokens and then finally we remove the record from the balance sheet does anyone see what might be wrong with this piece of code sorry they're bringing your mic uh it could be uh repeatedly to withraw those amount of money right you say a little louder uh repeatedly to to withdraw those money repeatedly withdraw yeah yep that's exactly correct if if I specify that I want to withdraw uh say say I have legitimately deposited 10 usdc or something into this contract and I say I want to withdraw my 10 usdc but I specify usdc 30 times in my list of tokens here I will be able to withdraw way more tokens than I am entitled to withdraw all right so hopefully that wet your appetite got you into kind of this security mindset and let's talk about some principles for smart contract design uh and these are kind of principles for secure smart contract design so so we have four of them here we'll go through them one at a time uh yeah there we go first one is trust less we talk a lot about trust lessness I'm going to split this word in we'll say trust less and the idea here is we have a lot of different entities that are talking to our smart contract and we really don't want to trust them too much uh I'm going to call out two specific areas that I see a lot of excessive trust uh in different smart contracts that I've read particularly in audit reports um the first is don't trust user input as we saw in that second example that second code snippet it's possible that unintentionally or maybe even maliciously a user could provide a payload that causes our smart contract to work improperly so make sure to validate that user input the second thing is don't trust other smart contracts in particular this might crop up when you're interacting with say a token uh like a fungible token smart contract and you just assume oh this implements the the nep1 141 standard this implements the NEP 171 standard and you just assume that it works properly and a lot of times that'll work just fine it'll probably work just fine in your testing but when you're out in the wild there might be a smart contract that claims to implement ne1 for one correctly but doesn't maybe it was an accidental bug or they just slightly modified the contract but still try to work with applications that support nep1 141 or maybe it's an actively malicious smart contract that claims to implement this standard but doesn't actually so th those malicious smart contracts could potentially uh take advantage of that assumption and that's a recipe for disaster our second uh our second item here is to make the invalid impossible trying to make these like really short and py statements uh if you do a Google search for make invalid States unrepresentable that'll bring up a whole bunch of articles about this very topic but I chose this particular illustration because if you think of the data structures and the way that your smart contract handles data as like a mold and then your data that you receive as input from other smart contracts from your users so on and so forth as uh something you're pouring into that mold you want to design that mold in such a way that no matter what data comes in if if you can get it to fit into that mold it's going to be valid data right you just want to be able to have this contract about the data that your smart contract is dealing with where you know if it fits in this data type if it fits in this struct I've designed this enum I've designed so on and so forth then it will be valid data and as much as possible we want to operate with these really strong guarantees about our data so make invalid States unrepresentable design your data structures in a way to avoid supporting invalid contents next we have one truth have one source of Truth for the data in your smart contract if you have multiple different places where you're storing the same data that can cause some synchronicity issues and I chose this uh illustration of a funnel here to kind of uh illustrate the idea that if you have one source of Truth for your data you can also really tightly control how that data changes right there's only one way to access this data and in order to access it you have to go through all of these different checks all of these different verifications and those are always going to be in sync with each other because well there's only one thing to be in sync with finally test for failure as well of course we want our smart contracts to be correct we want the Happy path to work and that's a really easy thing to test what's not always as intuitive to test is failure we want to make sure that yes our smart contract Works where it's supposed to work but we also want to make sure that it fails where it's supposed to fail so test for failure 2 finally uh doing all of that is hard and it is it's really hard it is hard it is hard um so luckily we have a bunch of tools at our disposal to help with this I'm going to particularly call out the programming language rust huge fan anyone who knows me I really like programming in Rust and luckily near protocol is built in Rust and supports it as a first class citizen for smart contract programming so we have this really strong type system that comes with rust algebraic data types fancy enums fancy structs and it makes it so that oh it's a little bit harder at at at first a little steeper uh steeper learning curve to get started with rust but once you get used to it the rust compiler actually becomes like a friend it's helping you to code correctly the second thing we have in Rust is powerful macros if you're someone who might be coming from a little higher level programming background something like JavaScript or python the idea of meta programming or macro might be new to you a macro is basically just code that writes code So Meta programming because we're programming the programming language this is an example of a macro invocation in Rust derive debug there uh kind of highlighted in that bluish green color and it expands to this big long thing and you'll see here it's it's actually taking into account the item that annotate that it was attached to that message struct so it prints out all the fields and it prints out the name of the struct so on and so forth so this is the idea of meta programming my team has taken all these ideas these security Concepts and the powerful tools that rust avails to us and designed a new smart contract Library called near SDK contract tools that provides a bunch of onliners implementing a bunch of different contract standards and not just the NEP standards but other tools as well so you can Implement online multisig wallets you can Implement ownership you can Implement uh role based Access Control uh contract posability there's even a uh more optimized account ID uh utility in there as well and a whole bunch of other stuff that hopefully you will find useful the onliners work just like this so this is kind of your boiler plate that you'll see very often in a near protocol uh smart contract that's built in Rust in order to implement say a fungible token then all you have to do is well import it from the library and then add one single line and you automatically Implement three different contract standards luckily the way this library is designed is you can choose the amount of magic that you want in your smart contract so here there's a lot of magic going on uh you just have the one line and it does a ton of stuff but this smart contract library has layers of magic that you can decide to implement all of the different standards manually and connect them together by yourself or use a little bit of magic here and less magic elsewhere it's very flexible modular it doesn't tie you into uh just this ecosystem it plays very nicely with the other smart contract libraries that are available for near protocol and of course if you want to extend the functionality of this Library there are hooks that make it really easy to say make your fungible token posible and again this is a a high level of magic that you're seeing right here but uh you can kind of choose the amount of magic that you want in your smart contract this is just the highest level for the most concise code all right so that was magic but I hear you you're sitting there you're saying I don't want to have to learn a whole new smart contract library in order to uh you know leverage these uh Primitives that are available in this smart contract Library I just want to get started get off the ground running quickly so my team has also designed another tool that is available on the boss it is is called the contract wizard you can scan the QR code right there to access it or go to new.org and search for contract wizard it'll pull up this user interface and you can right away just generate the code to get you started uh writing a smart contract that implements all of these different standards and takes advantage of the power of the rust programming language and also this smart contract library was designed with all these security considerations in mind as we were writing the library so that is all I have for you today that's the same QR code that was on the previous slide so scan it and start writing your smart contracts on near in Rust thank you very much all right it looks like we have a little bit of time for questions so I would love to take questions from the audience if you have uh anything that you wouldd like me to uh detail a little more yes sorry they're they're bringing your mic uh well it enlarge my wasm file because I my wasm file is really big now your wasm file is really large yeah very large so you want to optimize it yeah so if I use your your tools be larger or it will not be larger because this uh smart contract uh library is composed mostly of macros you will only generate extra code when you actually invoke the macros so just by including the library your smart contract won't be any Baker okay thank you thank you any other questions what what's the next step what's the next step for near SDK contract tools well um one of the things that we're really excited about for oh does this back button work I don't think oh there it goes now now it just went really far back okay so um some of the things that we are working on for near SDK contract tools is well more standards like the multi multi- token standard that's uh next up as well as uh for the contract wizard we have some really high hopes for this because this is really really just the start of uh the contract wizard with the relays and the um other fun stuff that has been announced at ncon we are hoping to make it so that you can not only generate the code but also generate the WM blob and even deploy the smart contract that you generated directly from the boss so those are some things that we are looking forward to in the future you have another question over here hi will you do the same thing for the soulbound token because it was pretty uh successful with the NDC election and yeah I I think reputation will be something on near and uh yeah I would be very glad to see that for soulbound token a soulbound tokens so like the idea of an nft that's non-transferable correct right so um we have the non-fungible token standards NE NEP 171 and we have the macros that Implement that all for you and if you recall here we have different hooks here now you don't you're not restricted to using just say the posible hook you can also write your own hook for different uh life cycle methods of the different standards so for example there exists a transfer hook for NEP 171 and you can Implement something in there that will make it impossible you know uh say error out Panic every time a transfer is attempted so you could make a token that implements the NEP 171 standard but disables transfers quite easily MH are there any plans to add uh async rust when calling other contracts inside of the uh contract Library so uh there is I've been discussing uh some very primitive plans uh with some of my co-workers we've been talking about uh thinking about adding some async Rust features maybe in this Library maybe in a different Library hasn't really been decided yet uh but in particular uh some async Rust features might be coming uh I might have uh taken a chunk of time directly after nearon in which I'm going to attempt to implement that uh but that's not necessarily a guarantee at this point in time definitely of Interest though thank you for the question all right and it looks like that is our time right there so thank you everybody for attending and uh use near DK contract tools","transcript_synced_at":"2026-11-03T06:12:55.792Z","segments":[{"start_seconds":0,"text":"uh so next up we have pigot's Jacob lindal that's going to talk to us about uh exploring elegant prototyping with near SDK contract tools so let's give a","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=0s"},{"start_seconds":8,"text":"round of applause for Jacob everybody hey everybody how's it going","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=8s"},{"start_seconds":18,"text":"my name is Jacob and we're going to be talking about elegant smart contracts going to get into a little bit of smart contract security talk about a little","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=18s"},{"start_seconds":26,"text":"bit of coding uh and then we have a product announcement or maybe two at the end all right so writing smart contracts","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=26s"},{"start_seconds":33,"text":"is hard you know uh we've been in the this is the hacker HQ I'm sure we've all had uh a taste of coding in our lives","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=33s"},{"start_seconds":42,"text":"and writing smart contracts is hard because in order for a smart contract to be ready for production it needs to be two things it needs to be correct and it","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=42s"},{"start_seconds":51,"text":"needs to be secure what does that mean correct well it's pretty simple it just means it does the thing it does the","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=51s"},{"start_seconds":58,"text":"thing correctly it does the right thing it works right that's what correct means well that's how I'm going to use it in","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=58s"},{"start_seconds":65,"text":"this presentation and it also needs to be secure basically that means our smart contract doesn't do the wrong things so","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=65s"},{"start_seconds":73,"text":"we want our smart contract to do the right thing and to not do the wrong things unfortunately this is not it's","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=73s"},{"start_seconds":81,"text":"not really a balanced issue here because if we have a smart contract that is incorrect but highly secure we basically","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=81s"},{"start_seconds":89,"text":"have a rock and a rock is not very useful but I guess it's secure right uh","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=89s"},{"start_seconds":97,"text":"but if we have a smart contract that is correct but insecure you can actually build an app around that because it's functional it works you can build an app","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=97s"},{"start_seconds":106,"text":"around that you can build an ecosystem around that people will see oh this application works and I might deposit","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=106s"},{"start_seconds":113,"text":"money in it I can maybe it's a defi contract or a market maker or something and I can deposit money into the smart contract contract and it works","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=113s"},{"start_seconds":122,"text":"unfortunately if it's insecure you end up with charts that look like this this is uh from chainalysis it's a","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=122s"},{"start_seconds":130,"text":"graph of the total value that's been lost through crypto related hacks over the past seven years and we're not","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=130s"},{"start_seconds":138,"text":"trending in the right direction last year according to this particular analysis uh around $3.8 billion worth of","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=138s"},{"start_seconds":146,"text":"value were lost in cryptocurrency Rel hacks and uh that's not good so what","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=146s"},{"start_seconds":154,"text":"could a potential solution to this problem look like well one of the first things that might jump into your head is","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=154s"},{"start_seconds":162,"text":"auditing and that's a good thing auditing is great but auditing should not be the only security measure that you have in your development uh in your","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=162s"},{"start_seconds":171,"text":"development process it's really great as a last step it's that final third party check saying yes I'm signing off on this","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=171s"},{"start_seconds":179,"text":"this this looks secure but it shouldn't be the first step in your security process and it definitely shouldn't be","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=179s"},{"start_seconds":186,"text":"the only step let's try and get into a security mindset here and have a little","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=186s"},{"start_seconds":193,"text":"quiz so we're going to do a little bit of audience interaction here um I have two different code Snippets that we're","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=193s"},{"start_seconds":200,"text":"going to look at they are derived from uh either real life smart contracts that have been exploited or from audit","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=200s"},{"start_seconds":208,"text":"reports that I have read so these are uh they're not exactly real life Snippets because they've been simplified down and they fit on a slide now uh but these are","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=208s"},{"start_seconds":217,"text":"actual real life vulnerabilities that existed at some point in the wild so this is the first one imagine we have a","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=217s"},{"start_seconds":226,"text":"smart contract that allows users to deposit the native token of our Network in this case near to our smart contract","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=226s"},{"start_seconds":235,"text":"and then this function the idea is it allows you to withdraw the number of tokens that you have deposited so let's","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=235s"},{"start_seconds":242,"text":"read through this line by line first we're going to grab the collar of the function and call it sender ID then","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=242s"},{"start_seconds":251,"text":"we're going to remove the entry from our balance record because we're withdrawing all of our near all of our near tokens from the smart contract and then we'll","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=251s"},{"start_seconds":259,"text":"send the number of near tokens that we have in our balance record in our balance sheet to the collar of the function does anyone see what might be","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=259s"},{"start_seconds":268,"text":"wrong with this particular function here raise a hand call it out David in the","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=268s"},{"start_seconds":279,"text":"back yes that is exactly right we are deleting the record uh in our balance table before we then try and read that","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=279s"},{"start_seconds":288,"text":"record and so of course this code never works properly because every single time we run this function the balance record will not exist because we already","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=288s"},{"start_seconds":296,"text":"deleted it all right uh that was the first one pretty easy here's our second one it's a little bit longer and it's","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=296s"},{"start_seconds":303,"text":"fairly similar in intent to the to the first code snippet except in this one instead of the user depositing native","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=303s"},{"start_seconds":313,"text":"near tokens we are depositing fungible tokens that implement the NEP 141 contract standard the idea here is okay","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=313s"},{"start_seconds":322,"text":"maybe the user doesn't want to withdraw all of their tokens they just want to withdraw some of them that is intended that's not a bug in this particular","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=322s"},{"start_seconds":329,"text":"piece of code uh they might want to just leave some of the tokens in the smart contract so let's step through this line by line again we get the caller then we","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=329s"},{"start_seconds":337,"text":"Loop through all of the tokens we want to withdraw we make sure that the balance record in our balance table uh","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=337s"},{"start_seconds":345,"text":"says that the color of the function has enough tokens that they say they want to withdraw then we send them that number of tokens and then finally we remove the","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=345s"},{"start_seconds":353,"text":"record from the balance sheet does anyone see what might be wrong with this piece of code","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=353s"},{"start_seconds":367,"text":"sorry they're bringing your mic uh it could be uh repeatedly to withraw those amount of money right you","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=367s"},{"start_seconds":376,"text":"say a little louder uh repeatedly to to withdraw those money repeatedly withdraw yeah yep that's exactly correct if if I","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=376s"},{"start_seconds":385,"text":"specify that I want to withdraw uh say say I have legitimately deposited 10 usdc or something into this contract and","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=385s"},{"start_seconds":394,"text":"I say I want to withdraw my 10 usdc but I specify usdc 30 times in my list of tokens here I will be able to withdraw","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=394s"},{"start_seconds":403,"text":"way more tokens than I am entitled to withdraw all right so hopefully that wet your appetite got you into kind of this security mindset and let's talk about","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=403s"},{"start_seconds":412,"text":"some principles for smart contract design uh and these are kind of principles for secure smart contract design so so we have four of them here","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=412s"},{"start_seconds":420,"text":"we'll go through them one at a time uh yeah there we go first one is trust less we talk a lot about trust lessness I'm","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=420s"},{"start_seconds":428,"text":"going to split this word in we'll say trust less and the idea here is we have a lot of different entities that are","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=428s"},{"start_seconds":435,"text":"talking to our smart contract and we really don't want to trust them too much uh I'm going to call out two specific areas that I see a lot of excessive","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=435s"},{"start_seconds":444,"text":"trust uh in different smart contracts that I've read particularly in audit reports um the first is don't trust user input as we saw in that second example","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=444s"},{"start_seconds":453,"text":"that second code snippet it's possible that unintentionally or maybe even maliciously a user could provide a payload that causes our smart contract","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=453s"},{"start_seconds":461,"text":"to work improperly so make sure to validate that user input the second thing is don't trust other smart","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=461s"},{"start_seconds":468,"text":"contracts in particular this might crop up when you're interacting with say a token uh like a fungible token smart","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=468s"},{"start_seconds":476,"text":"contract and you just assume oh this implements the the nep1 141 standard this implements the NEP 171 standard and","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=476s"},{"start_seconds":483,"text":"you just assume that it works properly and a lot of times that'll work just fine it'll probably work just fine in your testing but when you're out in the","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=483s"},{"start_seconds":491,"text":"wild there might be a smart contract that claims to implement ne1 for one correctly but doesn't maybe it was an","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=491s"},{"start_seconds":499,"text":"accidental bug or they just slightly modified the contract but still try to work with applications that support nep1","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=499s"},{"start_seconds":507,"text":"141 or maybe it's an actively malicious smart contract that claims to implement this standard but doesn't actually","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=507s"},{"start_seconds":515,"text":"so th those malicious smart contracts could potentially uh take advantage of that assumption and that's a recipe for","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=515s"},{"start_seconds":523,"text":"disaster our second uh our second item here is to make the invalid impossible trying to make these like really short","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=523s"},{"start_seconds":530,"text":"and py statements uh if you do a Google search for make invalid States unrepresentable that'll bring up a whole","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=530s"},{"start_seconds":537,"text":"bunch of articles about this very topic but I chose this particular illustration because if you think of the data structures and the way that your smart","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=537s"},{"start_seconds":545,"text":"contract handles data as like a mold and then your data that you receive as input from other smart contracts from your","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=545s"},{"start_seconds":552,"text":"users so on and so forth as uh something you're pouring into that mold you want to design that mold in such a way that no matter what data comes in if if you","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=552s"},{"start_seconds":561,"text":"can get it to fit into that mold it's going to be valid data right you just want to be able to have this contract about the data that your smart contract","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=561s"},{"start_seconds":570,"text":"is dealing with where you know if it fits in this data type if it fits in this struct I've designed this enum I've designed so on and so forth then it will","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=570s"},{"start_seconds":578,"text":"be valid data and as much as possible we want to operate with these really strong guarantees about our data so make invalid States","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=578s"},{"start_seconds":587,"text":"unrepresentable design your data structures in a way to avoid supporting invalid contents next we have one truth have one","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=587s"},{"start_seconds":595,"text":"source of Truth for the data in your smart contract if you have multiple different places where you're storing the same data that can cause some","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=595s"},{"start_seconds":603,"text":"synchronicity issues and I chose this uh illustration of a funnel here to kind of","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=603s"},{"start_seconds":610,"text":"uh illustrate the idea that if you have one source of Truth for your data you can also really tightly control how that","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=610s"},{"start_seconds":619,"text":"data changes right there's only one way to access this data and in order to access it you have to go through all of these different checks all of these","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=619s"},{"start_seconds":627,"text":"different verifications and those are always going to be in sync with each other because well there's only one thing to be in sync","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=627s"},{"start_seconds":634,"text":"with finally test for failure as well of course we want our smart contracts to be correct we want the Happy path to work","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=634s"},{"start_seconds":642,"text":"and that's a really easy thing to test what's not always as intuitive to test is failure we want to make sure that yes","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=642s"},{"start_seconds":650,"text":"our smart contract Works where it's supposed to work but we also want to make sure that it fails where it's supposed to fail so test for failure 2","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=650s"},{"start_seconds":659,"text":"finally uh doing all of that is hard and it is it's really hard it is hard it is","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=659s"},{"start_seconds":666,"text":"hard um so luckily we have a bunch of tools at our disposal to help with this I'm going to particularly call out the","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=666s"},{"start_seconds":674,"text":"programming language rust huge fan anyone who knows me I really like programming in Rust and luckily near protocol is built in Rust and supports","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=674s"},{"start_seconds":682,"text":"it as a first class citizen for smart contract programming so we have this really strong type system that comes with rust algebraic data types fancy","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=682s"},{"start_seconds":690,"text":"enums fancy structs and it makes it so that oh it's a little bit harder at at at first a little steeper uh steeper","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=690s"},{"start_seconds":699,"text":"learning curve to get started with rust but once you get used to it the rust compiler actually becomes like a friend it's helping you to code correctly the","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=699s"},{"start_seconds":708,"text":"second thing we have in Rust is powerful macros if you're someone who might be coming from a little higher level programming background something like","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=708s"},{"start_seconds":716,"text":"JavaScript or python the idea of meta programming or macro might be new to you a macro is basically just code that","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=716s"},{"start_seconds":723,"text":"writes code So Meta programming because we're programming the programming language this is an example of a macro","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=723s"},{"start_seconds":729,"text":"invocation in Rust derive debug there uh kind of highlighted in that bluish green color and it expands to this big long","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=729s"},{"start_seconds":738,"text":"thing and you'll see here it's it's actually taking into account the item that annotate that it was attached to that message struct so it prints out all","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=738s"},{"start_seconds":746,"text":"the fields and it prints out the name of the struct so on and so forth so this is the idea of meta programming my team has taken all these","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=746s"},{"start_seconds":755,"text":"ideas these security Concepts and the powerful tools that rust avails to us and designed a new smart contract","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=755s"},{"start_seconds":762,"text":"Library called near SDK contract tools that provides a bunch of onliners implementing a bunch of different contract standards and not just the NEP","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=762s"},{"start_seconds":771,"text":"standards but other tools as well so you can Implement online multisig wallets you can Implement ownership you can Implement uh role based Access Control","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=771s"},{"start_seconds":780,"text":"uh contract posability there's even a uh more optimized account ID uh utility in there as well and a whole bunch of other","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=780s"},{"start_seconds":788,"text":"stuff that hopefully you will find useful the onliners work just like this so this is kind of your boiler plate that you'll see very often in a near","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=788s"},{"start_seconds":797,"text":"protocol uh smart contract that's built in Rust in order to implement say a fungible token then all you have to do is well import it from the library and","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=797s"},{"start_seconds":806,"text":"then add one single line and you automatically Implement three different contract standards luckily the way this library is designed is you can choose","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=806s"},{"start_seconds":815,"text":"the amount of magic that you want in your smart contract so here there's a lot of magic going on uh you just have the one line and it does a ton of stuff","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=815s"},{"start_seconds":825,"text":"but this smart contract library has layers of magic that you can decide to implement all of the different standards","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=825s"},{"start_seconds":832,"text":"manually and connect them together by yourself or use a little bit of magic here and less magic elsewhere it's very","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=832s"},{"start_seconds":838,"text":"flexible modular it doesn't tie you into uh just this ecosystem it plays very nicely with the other smart contract","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=838s"},{"start_seconds":847,"text":"libraries that are available for near protocol and of course if you want to extend the functionality of this Library","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=847s"},{"start_seconds":853,"text":"there are hooks that make it really easy to say make your fungible token posible and again this is a a high level of","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=853s"},{"start_seconds":861,"text":"magic that you're seeing right here but uh you can kind of choose the amount of magic that you want in your smart contract this is just the highest level","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=861s"},{"start_seconds":870,"text":"for the most concise code all right so that was magic but I hear you you're sitting there you're saying I don't want","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=870s"},{"start_seconds":878,"text":"to have to learn a whole new smart contract library in order to uh you know leverage these uh Primitives that are","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=878s"},{"start_seconds":886,"text":"available in this smart contract Library I just want to get started get off the ground running quickly so my team has","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=886s"},{"start_seconds":894,"text":"also designed another tool that is available on the boss it is is called the contract wizard you can scan the QR","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=894s"},{"start_seconds":901,"text":"code right there to access it or go to new.org and search for contract wizard it'll pull up this user interface and","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=901s"},{"start_seconds":908,"text":"you can right away just generate the code to get you started uh writing a smart contract that implements all of","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=908s"},{"start_seconds":916,"text":"these different standards and takes advantage of the power of the rust programming language and also this smart contract library was designed with all","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=916s"},{"start_seconds":924,"text":"these security considerations in mind as we were writing the library so that is all I have for you today that's the same","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=924s"},{"start_seconds":933,"text":"QR code that was on the previous slide so scan it and start writing your smart contracts on near in Rust thank you very","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=933s"},{"start_seconds":946,"text":"much all right it looks like we have a little bit of time for questions so I would love to take questions from the audience if you have uh anything that","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=946s"},{"start_seconds":955,"text":"you wouldd like me to uh detail a little more","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=955s"},{"start_seconds":964,"text":"yes sorry they're they're bringing your mic uh well it enlarge my wasm","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=964s"},{"start_seconds":971,"text":"file because I my wasm file is really big now your wasm file is really large yeah very large so you want to optimize","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=971s"},{"start_seconds":979,"text":"it yeah so if I use your your tools be larger or it will not be larger because","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=979s"},{"start_seconds":986,"text":"this uh smart contract uh library is composed mostly of macros you will only","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=986s"},{"start_seconds":993,"text":"generate extra code when you actually invoke the macros so just by including the library your smart contract won't be any Baker okay thank you thank","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=993s"},{"start_seconds":1010,"text":"you any other questions","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=1010s"},{"start_seconds":1020,"text":"what what's the next step what's the next step for near SDK contract tools well um one of the things that we're really excited about for oh does this","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=1020s"},{"start_seconds":1028,"text":"back button work I don't think oh there it goes now now it just went really far back okay so um some of the things that","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=1028s"},{"start_seconds":1036,"text":"we are working on for near SDK contract tools is well more standards like the multi multi- token standard that's uh","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=1036s"},{"start_seconds":1044,"text":"next up as well as uh for the contract wizard we have some really high hopes for this because this is really really","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=1044s"},{"start_seconds":1052,"text":"just the start of uh the contract wizard with the relays and the um other fun","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=1052s"},{"start_seconds":1060,"text":"stuff that has been announced at ncon we are hoping to make it so that you can not only generate the code but also","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=1060s"},{"start_seconds":1067,"text":"generate the WM blob and even deploy the smart contract that you generated directly from the boss so those are some","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=1067s"},{"start_seconds":1075,"text":"things that we are looking forward to in the future you have another question over","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=1075s"},{"start_seconds":1084,"text":"here hi will you do the same thing for the soulbound token because it was pretty uh successful with the NDC","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=1084s"},{"start_seconds":1093,"text":"election and yeah I I think reputation will be something on near and uh yeah I would be very glad to see that for","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=1093s"},{"start_seconds":1100,"text":"soulbound token a soulbound tokens so like the idea of an nft that's non-transferable correct right so um we","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=1100s"},{"start_seconds":1108,"text":"have the non-fungible token standards NE NEP 171 and we have the macros that Implement that all for you and if you","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=1108s"},{"start_seconds":1116,"text":"recall here we have different hooks here now you don't you're not restricted to using just say the posible hook you can","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=1116s"},{"start_seconds":1124,"text":"also write your own hook for different uh life cycle methods of the different standards so for example there exists a","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=1124s"},{"start_seconds":1132,"text":"transfer hook for NEP 171 and you can Implement something in there that will make it impossible you know uh say error","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=1132s"},{"start_seconds":1140,"text":"out Panic every time a transfer is attempted so you could make a token that implements the NEP 171 standard but","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=1140s"},{"start_seconds":1148,"text":"disables transfers quite easily MH are there any plans to add uh async","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=1148s"},{"start_seconds":1159,"text":"rust when calling other contracts inside of the uh contract Library","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=1159s"},{"start_seconds":1165,"text":"so uh there is I've been discussing uh some very","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=1165s"},{"start_seconds":1175,"text":"primitive plans uh with some of my co-workers we've been talking about uh","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=1175s"},{"start_seconds":1181,"text":"thinking about adding some async Rust features maybe in this Library maybe in a different Library hasn't really been","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=1181s"},{"start_seconds":1190,"text":"decided yet uh but in particular uh some async Rust features might be coming uh I","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=1190s"},{"start_seconds":1198,"text":"might have uh taken a chunk of time directly after nearon in which I'm going","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=1198s"},{"start_seconds":1205,"text":"to attempt to implement that uh but that's not necessarily a guarantee at this point in time definitely of","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=1205s"},{"start_seconds":1212,"text":"Interest though thank you for the question all right and it looks like","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=1212s"},{"start_seconds":1221,"text":"that is our time right there so thank you everybody for attending and uh use near DK contract","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=1221s"},{"start_seconds":1235,"text":"tools","url":"https://www.youtube.com/watch?v=DDmf6qAHEKs&t=1235s"}],"youtube_url":"https://youtube.com/watch?v=DDmf6qAHEKs","url":"https://near-pedia.xyz/videos/DDmf6qAHEKs"}