I am trying to update the value of one of the props in a struct
in a solidity contract.
updating a variable works fine if it is not in a struct. but when i try to update a value in a struct
like in the contract below, gas is used to update the contracts as i would expect, but when i read the updated value, it has not been changed.
Can anyone see how my contracts definition is incorrect?
My contract is defined as:
Users.sol
pragma solidity ^0.4.17;
contract Users {
struct User {
string firstName;
string lastName;
}
mapping(address => User) public users;
function getFirstName() public view returns (string) {
User memory user = users[msg.sender];
return user.firstName;
}
function setFirstName(newName) public {
User memory user = users[msg.sender];
user.firstName = newName;
}
}
i'm new to working with solidity so any help is appreciated.