I am getting solidity unexpected response while creating a solidity class and an interface with ethers.js for a voting blockchain
here is the solidity function
function addVoter(string memory _email) public returns (string memory) {
return string('test');
string memory key = random(_email);
require(emailExists[key] == false);
emailExists[key] = true;
voters[key] = Voter({auth_code:key, authorized:true, candidate_id:0, email:_email, voted:false, voter_address:msg.sender});
return key;
}
The function will create a new "Voter" structure and assign to it a random number.
To test the function a placed a return at the function`s start.
The return is supposed to be the system response.
So I expect to get something that will contain the "test" string.
Instead I get something like the following:
{ hash: '0x2c9a61d3e903d706ca829d009d4fdd9f4c2972f17e7b0fb5e1c65b9a0f73436d', blockHash: '0x690948bea16c079b1ba33a0c79aa76e987b828e92aebacc477ec6f6a9152416e', blockNumber: 266, transactionIndex: 0, confirmations: 1, from: '0x6002D48140d30B26C0B8A7B77D7Fa11A41a61a9F', gasPrice: BigNumber { _hex: '0x4a817c800' }, gasLimit: BigNumber { _hex: '0x5a53' }, to: '0xaa0E1b62f1de3fdEC6474FFb78714b18b5477e4b', value: BigNumber { _hex: '0x0' }, nonce: 227, data: '0xaca84892000000000000000000000000000000000000...', r: '0xe9aef9a334b805240a4450845a640153292578b122ce487604ed3e4f135f70a3', s: '0x0eddc482b19115e983018e4b9fe1541b325096ff61c581c559cc54f153527ae8', v: 27, creates: null, raw: '0xf8ca81e38504a817c800825a5394aa0e1b62f...', networkId: 0, wait: [Function] }
The above is the result of the following function build with ethers.js
contract.addVoter('some_email').then((par) => {
registered = par;
console.log(par);
});
The question is, did we do something wrong in our code or did we misunderstand something?