'Is Smart Contracts variable is updated?
Lets assume im having mapping(address => string) names its likes storing user names with their address..function get() return string{ return names[msg.sender]}
and for retrieving the name
function setName(string memory name) return (string){
names[msg.sender] = name
return names[msg.sender]
}
in remix ide i can clearly get and setname with multiple accounts it works perfect... But when it comes to hardhat network locally i deployed but im getting empty string in get function and in set function it returns the string correctly.. After if i try to return the name by the same address im getting same empty string..
Im having a doubt. Am i using it wrong... Because im using that names variable as a database... Whoever set their name and retrieve it later right? But is this possible thats my question.. is that state is kept stored on blockchain or not? Any help
Solution 1:[1]
Yes, states variables are stored in blockchain and are mutable/accessible through the types/methods you defined. So, what you're trying to achieve (Variables as a database) is right, and what happens on your hardhat is probably due to a local miss-configuration.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
