Skip to content

Instantly share code, notes, and snippets.

@ImHukam
Created June 1, 2023 17:14
Show Gist options
  • Save ImHukam/a0c67c625740350ebf67cf416990dd49 to your computer and use it in GitHub Desktop.
Save ImHukam/a0c67c625740350ebf67cf416990dd49 to your computer and use it in GitHub Desktop.
const { ethers } = require('ethers');
async function transferUSDT() {
// Provider and Signer
const provider = new ethers.providers.JsonRpcProvider('https://polygon-rpc.com');
const privateKey = 'YOUR_PRIVATE_KEY_HERE'; // Replace with your private key
const signer = new ethers.Wallet(privateKey, provider);
// USDT Contract
const usdtContractAddress = 'USDT_CONTRACT_ADDRESS'; // Replace with the actual USDT contract address
const usdtContractABI = [
// USDT contract ABI (ERC20 standard)
// ... Include the relevant ABI here ...
];
const usdtContract = new ethers.Contract(usdtContractAddress, usdtContractABI, signer);
// Transfer Parameters
const recipientAddress = 'RECIPIENT_ADDRESS'; // Replace with the recipient's address
const amount = ethers.utils.parseUnits('100', 6); // Replace with the desired amount and decimal (in USDT)
// Perform Transfer
try {
const tx = await usdtContract.transfer(recipientAddress, amount);
console.log('Transfer TX Hash:', tx.hash);
await tx.wait();
console.log('Transfer completed successfully.');
} catch (error) {
console.error('Transfer failed:', error);
}
}
transferUSDT();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment