I have a smart contact which have 2 owner address and 3 functions.
my set functions is set a users with msg.sender and my getUser functions is returns name,surname and age and I want to add a admin which can set users to . This setUsersbyAdmin function take an address parameter for set name,surname and ag.
My smart contract works well on remix but I try to truffle compile it failed.
here's the code :
pragma solidity >=0.4.0 <0.7.0;
contract NewHello{
address owner;
address newOwner;
constructor()public{
owner = msg.sender;
}
modifier onlyOwner (){
if(msg.sender != owner){
require(msg.sender == newOwner);
_;
}
else{
require(msg.sender == owner);
_;
}
}
struct user{
string name;
string surname;
uint age;
}
event infoChanged(
string name,
string surname,
uint age
);
mapping(address => user) public users; // contains a user for every address
function setUser(string memory name,string memory surname,uint age) public payable{
users[msg.sender] = user(name,surname,age);
emit infoChanged(name,surname,age);
}
function setUserbyAdmin(address _address, string memory name,string memory surname,uint age) public payable onlyOwner{
users[msg.sender] = user(name,surname,age);
emit infoChanged(name,surname,age);
}
function getUser(address _address) public view returns(string memory name , string memory surname, uint age) {
return (users[_address].name,users[_address].surname,users[_address].age);
}
}
when I compile this with truffle I see an error on my window which says :
Warning: Unused function parameter. Remove or comment out the variable name to silence this warning. function setUserbyAdmin(address _address, string memory name,string memory surname,uint age) public payable onlyOwner{ ^--------------^