Solidity Basics

I do not understand quite well the question, msg.sender define any outside user that interact with the contract, msg.value is the funds that are going to be spend on the contract function.

Pure functions refers to functions that does not read not modify data, it will use the parameters of a function and return a value over those parameters (based on the function logic off course)

Values on msg.value are represented on wei.
1 ether is 1 000 000 000 000 000 000 000 wei so to go from ether to wei we need to add 18 zero’s To go from wei to ether we need to move the decimal point forward 18 places.

Carlos Z

Strings variables must have the ‘memory’ keyword when you define them.

Try with:
string memory message = "Hello World";

Also you are declaring the message variable outside of your contract body.

Carlos Z

:100: % right @zai :muscle:
Thanks for contributing and helping other students :slight_smile:

1 Like

I just started with Solidity learning and seemed like I was already stuck:
when I went to Deploy & run transactions it said: You have no instances to interact with.
I checked the code I’ve been writing along with you through the video, but I saw no error…
Then I rewatched the video and tried clicking Compile helloworld.sol and I could have finished it with the video from Deploy &… got the green checkmark. That simple is we can get stuck…

1 Like

Hi @jon_m. Yey! I honestly feel so happy helping because it boost my morale and make myself believe that I’m having some improvements in my understanding.
By the way, the youtube link that you gave helps me a lot. I already subscribed to Julien’s channel and check his videos every now and then. Thanks again!
I really hope that I can help more to the community soon! Hustle hardest for me! :smiley:

1 Like

Hey @makinitnow,

I’m glad you managed to work out how to compile and deploy your contract :smiley:
Just to ensure you do understand this process, here is what you should be doing:

  • Before you go to Deploy & Run Transactions, you need to compile your contract. It is usually more helpful to have this done automatically by the Solidity Compiler. For this to happen you need to go to the Solidity Compiler and make sure that the Auto Compile option is checked (under Compiler Configuration). The compiler will now compile your contract at the same time that you are typing the code. It will flag any errors in red, and warnings in orange. You can read the error or warning messages, which tell you what the problems are, by hovering over the red or orange box that appears over the line number.

  • Once you have finished coding your contract, and have resolved all of the compiler errors (and any warnings which are relevant), you can then go to Deploy & Run Transactions. It is normal for the message to appear: Currently you have no contract instances to interact with. This simply means that you haven’t deployed your contract yet. You do that by clicking on the orange Deploy button. As soon as your contract is deployed, you will be able to interact with it (i.e. call its functions, and input arguments where necessary) by clicking on the arrow next to the contract name and address at the bottom of the panel.

1 Like

Hey Jon,

Thank you very much for your explanation. It’s sometimes something wasn’t showing the same as in the instructors video, so I had to rewatch the videos few times and figure out what it was - so far it’s been all working in the end.
I’ve been compiling manually, now I’ve turned on Auto Compile as you suggested.
Thank you for the detailed explanation. It’s been helpfull.

1 Like

Glad it was helpful @makinitnow :slight_smile:

I think you’ll find it helpful to have the Auto Compile on. When you’re learning I think it’s easier to resolve any errors as you go, instead of having to do it all at the end before deploying :+1:

1 Like

What happens if i have endles loop on Ethereum mainnet?

fun stuff! :grinning:

Hi @chim4us

The transaction will run out of gas and the transaction will revert.

2 Likes

Hi Filip,

In your Structs tutorial, why are you only putting ‘memory’ to the name and not to uint parameter? or why not put ‘memory’ to both parameters? Thanks…

1 Like

Hi @padlanau, hope you are great.

String variables on Solidity must be declared with the memory keyword on it, is part of the syntax of Solidity.

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

Carlos Z.

2 Likes

Hi @padlanau,

It’s a very good question, and shows that you are really thinking about the syntax. Later in the course, you will learn about the reason for this difference in how local string variables and function parameters are defined compared to those of type (unsigned) integer, boolean or address. It is to do with where data is stored (data location) and how this can be different for complex data types (which include strings) and elementary (or value) data types (which include integers). Until you reach that stage in the course my advice would be just to accept that local variables and function parameters defined as strings include the memory keyword, whereas those defined as (unsigned) integers, booleans or addresses are not.

2 Likes

Greetings!

When running the helloworld.sol contract, I notice the the creation stays “pending” in the console log. Do I need to increase the GasLimit for the contract to execute??

Thanks,
Brian Y

1 Like

Hi @Brian_Y ,

Yeah that might help. try it

Thanks @jon_m for the prompt reply… Cheers.

1 Like

Hi Filip,

Whenever I deploy a contract from one of the exercises, the contract stays in a pending state. I tried increasing gas limit, but it didn’t change anything. Is there anything else I should be addressing to allow the contract to execute?

Thanks,
Brian Y

Oh man, I can hardly wait to start with this course! :exploding_head:

1 Like

Having some problem with the code:

“creation of HelloWorld errored: while converting number to string, invalid number value ‘’, should be a number matching (^-?[0-9.]+)”

Solidity code:

pragma solidity 0.7.5;

contract HelloWorld {

function hello() public pure returns (string memory){
    return "Hello World";
}

}