Solidity Basics

What would be the next step from here?
I’m not that confident with building a front end support from scratch :grimacing: + I thought front ends were made with react (I haven’t done that course yet).

1 Like

RELOAD IT, and every things will be fine

Our JavaScript Course and React Course will set you really quickly to start building basic (but solid) front ends.

I’m not good at front end either (dont like it, i like backend, and i’m quick on it, front end is suffering for me :roll_eyes:), but I’m still able to do a good front end, because i just learn some few coding tricks by practicing :nerd_face:

Carlos Z.

2 Likes

ivan ivan talking about making progress with legos, i think its plugin, but so far i just saw normal programming, where are the legos?

Keep getting ‘Declaration error: Identifier not found or not unique’ on line 15 when try compile this!! Any ideas? Guessing its simple error somewhere, but cannot find it. Feel sure I’ve got identical code to the lecture video.

pragma solidity 0.5.12;

contract HelloWorld{

struct Person {
    string name;
    uint age;
    uint height;
}

mapping(address => Person) public people;

function createPerson(string memory name, uint age, uint height) public {
 adddress creator = msg.sender;
 
 Person memory newPerson;
 newPerson.name = name;
 newPerson.age = age;
 newPerson.height = height;
 
 people[creator] = newPerson;
}

}

Any help appreciated, as I’m stuck here and cannot move forward.

Oh hahaha was a typo, my posting the code made me see it lol

1 Like

Hi, Ay_Jay.

Great job, I’m glad you managed to see the typo by yourself. :rocket:

The error message above says that your typo was in line 15 of your code, right?

Have a nice day, my friend.
Ivo

1 Like

@filip

There is one (important?) use for if-else-statements that I miss…
How to handle wrong type of input. I.e. if the user gives a string or char to a field for uint etc.
In this context how to use bool operators. (probably not hard to find by searching but to get them explained for better understanding)

1 Like

to handle wrong type of inputs you might want to use require()instead of an if-else, because it will stop the transaction unless all inputs or variables verification are correct.

The if-else statement will use for other internal operation on a function logic.
Here are some links to read more about the subject:

If you have any more questions, please let us know so we can help you! :slight_smile:

Carlos Z.

1 Like


Can’t deploy
Says sender doesn’t have enough funds

1 Like

I don’t know but if you set value to 0? Mine looks like… and it works.

1 Like

I have returned the value to zero
Still the same pop up

1 Like

Says low level interaction
Please help

1 Like

I haven’t got a clue…
row 10 if you add “public” ???
(One blind guides another)

Hey @Cryptoinsight, hope you are great.

You had already deplyed the contract, in the “Deployed Contracts” section of the bar, check that you have a contract function to be used, it might be that you are trying to deploy a contract that it has been already deployed in the same address.

Carlos Z.

Hi, Filip :slight_smile:

I wonder how could we implement the ‘removeNumber’ function that removes an element by index.

something like this:

uint[] public numbers = [1,6,9];
function removeNumber(uint index) public {
  numbers.splice(index, 1);
}

But compiler returns a mistake ‘TypeError: Member “splice” not found or not visible after argument-dependent lookup in uint256[] storage ref.’.

I wonder what is the right way to do it?

Thanks in advance!

1 Like

Hey @yana_holoborodko, hope you are great.

Now that is not the way to delete elements in an array in solidity, also is not good practice, that why is better to use mappings. Still if you want to try it out (because it is possible, but not advised to use in production), here are some resources to read more about it.

If you have any more questions, please let us know so we can help you! :slight_smile:

Carlos Z.

@thecil Thanks a lot for explaining, Carlos!

1 Like

@filip

In the If … Else control video when the senior bool property is added I simply used the following line.

newPerson.senior = (age >=65);

This avoids the need for an If … else block. Whilst clearly the video is designed to demonstrate the use of if … else this code is cleaner and more efficient. I assumed this would also consume less gas to run but after doing some research and using the gas information from the debug info in the IDE I found out it only made a gas saving (with Optimize checked in the compiler) of about 0.02 - 0.03 percent. Interesting exercise though…

Really enjoying the course and am glad I went through the Javascript course as refresher with the video speed at 2x (the “Ivan on speed” edition).

Regards,

Phil

1 Like

Hey @cryptophile, hope you are good.

Now indeed you are right, you could use (age >= 65) and that is a completely valid logical operator which will return true or false based on the condition (which is that age must be equal or greater than 65 in order to be true, below 65 will be false).

It will save a little bit on gas. Good thinking. In the video the main goal was to show a really simple way to use the if conditional, but I guess this is not the best practice for it.

If you have any more questions, please let us know so we can help you! :slight_smile:

Carlos Z.