ethers.js: How do I call transfer on an ERC20 contract? (missing signer?)
Related to: https://github.com/ethers-io/ethers.js/issues/59
From ethers.js/contracts/contract.js
if (!signer) { return Promise.reject(new Error('missing signer')); }
On the mainnet using a contract to transfer the funds results in an empty promise with missing signer error
{}
(node:14972) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: missing signer
Here is my code:
provider : new ethers.providers.getDefaultProvider()
const contract = new ethers.Contract(this.address, contractABI, this.provider)
contract.transfer.call(fromAddress, toAddress, new ethers.utils.BigNumber(0))
Trying to do it with BNB, all addresses are valid.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 28 (12 by maintainers)
Thanks a lot Richard, you are a genius you can anticipate future issues also!
I found ERC20
transfer
method only have 2 input parameters, so it don’t need set the fromAddress.No worries! Glad it’s working now. 😃