Solidity Basics

welcome to programming, where most of the time you are searching why something doesn’t work :grinning: #debugging


sending 4.95 dollars in ether is just some number in ‘Wei’

That’s right, ethereum (the EVM) doesn’t support floating point numbers. Due to the nature of floats and their unpredictability we can’t use them in a consensus based system.

Ok, I get why.
And all the floating points can be created in the JavaScript front-end.
I considered making a “Ye Olde Rational” type:

struct Rational {
    uint ordinal;
    uint numerator;
    uint denominator;

…but why waste all that gas.
After 25 years of scientific programming (in Fortran) Solidity feels like Flatland.

1 Like

@filip Seems using quotes on text in set function is not required. When pressing message with and without quotes result is the same.

1 Like

Maybe it does. I can remember some time I had issues with that and I had to use quotes in remix. Maybe it has changed. However, it’s a good habit to have to put quotes around your strings. In truffle you would have to, for example.

Dear @filip and colleagues, I have one question that I can’t figure out.
Why do I need to write Person memory newPerson; ?
Why can’t I populate the struct by writing / Person.age etc…

Is there a specific reason or it is just the syntax of Solidity?

The rest is all extremely clear :slight_smile: Thanks a lot!!

Great question!

The answer is that the struct that we create by writing struct Person {…} is just a definition of the structure. It’s like the architects drawing of a house, it’s just the definition of the house and not the actual house.

When we write Person memory newPerson we create an actual Person according to the definition we created. It would be like we built a house according to our drawings. And we can do that over and over again.

Was that clear? Let me know if you have more questions.


Hi Filip, you demonstrated in your first Solidity video how to increase the font size in the Remix editor by moving the mouse. But how do you do that? The Remix documentation seems to be outdated here. Thank you.

In the old remix editor you do it with these small + and minus signs. But I haven’t found them in the new version. But luckily, when you go to remix you can still choose to use the old version, which is fine.


Yes, I understand. However in your first video named “Build Tools - Remix Walkthrough” you are using the NEW remix editor as well (without these small +/- signs) and you are easily changing the font size, see your video at 2:40 min.

Oh right, I forgot about that. Thanks for reminding me of the timestamp. Makes it easy for me to check.

In the new editor you can zoom in with ctrl and “+” key or zoom out with ctrl and “-” key on your keyboard. Sorry for the confusion. With so many videos it’s easy to forget what I’m doing :smiley:

Perfect, now it’s working. Thank you.
This feature is quite hidden and the documentation is outdated, still showing the old +/- icons. Thanks again.

1 Like

Hey new to all this and I cannot find the “compile” tab… It’s on the left hand side in the course I’m watching but I don’t see it there on my screen. Anyone able to tell me how to find it?

If you press the Solidity button under Environments on the home page in Remix it should make all menus popup :slight_smile:

Hi Filip, I didn’t have any questions to answer in the Mapping Quiz. Regards

Can you see the quiz? You can try re-sizing the window, sometimes the quiz fails to display properly. Because I can see the questions correctly.

1 Like

I just took the mapping quiz and was confused about the last question: “What’s the main benefit of mappings compared to arrays?”
I said “Fast searches if the key is unknown”, but the right answer is: “Quick lookups if key is known”.
I thought that the problem with an array is, that the ID you assign to a user has to be memorized by the user. In a mapping we can just use their address. Therefore the user doesn’t have to remember anything to get his information. Did I misunderstood the answer or is there a mistake in my thinking?

Let’s take an example for the first answer:
“Fast searches if the key is unknown” so the key in the mapping is the address, the key in the array is an id.
Let say you want to know how which user is 38 years old.
The user age is stored in the mapping and in the array.
With an array you will do a “for loop” on the array length and check the age variable in each element of you array to find it.
With a mapping you can’t do a for loop and iter on each element of the mapping so you will have to store the count in an other type of variable (mapping or array). Then check for each index the value of age. So you will need variable something like:

mapping (address => uint) userAge;
mapping (uint => address) userIndex; // or address[] userIndex if you want it dynamic;

For the other answer “Quick lookups if key is known”.
A mapping is more efficient because you will enter the address in the mapping and get the user information. With an array you will a to do a “for loop” check inside your array if the user address match then check his age. if the user is a the first position it’s the same, but if the user is at the 150th position it ll take more time

1 Like

Thank you for the answer. :slight_smile: I thought the search was specified on how fast the user can find his own data.

1 Like