New Ethereum talks, every Monday. The week's conference uploads by event, in your inbox.

Loading player…

NEAR NFTs Workshop in Rust - Ben Kurrek

Ethereum DenverSun, Oct 9, 2022, 12:00 AM

Transcript

my name is ben kurick i'm a developer relations engineer here at near protocol and i'm also the co-founder of fair which hopefully you'll hear a little bit more about in the coming months and so today i'm going to be talking about nft zone near specifically built in rust so i'm going to go through um some i'm going to go through a little bit about near their access key model their account model smart contracts minting an nft having it show up in the wallet and then some cool upcoming projects um so i guess let's just get started so a little brief intro about myself i've been working at nir for a couple months now i'm one of their nft experts and i've been really involved in nfts for the past year and so a little bit about nier and their access key model which is pretty cool so near actually has two types of what's called access keys they have a function call access key which allows you to call specific methods on specific smart contracts right and so this is what's used to sign into dapps they have limited permissions so you can't transfer funds it's only for calling specific methods on a specific smart contract right so for example you could have a smart contract with a method buy and you're only allowed to call that one method on that smart contract with that access key and then the second type of access key on here is what's called a full access key and so these are these should be protected right so you can delete your account you can transfer funds you can deploy contracts you basically can do anything with a with a full access key and you can also use these to create what's called sub accounts which i'll get into now so what is a sub account so on near account ids are actually named so you can have the account benji.near for example which is pretty cool and benji.near could make what's called a sub account so if you had benji.near you could make the account buyer.benji.

near or artist.benji and you could keep chaining this so you could have like buyer.benji.fair.near for example and these sub accounts are completely separate accounts and so the root account benji.

near does not have any specific access uh or any it's a completely separate account it might as well be bob.near for example it's just a cool way to organize your accounts and to have some cool organization to your projects which is pretty neat um and so let's mint so i've got in front of me a example smart contract and so it's it's built in rust and so you've got you've got basically all the standards that are implemented on here so the approval standard the enumeration standard event standard it's got the metadata standard minting nft core and royalties and let's go ahead and let's build it so to build it we're just going to compile it to wasom right and so this is going to create in here i've got two awesome files my main.wassum and mymarket.wasm the market contract this is all in one repo but we're only we're only going to care about the main.wasm for this and so now what we're going to do is we're actually going to go and create an account on near so let's go to wallet.

testnet.nerd.org and let's create an account so we'll call this eth denver testing two for example let's reserve the account id let's get secure passphrase this is all on testnet by the way so feel free to take these to take this passphrase and steal this account if you want i'll put this here my eighth is one it's creating the account also i'm hot spotting so the wi-fi not be might not be amazing uh but here we go so now we've got my account ethdenver testing2.testnet and i you can see here i've got no collectables i've got a balance of about two thousand dollars which is about 200 near so let's go ahead and let's log in to that account so we'll just run a near login this is going to redirect me to the near wallet and it's going to request full access right so this allows me again to deploy contract to transfer funds it allows me to do anything so what this is going to do is going to store this full access key on my machine so i'm going to connect i'm going to put eth denver testing 2 dot testnet and then this is going to store again this is going to store this key on my local machine boom so now i've successfully stored this here and so what i'm gonna do is i'm gonna deploy my wasom file so the first thing i'm gonna do is i'm just gonna for for ease of development i'm gonna export an environment variable and this is youth denver testing 2. testing and then i've written this handy-dandy tutorial that anyone can go and look at on the docs it's a zero-to-hero nft tutorial which goes through uh from the basics a complete guide of building a smart contract based off of skeleton code and so what i'm going to do here is i'm just going to steal this code snip it up here and i'm going to actually first i'm going to deploy the contract so we'll do near deploy the path to my awesome and then my account id and so what this is going to do is it's going to deploy that wasm to my account and it'll show up in the explorer so if i go to this link over here this is the near explorer and it'll show basically all transactions and you'll see here that i deployed a contract right and it costs about two tera gas now that the contracts deployed i can go ahead and actually initialize it so i'll call this method here which is going to initialize it with a set of default metadata and then once that's deployed you can again look at the transaction if you want and you'll see that you know i called the method new default meta in my contract passed in this owner and so now this contract is live anyone can interact with it and what i'm going to do is i'm going to for example query for the metadata that i just that i just initialized the contract with so i'll call my contract nft contract id and i will quarry for its metadata and there you go it's got the spec it's got the name it's got the symbol icon base uri this is just default metadata for the purpose of this presentation but you can tailor this to however you want and now let's actually go and list mint in nft so i'll go back to my tutorial here and i will call this method here which is basically just going to mint an nft with a token id token one with some metadata uh with the receiver id being myself and so i'm going to mint this token to myself and then if i go back to my collectibles tab it should show up basically immediately and i now own this nft once this transaction is done there you go so we'll go back to the near wallet go to the collectibles tab and there you go we've got my nft token right there super fast super awesome and uh and yeah so you can do a lot of really cool things with this you can query for a bunch of different enumeration methods so i could view for example all the nfts on the contract so nft tokens and this will return information so this was the token id that i just minted right and it's lightning fast uh i minted it in about you know 10 seconds and it showed up in the wallet um and uh and yeah the the specs on near the standards are all outlined in uh this this handy-dandy place called nomicon and so this contains all of the standards for fungible tokens non-fungible tokens so it contains the approval management standard the core standard the enumeration standard the event standard metadata and a payout mechanic for marketplaces so the approval management standard basically allows you to approve someone to transfer a token on your behalf the core standard is just for transferring nfts so you as an owner can mint a token to yourself or to someone else and they can then go transfer it to a different wallet right and then there's the new enumeration standard which i just showed on the cli where you can query for page paginated information about nfts there's also the event standard and so that's actually how the near wallet was able to to know that my nft was minted to me is because if you look at the explorer link so let's go back here and let's go to this account so you can see all of the transactions and let's go to the nft mint transaction and these are the arguments that were passed in this is the execution plan so this is what happened basically on the smart contract and you'll see right over here there's what's called an event json and that's what is uh it's indexed by our indexers and stored in a database and it says here you know that the event was for any p171 which is our nft standard it showed the version of the standard the event so in this case i called an nft mint and it shows the data so the owner of the nft that was minted and the token id that was minted right and all of this can be viewed in the explorer and and yeah so that is a really really quick way to mint nfts on the near blockchain if you have any questions let me know thanks guys [Applause] cool

Automatic transcript — names and jargon may be misspelled.