Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

transferTether.js #2501

Open
Paolamatteo opened this issue Nov 28, 2024 · 0 comments
Open

transferTether.js #2501

Paolamatteo opened this issue Nov 28, 2024 · 0 comments

Comments

@Paolamatteo
Copy link

const TronWeb = require('tronweb');

// Configurazione TronWeb
const tronWeb = new TronWeb({
fullHost: 'https://api.shasta.trongrid.io', // Usa Shasta se sei in testnet
privateKey: 'ddb0565bacbfcb853ef575484a8b7ce96e9c1b505d8f4c75fa00ebac2c48e538' // La tua chiave privata
});

// Indirizzo del contratto Tether su Tron
const contractAddress = 'TVm22VuHmhxAuxN9f1LfpmrJTWS8aAYG9R';
// Il tuo indirizzo Tron
const userAddress = 'TJkcebb1pDb7WvGZ4RikofQFY8JpAdDSM4';

// Funzione principale per trasferire i token
async function transferTether() {
try {
// Instanzia il contratto
const contract = await tronWeb.contract().at(contractAddress);

    // Controlla il saldo del contratto (opzionale)
    const totalSupply = await contract.totalSupply().call();
    console.log(`Total Supply del Tether nel contratto: ${totalSupply}`);

    // Ammontare da trasferire (esempio: 100 Tether)
    const amountToTransfer = tronWeb.toSun(100); // 100 USDT con 6 decimali (toSun converte in unità base)

    // Esegui il trasferimento al tuo account
    const result = await contract.transfer(userAddress, amountToTransfer).send();
    console.log('Trasferimento completato con successo:', result);
} catch (error) {
    console.error('Errore durante il trasferimento:', error);
}

}

// Esegui la funzione
transferTether();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant