0

I'm not really sure why this web3 method is being called in my code and why it's not a function apparently.

Can anyone help me understand what the issue is here?

Unhandled Rejection (TypeError): address.replace is not a function

My react code calling my smart contract:

var event = storehash.events.documentAdded()
    await storehash.methods.sendDocument(_ipfsLink, newDate).send({from: _account})
    event.watch(function(error, result) {
            if (!error)
                //this.setState({idForBlockchain: result.args.id})
                console.log(result);
        }
    );
  • 1
    Just a guess, but maybe _account is the wrong type? It should be a public Ethereum address in a string (e.g. "0x12345..."). – smarx Mar 19 at 17:33
  • The worrying part is I'm able to display _account on the screen and its correct, so I'm really not sure how it's getting a problem with it. – Neil Grogan Mar 19 at 17:37
  • And what's its type? Try logging typeof _account. – smarx Mar 19 at 17:38
  • Another guess: the address you used to initialize storehash? – smarx Mar 19 at 17:41
  • Hmm, logging its type gave object back. So am I not getting it correct with this.setState({account: await web3.eth.getAccounts()}) or do I need to change its type to string before I send it? – Neil Grogan Mar 19 at 17:52

Your Answer

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

Browse other questions tagged or ask your own question.