To start, we need to create a Smart-Contract in the Ethereum Testnet, we can use Remix and MetaMask
If you don’t know how to, you can read these posts:
We will use this code:
pragma solidity ^0.4.16; contract Register { struct MyMail { string mail; } event Record(string mail); function record(string mail) public { registry[msg.sender] = MyMail(mail); } mapping (address => MyMail) public registry; }
Once connected with our MetaMask ( plugin of Google Chrome browser) to the Testnet, we can use Remix to install the contract.
Once deployed the contract, we can call the “Record” method to store information, in this case the mail (and this mail will be linked to my Ethereum address, because I am calling the function from my address)
MetaMask will ask us to approve the transaction
We will see the input params of the transaction in Etherscan
Once verified the smart-contract in Etherscan, we can interact and obtain the mail data of an Ethereum address…. because, in this case, we want the Registry of users public.
You can see the source of the contract and interact ->here<-.
By MrAddon
3 replies on “How to store information in Ethereum with Smart-Contracts”