# Encode Club NEAR Bootcamp X - DAY 4 21/01/2022
## [Day 4 Recording](https://www.youtube.com/watch?v=suL8kB4Ell8)
---
## Questions:
---
## Is there something special about the account or contract ownership when a contract is deployed and do we need to call it quickly if we are the owner
[Account smart contract link](https://youtu.be/suL8kB4Ell8?t=1010)
No there is nothing special in NEAR. In NEAR we create the account and then deploy a contract to it. As we don't have to deploy a contract if we just open an account and the account can hold NFTs, NEAR tokens, native NEAR tokens and other fungible tokens.
So we can use the account to do whatever we want in the network & also deploy a contract to the account if we want to or use any other account.
In NEAR we make the account and then deploy the contract.
When building using the **near dev deploy** command in NEAR CLI it will create an account in the testnet using timestamp and some random numbers and deploy the contract automatically.
This saves a lot of time during the development process and its just an exception and not a rule.
But if you want it to deploy in a certain account we can just use **near deploy**. This will require you to mention where you would like to deploy the contract by providing a contract account name.
In terms of ownership it's just a piece of data. In few examples mentioned in [Learn-NEAR](https://github.com/Learn-NEAR) there are cases where only an owner is allowed to call the contract.
There is a way to initializing the contract with a method call which sets the owner and then this owner becomes the owner during the life for this contract.
---
## Can I initialize a contract that doesn't have an init method inside of it. So is init method important for the smart contract?
[Initializing a contract without init](https://youtu.be/suL8kB4Ell8?t=1199)
In rust contracts we must have a method which is an init method tagged without a knit macro. Alternatively, you can have a method named new on the contract as per the rust sdk.
With the assembly script sdk the constructor becomes the init method for the contract in the singleton pattern and with the simple pattern in assembly script it's just a bag of functions there's no real init function.
So, it completely depends on which sdk we are using for our development.
---
## In an assembly script contract can we change the value initialized when the contract is created for the first time?
Yes, we can change the values.
To change the data of the contract just expose it via method. Think of the contract methods as the API for the storage.
So, if you have a piece of data that you initialize with your contract and you want to edit it throughout the life of the contract you need to give some method to be able to overwrite that data.
---
## In assembly script when I deploy a contract on testnet can I use my existing account? And if I delete that contract to stop testing & create another account will it be different from the concept of contract account ownership
A contract belongs to an account but near is structured around the account model.
Accounts live on one and only one chart the account has its data.
The data of an account includes things like keys that are registered on the account whether the contract is deployed or not.
There's contract binary code and the storage that's on the account pending receipts that are yet to be executed.
If you need more details about account data structure you can refer the nomicon.
---
## An account can have different accounts on that is that correct?
An account can have sub accounts if you think of it like domain names.
Actually testnet is an account with a contract on it and when you make a testnet account what you're doing is calling a contract on the account called testnet which has a link drop a contract on it and it creates a sub account for you like abc.testnet. Same thing with abc.near in mainnet.
We could have top level domains like abc.com or abc.biz or abc.help. As it's just a matter of agreeing with those top-level accounts. To create a top-level account on the network we need one of the genesis accounts.
---
## Generally, we create a random number using the oracle VRF contracts. In NEAR if we use import rng as per the near sdks will it suffice to generate a random number.
Random number generation in an environment like this is not an easy problem to solve.
Here's the reference code for the random number generation in the lottery

If you're talking about truly random or pseudo-random or whatever it is there's some there's some more to discuss there's basically one bit of influence
that can be put on the problem by validators that a validator can basically decide not to publish a block if the randomness is not suitable for them.
So that's something that you can't really avoid in this case unless you do a particular pattern.
For example: If your contract wakes up your function wakes up because you're calling the method it sort of wakes up inside the virtual machine and it's got 200 milliseconds to
live to do its work. And it reaches out into the runtime and asks for the random seed. The random seed was placed there by the machine that the blockchain is running on whatever
node that's doing the validation. This random seed is put into one of the slots by the virtual machine. So your contract can go and grab this random seed environment.
Random seed it's called that one of the registers so you can go and get that random seed and then do a little bit of math on it to generate some random number of the right size
it's coming from the environment where the contract is running.
But the problem is once your code is finished running before the validator publishes the block, they see the outcome of what has happened they could look at it and just say I don't want to & this is not working in my favour so I'm not going to talk about it & I'm not going to publish it.
So, the way to fix that is to get the random number through a cross-contract call and have it come in some future block back into your function to be applied. So, at that point it's too late for the validator to make that decision because the function has already been scheduled to execute so they've already published the block that says this cross-contract call has been made
and now when it comes back it's going to come back with whatever the random number is, and they can't stop it. So, this is the way to remove that bit of influence they have in the smart contract.
There is also a reference video on the same topic: https://www.youtube.com/watch?v=0-jCWp2-aMw
---
## Are the NEAR wallet private keys unique or will they keep generating new keys as we clear the local storage/login to different systems with the seed phrase.
I think that the seed phrase is used to generate a new private key pair a public private key pair that's added to your account as a full access key.
But in order to add another key to your account it needs a full access key. So this phrase must represent an existing full access key on your account.
For example:
If you pick a key phrase with a new secret phrase with a new account that you just created and you make it to the wallet and then you type near keys your account
you'll find two full access keys registered on your account at that point. One of them one of them will be in the near wallet local storage. The private key will be there
and one of them will be tied to the seed phrase. So, if you clear your storage and you lose the full access key that's there you still have the full access key on your account
that's related to the seed phrase. With the seed phrase we can then recover the account whether it's the email link/mobile/seed phrase this will generate and be the full access key to
add a new key a third key to your account and put that in your wallet.
windows specific stuff
---
## When I go for staking and pick a validator who has different fees what is it that I will get back after certain hours? Is it interest or tokens?
You can visit NEAR Staking site to get more details on this topic https://near-staking.com/
The way these networks work is that there is some clock which is ticking that pays people to keep it ticking that tracks history with data in there.
Proof of Work(PoW) and Proof of Stake(PoS) are two different consensus algorithms which is some rules for how you to agree on what actually happened and then to finalize transactions.
You get to finality which means that history cannot be changed anymore it's fixed. It's a little debatable but the idea is it gets kind of fixed into a permanent record by one of
these consensus algorithms.
So in Proof of Work the way that it works is basically for each tick to make the clock tick you need to run a program to solve a mathematical puzzle and this is called proof of work.
Here's a video explaining the ticking process where you can learn more about Proof of work in detail: https://www.youtube.com/watch?v=bBC-nXj3Ng4
---
## What does it mean to delegate money in POS? Is it safe to delegate money
It has its risks for sure as we're just trusting the software in the end. The smart contract of the staking pool contract can be read and checked if the contract has any risks associated with it or not.
There is also a risk of the validators contract getting compromised and if one got compromised all of the validators contracts are then compromised as it's the same contract.
You can check out this YouTube video if you want to get more details: [NEAR Live Contract Review](https://www.youtube.com/watch?v=BA7VeUS_RAA&list=PL9tzQn_TEuFXnYksuNJwrl1l_AuWzn6eF)
---
## Does NEAR have a library of standards like Ethereum does for certain tokens like the ERC20 or ERC721 like OpenZeppelin.
We have standards published in the [Nomicon](https://nomicon.io/Standards/).
---
## What are the different NFT standards and what's the function of a NFT standard?
NFT is just a word. There's an ID in the key called ID Number one & this is NFT Number one and then the value has your name,the word hello.
As of now you own the word hello but as far as this contract is concerned ID number two is Ben's name and maybe Ben owns the word goodbye
For example:
I own Hello the NFT and Ben owns goodbye the NFT so now the question is how do we transact with these things.
Well we need to have a method that allows me to transfer, buy & sell whatever it is. So what's the standard does is it reduces the
methods to just the bare minimum mint, transfer and allow someone else to transfer for you.
These contracts can be made to talk to each other because of the standards like ERC 721 & every marketplace online &
every software developer knows exactly what methods to expect on any NFT that follows this ERC 721 standard.
---
## What's the flow of the app files & what happens when we run the arm command in a project?
There are lots of examples & lots of videos in near.university where we've actually captured all of the steps of going to the project in which you can play and watch.
---
## Is there any interesting or popular projects in NEAR that you like personally so far like AVE?
Yes checkout awesomeawesomeneer.com you can find all the projects available on NEAR ecosystem there.
Coming to my favorite projects that i've been a fan of since it came. It's a music one by Solemson the project's name is WebAssembly music. In this project if you open what you'll find is basically an exploration of Peter Sollemson with a Video Intro where he's capturing songs on-chain and then playing them through some client.
Similarly I really enjoyed this sample art demo that was built by Yasing. He's gone and turned this into a full design system called cura.run for actually creating your own art. He started with NEAR Certified Developer in last summer I think and he took this project and then made the sample art demo. It basically creates a kind of 2D Art with some little pieces of colored unicode characters Red, Blue, Green.
He's matured that project now with a couple of grants and some support into this cura.run project that you can use to go and actually create your own generative art algorithmic art. It's fantastic for me as this is a great success story
of somebody who started by learning built something a project.
---
## Is using WEB3 storage to store alerts on a large amount of data a good idea?
On NEAR storage is expensive as with any layer one. But you're not burning the money as you're doing storage staking you're locking the
money in the account at a rate of 10/Year/MB.
But you could put your storage in some other places like
* [IPFS](https://ipfs.io/)
* [Sia Skynet](https://siasky.net/)
* [Arweave](https://arweave.org/)
These are the few decentralized storage providers.You can go and explore these projects and it's all pretty much the same thing as you're basically taking your data and passing it through their system. They put it somewhere somehow & whatever their deal is and they give you back some unique identifier that you can use it to get that data back and then that little piece of the identifier
you put that on the blockchain.
---
## In Rust why are the contracts built as libraries and not binaries?
The library structure in Rust is something which is lightweight & doesn't include the sort of execution harness. If you compile for a particular architecture it's going to include whatever it needs to kind of stand itself up in the computer's memory. But the library is really plugging into a lightweight Virtual Machine(VM) this run time so that we don't need all of that machine memory. So it just makes for a smaller binary would be my guess and it gives us a little bit more control over some of the details like we have our own Recommended Allocator. We've brought that in from open source as well. So there's some things that you can tune in the contract as a library.
---
## What is mutated state decorator?
In the singleton style in Assembly Script contracts the mutate state basically says that this method will change the state of the contract. At the beginning of the method it puts a little bit of extra code in there when you compile it to load the state of the contract. Then you do whatever you modify and then it writes the state of the contract back to storage at the end of the method. That's what Mutate state does. It kind of gives you that little bit of convenience only in the singleton styles.
---
## I have experience with low level languages such as C++ as well as Solidity & some JavaScript. So which one do you suggest to start with Rust, Solidity or Assembly Script?
If you are comfortable with C++ you can think of Rust as C++.
Assembly Script is the best language if you want to learn this technology but if you're planning to create some financial applications handling huge amounts of money then RUST is the language to use.
---
###### tags: `bootcamp transcripts`