Solidity Basics

Hi Frank,

Yes, you are correct :+1:

As you say…

uint positiveNumber = 5;

uint negativeNumber = -5;      // => compiler throws an error

(i) uint only allows zero and positive integers up to a max based on the binary places included in the type.
    e.g. uint4 (0 to 15) , uint8 (0 to 255) , uint16 (0 to 65535)

(ii) int allows positive and negative integers from a min of minus(-) half the max based on the binary places included in the type, to a max of plus(+) half the max based on the binary places, and including zero.
    e.g. int4 (-8 to 7) , int8 (-128 to 127) , int16 (-32768 to 32767)

We should always keep within the restrictions in terms of the range of integers available with a given integer type (signed or unsigned), because the compiler will not always prevent an overflow (a loop from the max limit, back to the min limit) or an underflow (a loop from the min limit back to the max limit).

1 Like

Hello sir, after the people.push, look at the last parameter (“height”), you should not have a comma at the end of the last parameter.

If you have any doubt, please let us know so we can help you!

Carlos Z.

1 Like

Thank you for your reply and I have amendent the comma error, however, I am still getting an error about not recognising ‘lenght’ in the directory, see attached. Again thanks for takin the time to help me out…

AJ

@filip @thecil can anyone help with this error I get now please, tried loads of different things and I might be missing something?!

Cheers

It’s only the variable “people.lenght”, LENGTH, you misspell the property name.

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

Carlos Z.

1 Like

@thecil Thank you sir and lol in me not being able to see that

2 Likes

Don’t worry @coletto27, you’re not the only one. It’s a very common mistake :wink:

1 Like

Hi, I have a question regarding the struct lesson.

My code works but it pushes the first created person under position " 1" in the array, instead of “0” which happened when Filip run his code. I don’t understand why it does this.
Here’s my code:

pragma solidity 0.5.12;

contract HelloWorld{

struct Person{
    uint id;
    string name;
    uint age;
    uint height;
   
}
Person[] public people;

function createPerson(string memory name, uint age, uint height) public{
    people.push(Person(people.length, name, age, height));
}

}

Hello, seeking assistance with deploying on this version of remix. Please see screenshot. I think it is adding plugins? Should I activate them all? Also trying to find how to compile as well, is that the bugs? Or where to choose the compiler as it isn’t clear…will play around a bit.

Salud.

1 Like

Hi,

Via Plugin Manager, you can install DEPLOY & RUN TRANSACTIONS and SOLIDITY COMPILER plugins. This last plugin will find the right compiler to match the pragma statement.

2 Likes

https://remix.ethereum.org
I’m not getting anything. It goes out and finds it but nothing is there.

https://remix.ethereum.org does not give me anything. No error, just blank page.

I had the same thing when using the Brave browser…still am using Brave, just shut off the brave shields and waited and it takes time to load.

2 Likes

that’s great…however I got a bit click happy and installed so many that if filled up the left column and there does not appear to be a way to unplug them nor scroll down to see the installed plugs below the settings…

ok,resolved…got to ‘featured plugins’ where I could deactivate…then found the solidity compiler

1 Like

not compiling apparently do to an SPDX license identifier not provided.

It appears that this is needed: SPDX-License-Identifier: UNLICENSED

but it wasn’t accepted

1 Like

It’s a warning, you compiled the contract successfully. You can deploy it.

1 Like

Indeed it was, ty

however I do not get any of the message buttons under deployed contracts…why?

**resolved…just needed to open the ‘>’ tree…matter of just getting familiar with Remix

I get an error message here…not sure why???


***resolved…I had commented out the instantiation in error

I can’t get my data structure code to compile. It looks exactly like yours but there is one thing. I wanted to save the code for reference and created a new contract.

Can you help me?

Sorry, never mind. I figured it out.

1 Like