Solidity Basics

you really must be one smart cookie if you have seen ‘Get Out’ only once and got it all…lol. ‘US’ is on my bucket list…haven’t seen that one yet. Director Jordan Peele is a genious and hilarious…he’s got a comedy central skit with Key guaranteed to distract you from a productive EVM day. cheers, have a good day!

2 Likes

Hi @dbeelow0323

Your contract are saved in your local storage

If you use a private windows it will not be saved,

I never get this case, and it seems a bit weird are you compiling the contract before ?
Doing

ctrl + s

save and compile the contract .

If you want to you can use this npm package to store your contract in your computer

1 Like

This is the information I needed. It would seem I just blasted ahead on the teaching and not the details!!

Thank you very much.

2 Likes

This sounds very likely. I did change from Firefox to Opera and it was while I was in the beginning of the coding part for remix lessons.

Thanks for the info.

Don

2 Likes

@John_Okoye

Yes, this statement exists only within the function and it is wipe out once the contract execution gets over :slight_smile:

Have a look at this: https://ethereum.stackexchange.com/questions/1232/difference-between-memory-and-storage

The link above answers all other remaining question.

For me to elaborate,

Memory is used by the EVM to perform storage operation but the storage of data is not permanent, the data is only available until your contract execution, after that it is removed.

Storage OTOH stored data permanently in the EVM and can be access any time

Hope this answers your question.

2 Likes

@John_Okoye
I have replied to your original question :slight_smile:

2 Likes

that was a good link, thank you. I do need to study storage structure in general so the ram - hard disc analogy was good. question that rises though is where is the storage memory physically for the EVM? I presume the memory storage is on the local client machine RAM, but what and where is the storage storage, the persistent stuff of contracts? Is that RAM as well?

@John_Okoye
The memory is a storage area that is created when functions calls are made to smart contracts. It is used to store temporary data such as function arguments, local variables and return values. Like the RAM (Random Access Memory) on x86-64 machines, the memory is volatile — its data is lost when power is switched off.

source: https://kauri.io/a-deep-dive-into-the-ethereum-virtual-machine-evm/766e5d1e1ba240a7976943b659a871fc/a

1 Like

im gonna do it again too lol

1 Like

Hi, I need help with Remix. It’s keep crashing my browser each time after couple of contract deployments. Also, eth balance randomly goes to zero periodically. Does anyone else experiences same issues?

@rostyslavdzhohola
Try using another browser, if the problem still persist let me know

1 Like

I have the same issue on Chrome

1 Like

Hi Filip-

I am getting a warning during compiling regarding my getperson() function, and when deployed, the getPerson function button doesn’t display any info. Here is the warning:

Warning:  Function state mutability can be restricted to view function getperson()...

Here is my code:

`pragma solidity 0.5.12;

contract HelloWorld {
    //STATE VARIABLES
 
    
    struct Person {
        
        string name;
        uint age;
        uint height;
    }

    mapping(address => Person)private people;
    
    
    
    
    //FUNCTIONS
    
    function createPerson(string memory name, uint age, uint height) public {
        
        address creator = msg.sender;
        
        //This creates a person.
        Person memory newPerson; 
        newPerson.name = name;
        newPerson.age = age;
        newPerson.height = height;
        
        people[creator] = newPerson;
        
        
        //people.push(Person(people.length, name, age, height));
    }
    
    function getperson() public returns(string memory name, uint age, uint height){
        
        address creator = msg.sender;
        return (people[creator].name, people[creator].age, people[creator].height);
    }
}`

Thanks!

@Flaflaflohi
Thanks for reaching out!

change it to
function getperson() public view returns(string memory name, uint age, uint height){

you just need to add view keyword to the function :slight_smile:

view keyword means that function will not modify state of contract, i.e. not modify variables, not emit events etc.

2 Likes

Hello… this is my first post. When using remix, after a few files and deploys, i started getting the error:
"Error: sender doesn't have enough funds to send tx. The upfront cost is: 3000000 and the sender's account only has: 0"
I opened a new tab and paste the same code in, and it does work. What am I missing here?

@bhaun
Welcome to the forum and thanks for reaching out!

This is a cryptic error with remix and web3, since it works when you use another tab, then there is no need to worry :slight_smile:
source: https://github.com/trufflesuite/truffle/issues/1062

2 Likes

Hi. I have Parser Error in the Remix for this piece of code:

uint public g_id;
g_id = 0;

Why I can’t assign value to my variable outside of the function?
I want to assign this global variable number 0.
It’s function is to hold the global amount of Retirement contracts created in the system.

I had found a solution. I have initialized the variable g_id without assigning it value. It has default initializing of 0. However, does it have any risks to do so?

@rostyslavdzhohola
There is no risk associated directly with it.
But since you have declared it public, it can be accessed by anyone.

2 Likes

I need your advice:
I want to display all the created IDs by each address. I was trying to convert uint into string but I get “TypeError”.
Below is a solution that doesn’t give off compile error, but I have VM error:

avaliable_contracts = new string(_array[i]);

The second issue is I haven’t found the way to concatenate two strings together yet.
Any ideas?

Hi Filip. While watching “Programming with Assert()” you didn’t quite show what you wrote on:

function getCreator(uint index) public view returns

So, my question is, what goes after that? Is it

returns {
require (msg.sender==owner, "Caller needs ...";
return creators [index];

Also I don’t quite know what your wrote on Caller needs, could you be able to remember that.
Thank you.