When I run the method on Etherscan or Remix, the amount is correct, and it displays with the token's symbol CSHIP.

enter image description here

Yet for the life of me, I can't get the right amount to show up when I am implementing this in my javascript app. My code is below:

let amt = 1e16;
const hash = await web3React.library.provider.request({
    method: "eth_sendTransaction",
    params: [
            from: web3React.account,
            to: farmAddress,
            data: shipContract.methods
            .transfer(farmAddress, web3.utils.toHex(amt) + "")
            nonce: (await web3.eth.getTransactionCount(web3React.account, "latest")) + "",

And here is the result when that code is run: enter image description here

Note that not only is the amount wrong, but the token symbol CSHIP does not appear. What am I doing wrong?

1 Answer 1


Your to parameter should be the address of the contract you're executing the transfer method on - the address of the token you are sending. Probably shipContract.address.

  • If you notice in the screenshots, the recipient address is the same in both metamask popups Dec 15, 2021 at 16:54
  • The address you're referring to is to whom are you sending the funds, not which contract are you using to send the funds. You can see that in Remix you're executing the transfer function on the CSHIP contract - address 0x391 - but in JS you're executing it on farmAddress - 0xc17. So my original answer holds: you need to keep the farmAddress inside the transfer, but change the "to" field to the address of CSHIP - probably shipContract.address. Dec 16, 2021 at 2:49
  • 1
    That's what it was. Thanks for the further explanation! Dec 16, 2021 at 21:26

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.