const Moralis = require("moralis-v1/node");
await Moralis.start({ serverUrl, appId, moralisSecret });
await Moralis.enableWeb3({
chainId: 0x38,//BSC mainnet
// chainId: 0x61,//BSC testnet
privateKey: privatekey,
});
let contractAddress = '';
let unit = 18;
if (erc20_id == 30) {
contractAddress = '0xxxxxxxxxxxxxx';
}
const options = {
type: "erc20",
amount: Moralis.Units.Token(value, unit),
receiver: to,
contractAddress: contractAddress,
};
await Moralis.transfer(options).then((result) => {
const ret = {
txhash: result.hash,
}
console.log(JSON.stringify(ret));
});
is v1 transfer still working ?
I got error like this. help please
Error: could not detect network (event="noNetwork", code=NETWORK_ERROR, version=providers/5.6.0)
at Logger.makeError (/usr/lib/node_modules/moralis-v1/node_modules/@ethersproject/logger/lib/index.js:233:21)
at Logger.throwError (/usr/lib/node_modules/moralis-v1/node_modules/@ethersproject/logger/lib/index.js:242:20)
at Web3Provider.<anonymous> (/usr/lib/node_modules/moralis-v1/node_modules/@ethersproject/providers/lib/json-rpc-provider.js:517:54)
at step (/usr/lib/node_modules/moralis-v1/node_modules/@ethersproject/providers/lib/json-rpc-provider.js:48:23)
at Object.throw (/usr/lib/node_modules/moralis-v1/node_modules/@ethersproject/providers/lib/json-rpc-provider.js:29:53)
at rejected (/usr/lib/node_modules/moralis-v1/node_modules/@ethersproject/providers/lib/json-rpc-provider.js:21:65)
at processTicksAndRejections (node:internal/process/task_queues:96:5) {
reason: 'could not detect network',
code: 'NETWORK_ERROR',
event: 'noNetwork'
}