Skip to content

Instantly share code, notes, and snippets.

@SametSahin10
Created December 5, 2023 09:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SametSahin10/b55de622120bcee34cd390524b339bba to your computer and use it in GitHub Desktop.
Save SametSahin10/b55de622120bcee34cd390524b339bba to your computer and use it in GitHub Desktop.
import { ethers } from 'ethers';
async function transferTokens() {
// Replace with your private key
const privateKey = 'YOUR_PRIVATE_KEY';
// Replace with the recipient address
const toAddress = 'TO_ADDRESS';
// Replace with the amount of tokens to transfer
const amountToTransfer = ethers.utils.parseUnits('AMOUNT_TO_TRANSFER', 'ether');
// Create a wallet instance using the private key
const wallet = new ethers.Wallet(privateKey, provider);
// Transfer tokens to the specified address
const transaction = await wallet.sendTransaction({
to: toAddress,
value: amountToTransfer,
});
// Wait for the transaction to be mined
await transaction.wait();
}
// Execute the transferTokens function
transferTokens().catch(error => console.error('Error transferring tokens:', error));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment