Created
December 5, 2023 09:58
-
-
Save SametSahin10/b55de622120bcee34cd390524b339bba to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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