Hi guys, Iām having problems transferring a BEP20 token on the BSC network to another wallet.
Below is the error and the code Iām using >:
code :
//const Moralis = require("moralis/node");
import Moralis from "moralis/node";
const serverUrl = "https://MYSERVERURL.usemoralis.com:2053/server";
const appId = "MY APP ID";
const moralisSecret = "MY SECRET MORALIS";
const web3API = async () => {
await Moralis.start({ serverUrl, appId, moralisSecret });
await Moralis.enableWeb3({
//BSC mainnet
chainId: 0x38,
privateKey: "MY WALLET PRIVATE KEY",
});
const options: Moralis.TransferOptions = {
type: "erc20",
amount: Moralis.Units.Token("2", 18),
receiver: "0x9S9DAS9DUAS8DH8ASHD8AH8........",
contractAddress: "0xA0758218A5A7D5374D2D66EF9b0FDfCD267F49Fa" // this is the token present in my wallet, which I want to transfer to another wallet
};
await Moralis.transfer(options).then((result) => {
console.log(result);
});
};
web3API();
error log >
PS D:\MyPC\Documents\DevTools\NodeJs-Projects> ts-node trans.ts
D:\MyPC\Documents\DevTools\NodeJs-Projects\node_modules\@ethersproject\logger\src.ts\index.ts:261
const error: any = new Error(message);
^
<ref *1> Error: cannot estimate gas; transaction may fail or may require manual gas limit [ See: https://links.ethers.org/v5-errors-UNPREDICTABLE_GAS_LIMIT ] (error={"reason":"cannot estimate gas; transaction may fail or may require manual gas limit","code":"UNPREDICTABLE_GAS_LIMIT","error":{},"method":"estimateGas","transaction":{"from":"MY WALLET ","gasPrice":{"type":"BigNumber","hex":"0x012a05f200"},"to":"0xA0758218A5A7D5374D2D66EF9b0FDfCD267F49Fa","data":"0xa9059cbb00000000000000000000000093c93fad5ef766b6051e8658a65783345793c5400000000000000000000000000000000000000000000000001bc16d674ec80000","accessList":null}}, tx={"data":"0xa9059cbb00000000000000000000000093c93fad5ef766b6051e8658a65783345793c5400000000000000000000000000000000000000000000000001bc16d674ec80000","to":{},"from":"MY WALLET ","gasPrice":{"type":"BigNumber","hex":"0x012a05f200"},"type":0,"nonce":{},"gasLimit":{},"chainId":{}}, code=UNPREDICTABLE_GAS_LIMIT, version=abstract-signer/5.6.0)
at Logger.makeError (D:\MyPC\Documents\DevTools\NodeJs-Projects\node_modules\@ethersproject\logger\src.ts\index.ts:261:28)
at Logger.throwError (D:\MyPC\Documents\DevTools\NodeJs-Projects\node_modules\@ethersproject\logger\src.ts\index.ts:273:20)
at D:\MyPC\Documents\DevTools\NodeJs-Projects\node_modules\@ethersproject\abstract-signer\src.ts\index.ts:301:31
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Promise.all (index 6) {
reason: 'cannot estimate gas; transaction may fail or may require manual gas limit',
code: 'UNPREDICTABLE_GAS_LIMIT',
error: Error: cannot estimate gas; transaction may fail or may require manual gas limit [ See: https://links.ethers.org/v5-errors-UNPREDICTABLE_GAS_LIMIT ] (error={}, method="estimateGas", transaction={"from":"MY WALLET ","gasPrice":{"type":"BigNumber","hex":"0x012a05f200"},"to":"0xA0758218A5A7D5374D2D66EF9b0FDfCD267F49Fa","data":"0xa9059cbb00000000000000000000000093c93fad5ef766b6051e8658a65783345793c5400000000000000000000000000000000000000000000000001bc16d674ec80000","accessList":null}, code=UNPREDICTABLE_GAS_LIMIT, version=providers/5.6.0)
at Logger.makeError (D:\MyPC\Documents\DevTools\NodeJs-Projects\node_modules\@ethersproject\logger\src.ts\index.ts:261:28)
at Logger.throwError (D:\MyPC\Documents\DevTools\NodeJs-Projects\node_modules\@ethersproject\logger\src.ts\index.ts:273:20)
at checkError (D:\MyPC\Documents\DevTools\NodeJs-Projects\node_modules\@ethersproject\providers\src.ts\json-rpc-provider.ts:80:16)
at Web3Provider.<anonymous> (D:\MyPC\Documents\DevTools\NodeJs-Projects\node_modules\@ethersproject\providers\src.ts\json-rpc-provider.ts:562:20)
at step (D:\MyPC\Documents\DevTools\NodeJs-Projects\node_modules\@ethersproject\providers\lib\json-rpc-provider.js:48:23)
at Object.throw (D:\MyPC\Documents\DevTools\NodeJs-Projects\node_modules\@ethersproject\providers\lib\json-rpc-provider.js:29:53)
at rejected (D:\MyPC\Documents\DevTools\NodeJs-Projects\node_modules\@ethersproject\providers\lib\json-rpc-provider.js:21:65)
at processTicksAndRejections (node:internal/process/task_queues:95:5) {
reason: 'cannot estimate gas; transaction may fail or may require manual gas limit',
code: 'UNPREDICTABLE_GAS_LIMIT',
error: Error: Failed to make "eth_estimateGas" request with networkConnector: "gas required exceeds allowance (0)"
at MiniRpcProvider.request (D:\MyPC\Documents\DevTools\NodeJs-Projects\node_modules\moralis\lib\node\Web3Connector\NetworkWeb3Connector.js:85:15)
at processTicksAndRejections (node:internal/process/task_queues:95:5),
method: 'estimateGas',
transaction: {
from: 'MY WALLET ',
gasPrice: [BigNumber],
to: '0xA0758218A5A7D5374D2D66EF9b0FDfCD267F49Fa',
data: '0xa9059cbb00000000000000000000000093c93fad5ef766b6051e8658a65783345793c5400000000000000000000000000000000000000000000000001bc16d674ec80000',
accessList: null
}
},
tx: {
data: '0xa9059cbb00000000000000000000000093c93fad5ef766b6051e8658a65783345793c5400000000000000000000000000000000000000000000000001bc16d674ec80000',
to: Promise { '0xA0758218A5A7D5374D2D66EF9b0FDfCD267F49Fa' },
from: 'MY WALLET ',
gasPrice: BigNumber { _hex: '0x012a05f200', _isBigNumber: true },
type: 0,
nonce: Promise { 0 },
gasLimit: Promise { <rejected> [Circular *1] },
chainId: Promise { 56 }
}
}
What do I need to do to fix this??