async function transferTokens(from, to, amount, privateKey) {
const account = web3.eth.accounts.privateKeyToAccount(privateKey);
web3.eth.accounts.wallet.add(account);
const tx = contract.methods.transfer(
to,
web3.utils.toWei(amount.toString(), 'ether')
);
const gas = await tx.estimateGas({ from: account.address });
const gasPrice = await web3.eth.getGasPrice();
const data = tx.encodeABI();
const txData = {
from: account.address,
to: contractAddress,
data: data,
gas,
gasPrice,
};
const receipt = await web3.eth.sendTransaction(txData);
console.log('Transfer complete!', receipt);
}