Hi @Nev
Thanks for reaching out. Can you specify the time in the video this was mentioned?
@Taha right around minute 4ā¦
My understanding (super limited might I add) is that computer reads code top to bottom and when I was learning about JS we would write function first, then call it later (lines underneath it). However in this video, while we did create function first, the calling of the action came on the lines above the function itself and I just want to understand why that is and whether that is how solidity works in contrast to JS.
@Nev
JS (apart from Nodejs) is browser oriented and reads from top to bottom. While other programming languages first compile the code for the machine to understand and then execute.
In solidity, the code is first compiled for the EVM to understand and then publish, hence by the time the EVM has all the functions irrespective of the vertical order coded
@filip
Hi Filip
I tried to follow āhello worldā contract but when I try to compile I get an error saying: browser/HelloWorld.sol: Warning: SPDX license identifier not provided in source file. Before publishing, consider adding a comment containing "SPDX-License-Identifier: " to each source file. Use āSPDX-License-Identifier: UNLICENSEDā for non-open-source code. Please see https://spdx.org for more information.
The website confused me some more. Is there some licensing I need to have, like register as a user or something. Please help.
Thanks a lot.
Hi
What did you do to resolve this issue?
Actually I didnāt resolve it. The contract did compile, the SPDX-License-Identifier is simply a āprecautionāā¦so the āresolutionā was just to ignore it and move on as it is just another āminor issueā getting in the way of learning more important matters.
Like many, Remix is quite a big step from a simple ānotepadā or āAtomā text editor so it was and still is a bit learning curve to get familiar with it and having an older laptop and poor internet connection does not help. This application is run from the backend isnāt it? One cannot download a desktop appā¦but perhaps you can! This is one of the merits of the forum: generation of ideas and the benefits of collaberation! Cheers
@Rasselas_Wildcat
Thanks for reaching out!
Point to remember: āwarningsā are not error. You should be able to compile your contract.
Let me know it doesnāt.
Thank you guys! I was able to move forward!
Hello everyone
I was working through the mapping video with Filip and have a āParserErrorā at the end. If youād be so kind to look it over and give me any hints or info iād thoroughly appreciate it. REALLY thought I was doing this word for word as Filip did, but here we are
Thank You for your time :]
Hi @Mining365 You have forgotten to open and close the curly brackets when you write the function. This should work
function getPerson() public view returns(string memory name, uint age, uint height){
address creator = msg.sender;
return (people[creator].name, people[creator].age, people[creator].height);
}
Thank You so much @abuga
knew it was something simple that I wasnāt seeing! really appreciate the help 10/10
Question:
If there are so many addresses, how can the program instantly return its value? Doesnāt it have to go through each address to find the right one?
Hi @JohnJR,
Firstly, many apologies for having missed your post and for therefore taking so long to respond to your question.
I do hope you managed to resolve it and move on, because Iāve just run the exact code that youāve posted here, and it should run exactly as Filipās does in the video.
With your code, I retrieve the first person I input by accessing index 0 of the people
array, the second person at index 1, the third person at index 2 ā¦ etc.
The only thing I can think of that may have caused your confusion is if you executed createPerson
twice with the same person information. You would then have 2 people, one at index 0, and the second at index 1, but they would appear to be the same person as their details would be identical.
Do let us know if youāre still having problems, and weāll respond a lot quicker this time around
No probs, thanks for getting back. I see it now and it indeed works. think that was what happened.
thanks for clearing it up!
@rostyslavdzhohola
Thanks for reaching out!
Can you elaborate your question more? Like what program?
If you are talking about the EVM returning addresses values then this is the answer:
- Address are nothing but keys and its value (i.e. balance) is an Unspent transaction output (UTXO) in the blockchain
- the EVM can easily act as a read-only database/ledger, the bottle neck is when we try to insert some data/tranx, hence there is no gas fees for only reading the blockchain
- Returning value still take fraction of seconds more in public Ethereum due to so many address as compared to private Ethereum/Ganache.
Regards
For example, when we use msg.sender to find the address. The program still needs to look up that address in the millions of different addresses on the blockchain. How does it find it quicker than if you were using an array, for example? You still need to go through each address and compare if it is the right one.
@rostyslavdzhohola
msg.sender is an address only
it basically means the address which is sending the message (i.e. calling the function )
Iām having to repeat some of this course due to a lack of understandingā¦
I do not understand the mapping comparison to arrays. Is not an array a dictionary as well? the key to arrays are the indices. If you know the index, ā0ā for example, you know the value instantly. there is no guessing. if you had to guess the hexadecimal address, you would never find the value. so I donāt get that comparison.
the array index is also unique to the value as well. index āzeroā has itās value and that value may be shared with other index values, but there is only one value for index zero as with mapping. so I donāt get the uniqueness comparison either. a single digit is just as unique as a 32 or whatever bit hexadecimal address to my understanding (yes, I am a nube)
is it a security thing? if you have an array value that is linked to its index, open and free for any and all to see. You have the value to index zero you know itās tie to index zeroā¦this tie is not secure. stated in another way, if an array is defined or undefinedā¦its index is not hidden.
so is mapping some sort of secure array?
basically what we are following is a simple entry of the database field ābalanceā to the database field āownerāā¦please bear with me, I am old school. That is done in a balance-owner line entry.
this relationship is can be performed with an array operation
or it can be performed with a mapping operation
simply put, remembering an array index is much easier than remembering an ethereum addressā¦(I know, I am missing the big picture hereā¦lost in the forrest gump)
is the concept āto setā the same as āto inputā or āto passā or āto throwā data to a function? Is this also creating āan instanceā and this instance is persistent as it goes to a āstate variableā?
this is probably the MOST important section of all the vids for me as I gotta get these concepts, yesā¦I am a repeat customer here as I didnāt get it and just eased on down the road only to be hit by a collision near the end.
also I have noticed that I can āsetā the string variable without quotation marks and it appears to workā¦so is this necessary???
cheers