Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

I am trying to understand the use of memory in smart contracts

I am new to solidity, and I’m trying to wrap my head around memory, it seems we use the memory keyword when dealing with strings, structs etc… in functions, how come we dont do the same when passing in a uint? (at least in my crypto zombies tutorial)

e.g

function createObject(string memory _name, uint _dna) public {
    object.push(Object(_name, _dna));

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Data location (memory, storage, and calldata) needs to be specified for reference type variables.

Since uint is a value type, its is’t specified.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading