Loading...
This is a simple smart contract which will store persons details such as age,adhar number,name in smart contract and read from the smart contract .
pragma solidity ^0.5.0;
contract mycontract{
struct details{
string name;
uint256 age;
string adhar;
}
details detail;
function setname(string calldata _name) external{
detail.name=_name;
}
function setage(uint256 _age) external{
detail.age=_age;
}
function setadhar(string calldata _adhar) external{
detail.adhar=_adhar;
}
function getname() view external returns(string memory){
return detail.name;
}
function getage() view external returns(uint256){
return detail.age;
}
function getadhar() view external returns(string memory){
return detail.adhar;
}
}
Here we have created the structure for the persons to store details in object format .After that we have created the variable or instance of structure .Then we have added some setters and getters methds for reading and displaying details of that persons.