跳转到内容

How to deposit credit

此内容尚不支持你的语言。

Credit is TRX pre-deposited in your account. It saves you bandwidth and simplifies the process of creating orders, since no blockchain transaction or private key is required for each purchase.

The minimum amount to deposit is 10 TRX.

There are three ways to deposit credit:

  • By code — through the API, as shown in the example below.
  • Kiosk mode — send TRX directly from any wallet to the deposit address:
  • Through the web — Go to the menu and select Deposit Credit.
const axios = require('axios');
const TronWeb = require('tronweb');
const TRON_NODE = "https://api.trongrid.io";
const PRIVATE_KEY = "YOUR_PRIVATE_KEY";
const tronWeb = new TronWeb(
new TronWeb.providers.HttpProvider(TRON_NODE),
new TronWeb.providers.HttpProvider(TRON_NODE),
TRON_NODE,
PRIVATE_KEY // this should match origin address
);
const API_SERVER = "https://api.tronenergy.market";
const SERVER_ADDRESS = "TEMkRxLtCCdL4BCwbPXbbNWe4a9gtJ7kq7";
const ORIGIN = tronWeb.defaultAddress.base58; // sender of the TRX to add the credit
const ADDRESS = "YOUR_CREDIT_ADDRESS"; // destination of the credit, it can be the same or another address
const AMOUNT = 10000000; // amount of TRX to load as credit in sun. Here 10 TRX. Min amount: 10 TRX == 10000000
async function DepositCreditTest() {
// We sign the transaction
const raw_tx = await tronWeb.transactionBuilder.sendTrx(SERVER_ADDRESS, AMOUNT , ORIGIN);
const signed_tx = await tronWeb.trx.sign(raw_tx);
// We send the order
const params = {
address: ADDRESS,
signed_tx: JSON.stringify(signed_tx)
};
const POST_URL = `${API_SERVER}/credit/deposit`;
axios.post(POST_URL, params)
.then(() => {
console.log("all ok, credit deposited");
})
.catch((error) => {
console.error("woops, something wrong happened!");
console.error(error);
});
}
DepositCreditTest();