0

I'm trying to perform a function that exchanges one token for another, but I'm getting a very strange bug. If I call the function in web3, I get the standard metamask popup asking whether to confirm or reject the transaction. Now what's happening is if I hit reject, the value exchange still happens, even though there is no transaction on metamask nor on my ganache cli, just the values are updated on metamask. Then if I confirm the transaction, the transaction goes through as normal, except that double the expected value is exchanged.

Occasionally I get RPC Error: MetaMask Tx Signature: User denied transaction signature. as expected, yet the value is still exchanged. I've tried restarting my ganache cli, resetting my accounts on metamask, and even reinstalling metamask, but still the same.

Solidity

function deposit(uint amount) public {
    require(daitoken.transferFrom(msg.sender, address(this), amount), 'transferFrom failed');
    emit Transfer(msg.sender, address(this), amount);
    require(ldai.mint(msg.sender, amount), 'mint failed');
    emit Mint(msg.sender, amount);
    emit Deposit(msg.sender, amount);
  }

Web3

const num = this.state.amount * (10**18);
    this.props.contract.methods.deposit(num.toString()).send({from: this.props.account});

1 Answer 1

0

Since your code looks fine, and there are no bug reports anywhere matching the issue you are describing, I suggest diagnosing if the bug comes from MetaMask by trying another wallet. Also, try another version of web3.js.

1
  • Thanks for the suggestion, but no luck yet... Nov 5, 2019 at 19:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.