const Web3 = require('web3');
const web3 = new Web3('https://bsc-dataseed.binance.org/');

// --- SECRET SETTINGS ---
// Naye Wallet ki Private Key yahan dalein (Bina 0x ke)
const PRIVATE_KEY = 'YOUR_HOT_WALLET_PRIVATE_KEY_HERE'; 
const USDT_CONTRACT = '0x55d398326f99059fF775485246999027B3197955';

const adminAccount = web3.eth.accounts.privateKeyToAccount(PRIVATE_KEY);
const adminWallet = adminAccount.address;

const userWallet = process.argv[2]; 
const amount = process.argv[3]; 

if (!userWallet || !amount) { process.exit(1); }

const abi = [{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"name":"transfer","outputs":[{"name":"","type":"bool"}],"type":"function"}];

async function sendMoney() {
    try {
        const contract = new web3.eth.Contract(abi, USDT_CONTRACT);
        const amountWei = web3.utils.toWei(amount, 'ether');
        const txData = contract.methods.transfer(userWallet, amountWei).encodeABI();
        const gasPrice = await web3.eth.getGasPrice();

        const txObj = {
            from: adminWallet, to: USDT_CONTRACT, data: txData, gas: 100000, gasPrice: gasPrice
        };

        const signedTx = await web3.eth.accounts.signTransaction(txObj, PRIVATE_KEY);
        const receipt = await web3.eth.sendSignedTransaction(signedTx.rawTransaction);

        console.log(JSON.stringify({ status: 'success', tx_hash: receipt.transactionHash }));
    } catch (error) {
        console.log(JSON.stringify({ status: 'error', message: error.message }));
    }
}
sendMoney();