Hi guys, I’m learning Moralis and I’m facing my first problem.
Here my solidity function :
function addVoter(address _addr) external onlyOwner {
require(workflowStatus == WorkflowStatus.RegisteringVoters, 'Voters registration is not open yet');
require(voters[_addr].isRegistered != true, 'Already registered');
voters[_addr].isRegistered = true;
emit VoterRegistered(_addr);
}
As you can see an address can be add only once.
Now when I call the function addVoter
in JS :
const {account} = useMoralis();
const addingVoter = async function (){
let options = {
abi: [
{
"inputs": [
{
"internalType": "address",
"name": "_addr",
"type": "address"
}
],
"name": "addVoter",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
],
contractAddress: 'the contract address',
functionName: "addVoter",
params: {
_addr: account,
},
}
await contractProcessor.fetch({
params: options
})
};
return (
<div>
<button
onClick={() => AddingVoter()}
>
Fetch data
</button>
</div>
);
When I click the button, Metamask pop up and I can sign the transaction, but I can do it again and again with the same address which I normally can’t do it. I don’t figure out my mistake can you help me ?