Solidity Basics

Hi all, I was wondering if there’s a way to show a contract creator text before deployment.

I thought it might be interesting if, for example, when the creator is inputing into the constructor function, the contract prompted “welcome” or something like that.

@dan-i thank you :pray:

1 Like

You’re more than welcome

Hi,
do I need first watch the old version of Ethereum smart contract programming 101 or I can start from here?

1 Like

Why isn’t possible to find all value entered into a mapping? I don’t understand a question in the mapping quiz, do you think that is it possible to find all value entered into a mapping without key or?
Because if we know a key we can easily get a value of that key.

Sorry Filip in the lesson Control Flow why we have to write this last return message call…we already put it in the funtcion and in the if else flow? I programmed 1989 C++, a bit. It was long time ago…

1 Like

State is the root of all evil. I am really surprise when I saw the word ‘pure’ despite solidity looks more like a OOP language. I hope you guys create soon a Course for Plutus Smart Contracts (Haskell) :laughing:

1 Like

@filip I have a couple of questions from your videos

  • Video solidity/control flow
    you mentioned the usage of msg.sender but I am missing the msg and the type in the list of arguments of your hello function. I would expect function hello(msg MsgType) … or does is this magically accessible like a global var ?

  • Video solidity/Loops and solidity/Arrays
    Do you have any iterables? like map, filter, reduce? otherwise it looks too imperative and verbose using while and for :frowning:

  • Video solidity/Structs
    How do I know what value goes to age and what to name? is the order? or the type how the compilers know what values goes where?

1 Like

Hey @Lane11, hope you are well.

there is no need to do the OLD version of the course, we have updated it to a newer solidity version and also the projects and assignments of the course. So you can just start watching the new one.

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

Carlos Z.

1 Like

Hey @Jelkucijus, hope you are great.

Could you please explain your doubt a little bit more? maybe showing me the code or the lesson can help me understand it :nerd_face:

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

Carlos Z.

1 Like

mgs.sender is a reserved keyword on solidity that refers to the user (account/address) that execute/call the function.

there is not iterables on solidity yet, so you have to use the fundamentals of iterating an array (for loop or while as you mention)

you have to define the variable type on the struct.

struct MyStruct{
   uint age;
   string memory name;
}

for example.

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

Carlos Z.


Why I can’t transfer from one to another acc. When I put address of recipient (in function parameter to) and the amount, it won’t transfer. Balance of msg.sender is still addBalance amount but recipient is always 0?

Hi @Lane11

In your function transfer you are:

  • Decreasing the balance of msg.sender of amount
  • Increasing the balance of to of amount

That seems correct.

Can you clarify the issue, explaining which function you are calling and which parameters you are sending.

Also make sure the msg.sender and to are not the same address, otherwise you won’t see any difference.

Please also post your contract by copy-paste its code and avoid screenshots, so that we can copy and test ourselves.

Cheers,
Dani

1 Like

pragma solidity 0.7.5;

contract Transferr{

mapping(address => uint)balance;

function addBalance(uint add) public returns(uint) {
    balance[msg.sender] = balance[msg.sender] + add;
    return balance[msg.sender];
}

function showBalance() public view returns(uint){
    return balance[msg.sender];
}

function transfer(address to, uint amount) public {
   
     balance[msg.sender] -= amount;
     balance[to] += amount;
     
}

}

When I call addBalance and showBalance functions it works, but when I call transfer function it won’t work when I change acc and try to check balance.

Hi @Lane11

I copy/pasted your code and works for me.
Are you sure you are not using msg.sender as to address on the function transfer?

1 Like

@dan-i
When I copied a recipient address I did not change acc back to deployer of contract and then do a transfer, but I did the transfer from recipient acc (address). My mistake, but ty for help.

1 Like

Hello Filip I did open Remix, but the “Create File” does not appear in the page.
Please anyone can help me with this as fast as possible in order to continue my course.
Thank you

Hi everyone! I’m stuck because I don’t see the input field next to the hello button. I don’t know what I’m doing wrong. Any help is appreciated :wink:

Hi @Fahd_Sef

Here the Remix docs: https://remix-ide.readthedocs.io/en/latest/

Regards,
Dani

Hey @thecryptoargie

Your function hello() is not asking for parameters, therefore you don’t see the input field next to it :slight_smile:

You will have the input field in all your functions that ask for parameters, an example:


function test (uint _number) public {}

Happy learning,
Dani

1 Like