0

I hope you are all well.

I have 2 functions. The "transferFrom function" allows a third party to send ether from an account which is owned by another address. The "approve" function is used to allow the third party to use the "transferFrom" function.

My problem is that when I want to use the "transferFrom" function it does not work and my web browser displays this error message: "MetaMask - RPC Error: Invalid parameters: must provide an Ethereum address." The addresses are Ethereum addresses.

Here are the functions:


function transferFrom(address from, address to, uint value) public returns(bool) {
      uint allowance = allowed[from][msg.sender];
      require(allowance >= value, 'allowance too low');
      require(balances[from] >= value, 'token balance too low');
      allowed[from][msg.sender] -= value;
      balances[from] -= value;
      balances[to] += value;
      emit Transfer(from, to, value);
      return true;
      
  }
  
  function approve(address spender, uint value) public returns(bool) {
      require(spender != msg.sender, 'spender must not be sender');
      allowed[msg.sender][spender] = value;
      emit Approval(msg.sender, spender, value);
      return true; 

Would you have an idea on how to solve this problem please?

Thank you very much

Take care

Pierre

2
  • The error message says "Invalid parameters: must provide an Ethereum address", so some of the parameters used to call transfer is incorrect. Check the way the functions is being called and the parameters used. The solidity code seems to be fine.
    – Ismael
    Aug 15 at 22:36
  • Thank you Ismael
    – Pierre
    Aug 16 at 7:27
0

There are two possible problems you may have encountered,

The first might be if you are using Ganache as a local test server check to make sure that the port is the same as the one in truffle.config

Secondly you might be getting that error due to you being in privacy mode on Metamask try disabling that.

1
  • Thank you Adrian
    – Pierre
    Aug 16 at 7:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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