How to transfer bep-20 token?

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'
}

You can’t use privateKey in enableWeb3() like that anymore, you will need to use ethers.js (underlying library) directly now.

thanks for your quick replying.
If I use ethers.js , do I still need use moralis?
can you give some code example to show how to transfer bep20 with ethers.js?
thank you!

If all you do is to transfer tokens then you don’t need Moralis, you can use ethers directly, or web3. The same code that transfers an erc20 token will work for bep20 tokens. You will need a RPC node url in order to send the transaction on chain.