Skip to content
by Unity Nodes
NEAR Protocol

NEAR Blockchain Concepts (4/6) -- Accounts

about 50:43 long

Nothing is loaded from YouTube until you press play, and then without tracking cookies.

About this video

In this episode of NEAR Blockchain Concepts, we go over the accounts model in NEAR Protocol.

We will cover the accounts naming, implicit accounts, accounts creation, sub-accounts, seed-phrase, public and private keys, and CLI tools.

Speaker: Vlad Frolov, Engineering Manager of Public Interfaces Team at NEAR

Useful links: NEAR Block Explorer - explorer.near.org NEAR CLI - https://docs.near.org/docs/tools/near... Experimental NEAR CLI in Rust - github.com/FroVolod/near-cli JSON RPC APIs documentation - docs.near.org/docs/api/rpc Learn more about Accounts - https://docs.near.org/docs/concepts/a... Learn more about various types of keys in NEAR Protocol - https://docs.near.org/docs/validator/... Reference-level documentation on Accounts - https://nomicon.io/DataStructures/Acc...

Follow the latest from NEAR Protocol on: Website: near.org Discord: near.chat Blog: near.org/blog Twitter:   / nearprotocol   GitHub: github.com/near github.com/nearprotocol #Blockchain #FutureIsNEAR #NEAR #nearprotocol

Transcript

5,459 words

Captions as YouTube publishes them, usually machine-generated, so product and people names can be misheard.

  1. 0:07

    so let me again start with uh near explorer and as usual um so we covered um epochs blocks uh transactions uh chunks transactions execution outcomes and on the previous calls and today we're going to talk about accounts which are not very well represented on explorer yet so you can see some useful info but it's still not um i would say feature complete in order to on to clearly understand the picture here but it provides just bare minimum and i will cover

  2. 0:59

    the rest of the things you will not see them right here but we'll use imagination a bit uh to understand the details so basically what we want to where we want to start that account on here is a human readable thing um you just have a name and we use this uh schema of having um domain like kindle domains and subdomains um register um way to operate with with with naming so the first thing you you will notice on main net that there is almost all the accounts have this dot near

  3. 1:44

    uh suffix and uh only after like and before it there is some human readable name i just open the random account i'll also go to my own just in a moment and what i want us to know about account system is that uh there are a few different types of names sorry but is it so noisy for me or it's fine fine um so accounts as i said follow the same domain name schema so only the owner of dot org can register and

  4. 2:36

    near the torque or or qq.org or whatever the torque and only near the torque can register explore that near the door so that org cannot register explored near the torque and near the torque cannot register qq and the torque so that's um that's a the same follows on here as well however there are so called implicit accounts let me see if i can find any um maybe i'll need to i can for my yeah boy thank you can you please help me with this um so any implicit account

  5. 3:28

    and there is also um um validation process for account name which also allows you to create accounts that are longer than 64 characters so if your account name is longer than that thanks olga this is included account it should be more this one as well um explorer is rather slow these days to figure out so you can see this is quite a long name and there is no dot near prefix suffix we will talk about them a little bit later um this is another example

  6. 4:20

    and you can see there are a bunch of different uh actions uh and transactions on behalf of that account so we don't have a human readable name here uh while we have it here and we also have accounts which has more than 64 um characters along and they could be created without near suffix those are three different uh valid account names what's important is that to create an account on here usually you need to submit

  7. 5:05

    a transaction to create an account like this one i created a dot for all that mirror at some point so let's open this up this is a transaction signed by my account to a dot near a dot for all that near account and the actions are the following uh i it's a create account by by default like that you you can't like the account that you are creating is the one that transaction is signed for so the receiver is the account that will be created

  8. 5:45

    um you also need to fund the account uh because when we store information about the account on chain and it requires some storage and and we need to lock some tokens to cover the costs of storing that info and also i need to uh submit an a full access key uh or like well it's it's some like sometimes you can get away with other type with function access key but let's focus on the

  9. 6:22

    simple case usually just use a full access key so that account can have control over itself like i can once i create that account i cannot delete it i cannot transfer tokens from it it's not controlled by for all.near it's now a completely separate independent account and if we do not specify any function key that account will just be left on the blockchain forever and you will nobody will be able to remove it because there is no um

  10. 7:08

    no access key that can sign a transaction uh which would have a delivery account action that's why so most of the time to create an account you usually need to specify these three actions create account transfer some tokens to cover the storage and uh specify the function key for the the the full x key there are some exceptions but overall that's the case um how do you create the sub account

  11. 7:40

    uh it's there are different types of tools essentially what at the end what you want is to submit a transaction like this one to help you with it you can use near cli i believe wallet can do that as well but while it will do it slightly different in a slightly different way so yeah basically near create account where near is near cli um is what you want to see and try to use from if you want to go see a live way

  12. 8:21

    logan you want to set something yeah i want to find the reference but yesterday stefano has shared link on the staging where you can get like a new account without additionally funding it like i guess it wasn't in general uh yeah probably like i mean uh like you need to fund it but uh this information might be outdated because there is well at the end of the day you still need to fund it for near protocol side

  13. 8:57

    uh wallet indeed ex explores the way how to lower the beta for entrance so we don't require people to um to get some upfront uh costs and uh getting around to actually like buying the first person someone can start like creating stupid account names uh getting there some initial amount then transfer this amount to single account and become a billionaire for example uh well indeed it's a it's a it there is a problem why we didn't want to allow it this way in the first place

  14. 9:43

    because on testnet it is fine we it is a regular flow will follow uh on for tested accounts because test net tokens are uh not worse of anything and that's why when you create an account on testnet it's it's easy it's you get your uh 500 account of 500 near tokens on testnet for free and you can ex like play around with them uh but on mainnet you you immediately bump into the issue that you cannot even create an account without paying the money so that's why

  15. 10:23

    the team is working on trying to come up with some clever ideas how we can eliminate the the necessity to um pay upfront costs uh i'm not sure how exactly like it's it's highly experimental uh it's uh it is just okay if we actually interested in uh these questions provided the additional information like uh on the web wallet uh minimum balance on the web wallet is 0.35 and this contract will give

  16. 11:04

    0.05 and like you can't even delete account and transfer this funds this is a contract by vlad's by valgrina so essentially when you fund your account with an additional amount this uh 0.05 will be taken away like taken back so yeah okay there is some protection how exactly it works uh because i'm i'm trying to cover uh here the near protocol implement like design and those uh different applications built on top of that is just a clever combination of

  17. 11:46

    different uh possibilities that uh yeah near protocol provides us okay sorry the basics the basic thing is that you uh to initiate the creation of an account you need an account on mere protocol in the first place so as you may have already uh considered near should be an account and it is the case so near is a regular account which was created in genesis so genesis i just want to remind us that it's an initial um

  18. 12:27

    list of records that are that the network starts with and in that genesis there is account here with some amount of tokens and there is a contract so you can as you can see it was created in genesis uh it has some amount of tokens it doesn't really need much um and it uh it it it has quite a lot of traffic and going through it to essentially create accounts and also like where is different types of uh usage goes through this contract that is deployed to near

  19. 13:07

    account um so just to um let's probably not dive into it like ask a curious question like if for example uh near is an account so it is basically a contract which can create another uh accounts does it actually like mean that uh this account must uh store somewhere in his state which names are free like i mean not free but like which one is actually settled and not available anymore no it doesn't need to record that

  20. 13:52

    it will just try to submit a transaction to create an account and the the transaction will just fail okay so if i understand correct so uh the uh account system of protocol is actually already for this type of account but uh like i'm trying to ask that if we are like any our account is and some sub account of near does it mean we actually don't uh like our account doesn't belong to us

  21. 14:30

    in that case because when i created account a dot near it's not under my control it's like it's it's under control of this uh under this uh access key only this access key can do like actions on on this account through cannot remove sign transactions on behalf of ae dot roll dot here and for for all that near can't remove a that's build it yeah nope so the only the only purpose of the

  22. 15:15

    parent account is to create to initiate this creation after that it has no connect connection to the given name you might say yeah okay so the actually uh previously when when the network just started any account could create any other account and the reason for like for this was to just you need to sign the transaction somehow i need to you need to fund the new account that was the main reason and after that uh we realized well

  23. 15:48

    if a fraud account can create uh let's say root account or like near account on the network uh it would create a lot of um problems and scoring on the name inside and that's why we uh try to change the schema to uh to only allow subaccounts to be created by by the account actually fraud can create a new account which has 64 uh plus characters long in the name so it will not have a fraud near them uh s4 uh

  24. 16:32

    like root level accounts like is it possible to create them without the genesis involved in that process so currently on on main like i i mean short one just like what was the case on testnet uh and if you open testnet but the answer is but only foundation can create them yeah the short answer is that foundation can create them uh let's see well it will be hard it's probably hard to find but on test that you have a bunch somehow centralize this decision

  25. 17:14

    no there's gonna be an auction for them so like in the future you'll be able to buy them from foundation through an auction uh like dns you buy from somebody yeah it's a it's a government governance question the implementation detailed that currently only uh foundation has the access key that is allowed to create new uh top-level accounts as far as understood okay thank you and that's that's why we have recently created

  26. 17:51

    uh aurora account on mainnet specifically for our project as you can see there is register account which submitted this transaction where the receiver was aurora name and they it was funded with 0.1 here and it it gave the error account this account this access key and after that aurora is completely independent account register can not do anything with aurora you cannot remove it that's why i i want to emphasize it once again

  27. 18:38

    if you do not specify access key the account will remain forever if uh if you provided enough near tokens to fund the initial storage um yep so basically in the future yes uh register account will be somehow used to uh it will be involved in this governance of creating top level accounts on behalf of foundation with some auction thanks cindy different types of account i want to talk us through is this uh well this is not a good example

  28. 19:28

    let's let's take this one as an example this account has 64 characters i believe so let me check yep and what exactly is that is it's a uh hex representation 60 16 uh well base 16 representation of bytes of the public key that is generated offline so basically you can create an account on mir without that create account action as you can see this account has only been involved with two

  29. 20:26

    uh transfers so there are only two transactions uh on this account both are transfer and it and they succeeded usually if you try to send to transfer tokens to the account that does not exist you will see that the transaction fails but this one succeeded and it's uh specifically due to the fact that if uh near protocol receives the transaction well the receipt uh let's be uh more like accurate than this if we have a receipt where the receiver is

  30. 21:07

    64 characters long and it's hex encoded we assume it is a public key uh full access full access key to to this account and transfer is the only thing that we need if we compare to where is it when we created when we created an account ah this one so when i wanted to create an account 80. near i needed to explicitly state i want to create an account if such account already exists this will fail and transaction will not go through uh i also need to transfer tokens to

  31. 22:02

    to bait the storage and i need to specify the access full access key if we compare it to implicit accounts when one is sent to this when transfer is sent to this uh loan name account we already have the funding so this part is covered we already have the name it's like it's fine and we already have the access key that that is encoded in the account name so essentially if you have

  32. 22:44

    if you generate access key pair with a public and secret key you can encode your public key in base64 oh in in in hex and that will be the account that you can use on mir it will not have any record on the blockchain itself but you can already send somebody this hex representation and they can transfer tokens to so let me show because i feel like it's not easy to comprehend i have my cli project over here

  33. 23:38

    i hope it will run just fine i haven't tested it beforehand sorry for live demos while we are waiting but could you please send the link to the explorer with this simplicity account that was not created if you believe to explore i want to play with it one sec this one thank you well it was created and according to explorer it was cree and not oh it was the wrong link sorry about it let me

  34. 24:35

    come on a bit lost here uh yeah this one as you can see it was created on may 14th so today essentially just half an hour ago um so indexer for explorer is aware of this thing and such transfer is implicit um is implicitly is implicitly handled as um create like creation of the account because we know that the specs face so we have an issue about it i will handle it yeah we have

  35. 25:30

    some misalignment but overall it's uh it is there uh so on the um on the near cli i have uh at access key i want to add an implicit account to do that they just need to generate a key pair uh that's that's all they i need uh i haven't specified any uh so it's it's there is no record of this account on any network not on testnet or not on minute uh let me open this uh near credentials default

  36. 26:25

    file this is safe to display it here because there is no such account on any network um well this tool is similar to that that near cli for gs can also generate with the we just once uh different well it was one difference actually i want to compare for us if you have ever tried near cli for uh the official one implementing js uh you could have you could have such file here uh in in your folder like dot near credentials

  37. 27:24

    default and your name and i use testnet for for the example so we have account id here we have public key here and private key so the only difference with my tool over here that it also provides you with this money monic that you can use on wallet um a seed phrase it's also called which is essentially a way to a human readable way to produce uh this key pair so it's um it's a seed like a random seed if you are familiar with

  38. 28:13

    that concept more closely from which the algorithm will start the generation of the key pair and if we specify the same initial state then we will receive the same public key and private key again and again so this is the the concept of how seed phrase is used you cannot generate seed phrase from public key and and private key once you have it so i cannot recover uh the the the seed phrase from this information anymore

  39. 28:51

    it the the order is the following you generate the seed phrase and then from it you generate the the public key and private key and what i want us to look at is that account id so the tool just generated this json file that's all it did and as you can see there is some account id in place i didn't enter any account name but it is there and let's use some tooling here actually now i will

  40. 29:30

    use my public key so this uh this thing is a base 58 encoded string of bytes so let's try if what we will get if we go from base 58 to hex we enter that public key and you can notice that c234 cd is exactly what the account name is so when i generated this public key and private key pair and then converted this base64 to hex base 58 to x to hex i received this account name that i can use

  41. 30:27

    what this means is that now if i give this account id to somebody and they use yeah and i need to prove that there is no such an account so i just enter it into search there is no account on the network um like it does not exist at all but if i send let's say one year to this account everything is fine i go i want to go to all the near

  42. 31:31

    it here i see that i transferred tokens one one year to this account and it succeeded and now if i open this account it's indeed there let's uh let's repeat this exercise the the search i didn't change anything here i'll just hit enter boom the account is there i did not create it explicitly that that's why the name is implicit account so this is an implicit account it has only one transaction and for all cannot troll the near cannot control this

  43. 32:10

    account only the account uh on only the folder of the corresponding private key to this um public key is able to send any transactions so let's give it a try sorry for using my uh experimental tooling but i find it a bit easier to um to show especially when you just want to construct a a transaction so it's a nice uh questionnaire here it asks various questions whether to keep it

  44. 32:56

    simple or whatever you go to mainnet because i signed the tokens i could actually send the tokens and test that i i really forgot that they could do it and it would be much easier to handle so the account the sending the transaction is now this new account over here so i will send a transaction from it uh the receiver will be also the same account so i basically want to remove the account right now so to do that i

  45. 33:35

    i just want to send transaction to itself uh and given that they have a full access key to do that i can do it uh i want to add a new action i want to delete an account and the beneficiary would be folded here so the account that will receive the remaining fonts but i don't want to add anything else and i want to use well let's let's keep it simple i will like explicitly put it here

  46. 34:13

    public key is this one and private key is this one oops the good thing it does validation for you huh um that's a bit unexpected weird probably hit the bug and let's uh let's not do the uh that thing let's do something transfer the account no not the account name

  47. 35:16

    account name account name and may not from this account name to folder here i want to transfer 0.5 tokens 0.5 near nothing else private key all public key is this one it's totally weird something is completely broken let's try this one where's the account 84 sender

  48. 36:21

    um maybe just keychains will essentially read the file um okay let's conclude that this tool is really uh broken at this point time sorry about that um probably probably had an outdated version of it um what we can do we can always use the regular tool mirror main net and we do near transfer what do we need to specify i guess there is no transfer um why are you taking someone

  49. 37:25

    um it is sent is it yes and send the receiver in the mount send where sender is this receiver that the amount is 3.5 i have no clue amount in which let's let's give it a try um cannot sign transaction for account only the network main no matching key player found i mean jeez um one of them was a heart if you haven't prepared very well

  50. 38:26

    we need to copy it from um that's that once more okay finally we can go to following the list the link and you see that indeed this account was able to create the transaction signed by that account received by this account 0.5 near tokens so the current balance of this account is less than zero five because we paid for some piece when we sent we did this transfer um i guess that's

  51. 39:28

    uh all about accounts as of right now i don't want us to jump into function calls just yet because it will require another hour i guess to talk through and we'll also cover access keys and specifically function uh function call access keys once we cover the function calls themselves do we have any questions so far no thank you yeah you're welcome hope it was somewhat useful well um what should we gonna build next like contract developer development or or something else like

  52. 40:34

    it's kind of hard to explain function calls without explaining how to deploy a contract and what it is yeah probably to do that i will just link us to certain uh materials that we already have the devex team already created a lot of tutorials on how to develop contracts in rust and assembly script and we have a lot of examples to play with so um i will give you some pointers and we'll briefly cover the topic i i don't want us to jump into

  53. 41:13

    like full-blown development during these calls because we already have you know materials in my opinion yeah we we can like plants somehow like um like from in my opinion uh our team is uh like public not interfaces we should know how to create a contract and uh what was going on there so just to understand what the pain points might be for the developers because we actually this uh last break between developers and in your core

  54. 41:57

    itself and it would be great uh so i i can propose like uh everyone to look at the examples till the next time for example or maybe the time after the next time uh just like to familiarize ourselves and uh for example to discuss some questions things pinpoints and stuff about the contract like development i mean and then we can decide if we need to go back yeah i have a question uh so like um when we add this access key for example

  55. 42:39

    if you log into an application it automatically gives you the the access key of that application when you log in with wallet like how is that managed like how do you store this access key like what what permissions can you give to an access key that's like unclear to me because like it seems to me that every app has a different access key and every access key has like a set of permissions you can do uh the full access key is understand like understandable to me what i don't

  56. 43:10

    understand is like the specifics of different uh keys and um how are they managed also here it is okay there is key management actually he gave a talk okay near accounts and key management yeah that's the part which i want to know more so i'm going to watch this video yeah it will be the best if we leverage like the the the videos that we already have yeah super nice i watched all the ones from afghani

  57. 43:49

    but i haven't watched these ones or from like okay we also used to have some other place i guess this one yeah where is keys uh in in the system um yeah these are wrong no yeah all these ones i know yeah these are not where i want this one is uh account keys okay i'm gonna look it up how how it works because like that's the part which is kind of uh the most confusing to me uh not confusing but the part i know

  58. 44:32

    least about oh okay okay thank you for for doing this like this uh explain some stuff to me which i didn't know um yeah perfect uh we have a lot of new people on the team and i feel like we had missing gaps here and there even with people who already even for all people it is a gap actually like it's kind of complicated stuff so yeah it's not that easy it's it's somewhat easy when you follow it up and like

  59. 45:12

    have this walkthrough as i did but i i feel like that um our material uh are not uh uh sometimes discoverable very well as just we like realized i i knew that we had some dogs but sandy didn't um so it's uh we we need to promote more on like when we create such materials yeah i know there's dogs but like sometimes i have um yeah like some of the dogs are very good some of the dogs are like in progress so like i just didn't uh

  60. 45:51

    yeah yeah it's it's actually a good point when you i guess it would be beneficial for everybody to uh subscribe on the near dogs and follow the pull requests at least like what's headed there it probably as of right now at this stage it is the best thing to do because uh like we had a lot of new tutorials uh there like bogdan has fixed indexer tutorial recently and we constantly update the docs and clarify them

  61. 46:32

    uh olga it has also been a major contributor to our docs lately to improve information about lock-ups so definitely a lot of improvements all around yeah docs has more than like 70 open issues and like if you found power to contribute it would be much appreciated george is very uh helpful uh in this matter so like if you at least start you or you want to to help and contribute just think george joshua in the slack

  62. 47:18

    because of aurora launch so once that is out of the door he he said that he would have more time to work on other topics but overall yeah i i saw how he improved and helped borden and with the indexer tutorial like how to restructure it for more readability and you can also like review uh certain pull requests and help to clarify the questions that you're not clear even after reading the like proposed pull requests as an example so i encourage everybody to at least

  63. 47:56

    have a look over there all right let's uh we're ready run out of time sorry for being late again and i hope um i guess next time we will just go i i i think we'll go this way of q a essentially so i want you to just collect a list of random questions about whatever in here i can system i do not promise i will answer all them but at least we'll uncover certain pieces and specifically contract development let's let's give it a try so

  64. 48:45

    i just go to examples or actually uh i find this near-death link quite easy to remember which navigates to examples.near. uh you can play with some uh assembly script based contracts or rust-based contracts uh some of them are complicated i don't believe we have uh some markers about that uh counter is simple guestbook is simple yes book is more preferable because counter doesn't take any arguments and like

  65. 49:25

    it is considered too easy so yeah do we have a guest book in rust i don't believe so russ status message probably is uh also quite simple to comprehend um so guest book and status message uh like good examples you can start with counter if you feel like uh uh totally lost to just learn the very basic entry points and there is counter example in assembly script and in rust so at least let's start from there and

  66. 50:08

    let's collect your feedback was it simple was it clear uh was was it smooth experience to get get up and running was most experienced to understand where to go next because it seems like sometimes i like i fail exactly right there like okay it works it's already created for me it's it's fine but the next step is to total and clear to me so give it a try let me know that goes so next week i don't think we'll have

  67. 50:43

    any like uh lecture or what what not just q a we may even keep it short and sandy will be out of office as far as remember right sandy uh i will but i will join for this call but all the other calls i wanna reject okay uh thank you everybody see you around thank you bye thank you you