unable to transfer token on polygon using enableWeb3 automatically.i want to send token automatically without authentication so due to this trying to send with private key enableweb3 functionality.but it not works.
âInternal json-rpc errorâ will occur on Moralis.transfer
async function sendToken() {
try {
//console.log(Moralis.CoreManager.get("VERSION"))
await Moralis.start({ serverUrl, appId });
await Moralis.enableWeb3({
chainId: 0x89,
privateKey:"ddddkkkkk",
});
alert("For ats trans");
// sending 0.5 tokens with 18 decimals
const options = {
type: "erc20",
amount: Moralis.Units.Token("0.5", "18"),
receiver: "abcd",
contractAddress: "xyzz",
};
//let result = await Moralis.transfer(options);
setTimeout(() => {
console.log("we waited 204586560000 ms to run this code, oh boy wowwoowee!");
}, 5000);
alert('ready to hit req');
const transaction1 = await Moralis.transfer(options);
let result1 = await transaction1.wait();
alert(result1.transactionHash);
} catch (error) {
alert(error.message);
return false;
regError("Something went wrong.please check and try again.");
//console.error("trigger smart contract error", error);
}
}