Transaction Management
Send Trx
tronWeb.transactionBuilder.sendTrx("TXPHCzmAmjyERtWES6EXTYqUPfJfQSzp2m", 100, "TZDCUCy3Wn1HhJVseANdrhzqDYCTEue8xT");
Create an unsigned transaction.
| Value | Description |
|---|---|
| to | Address to send TRX to. |
| amount | Amount of TRX to send. |
| from | Optional address that is transferring the Tokens. |
Send Token
tronWeb.transactionBuilder.sendToken("TXPHCzmAmjyERtWES6EXTYqUPfJfQSzp2m", 100, "WIN", "TCanwMYEkP1e6ZWSA2gdU6jDEm1TxWMYQF");
Creates an unsigned Token transfer transaction.
| Value | Description |
|---|---|
| to | Address to send Token to. |
| amount | Amount of Tokens to send. |
| tokenID | If the function accepts a trc 10 token , the parameter is the id of the token |
| from | Optional address that is transferring the Tokens. |
Purchase Token
tronWeb.transactionBuilder.purchaseToken("TXPHCzmAmjyERtWES6EXTYqUPfJfQSzp2m", 100, "WIN", "TCanwMYEkP1e6ZWSA2gdU6jDEm1TxWMYQF");
Creates an unsigned ICO Token purchase transaction.
| Value | Description |
|---|---|
| issuerAddress | Address that issued the Token. |
| amount | Amount of Tokens to buy. |
| tokenID | Name of the Token, matching the exact capitalization. |
| buyer | Optional address that is buying the Tokens. |
Freeze Balance
tronWeb.transactionBuilder.freezeBalance(tronWeb.toSun(100), 3, "ENERGY", "TXPHCzmAmjyERtWES6EXTYqUPfJfQSzp2m", "TXPHCbmRmjyRPtDFS6ERTPqUPfJfQSzp2m");
Creates an unsigned freeze TRX transaction.
| Value | Description | Data Type |
|---|---|---|
| amount | Amount of TRX (in SUN) to freeze. | Integer |
| duration | Length in Days to freeze TRX for. Minimum of 3 days. | Integer |
| resource | Resource that you're freezing TRX in order to obtain. Must be either "BANDWIDTH" or "ENERGY". | String |
| address (optional) | Address of the owner of the TRX to be frozen (defaults to caller's default address). | String |
| receiverAddress | Address of other user receiving the resource. | String |
Unfreeze Balance
tronWeb.transactionBuilder.freezeBalance("ENERGY", "TXPHCzmAmjyERtWES6EXTYqUPfJfQSzp2m", "TXPHCbmRmjyRPtDFS6ERTPqUPfJfQSzp2m");
Creates an unsigned unfreeze TRX transaction. This will unfreeze ALL TRX for that resource and also remove all VOTES.
| Value | Description | Integer Type |
|---|---|---|
| resource | Resource that you're freezing TRX in order to obtain. Must be either "BANDWIDTH" or "ENERGY". | String |
| address (optional) | Address of the owner of the TRX to be unfrozen (defaults to caller's default address). | String |
| receiver address | Address of user in which the resource is being removed from, due to unfreeze. | String |
Withdraw Block Rewards
tronWeb.transactionBuilder.withdrawBlockRewards("TXPHCzmAmjyERtWES6EXTYqUPfJfQSzp2m");
Creates an unsigned Super Representative award balance withdraw transaction.
| Value | Description |
|---|---|
| address | Optional address to withdraw from. |
Apply for Super Representives
tronWeb.transactionBuilder.applyForSR(address = this.tronWeb.defaultAddress.hex, url = 'google.com');
apply for SR for an address
| value | Description |
|---|---|
| address | address for applying for SR, hex string format |
| url | website of SR |
Vote
tronWeb.transactionBuilder.vote( votes = {srAddress : voteCount}, voterAddress = this.tronWeb.defaultAddress.hex);
vote for an SR
| value | description |
|---|---|
| votes | dictionary of SR address : vote count key-value pair |
| voterAddress | voter address in HexString |
Create Token
tronWeb.transactionBuilder.createToken(options = TOKEN_OPTIONS, issuerAddress = this.tronWeb.defaultAddress.hex);
create a token
| value | description | example |
|---|---|---|
| options | token options | { name = false, abbreviation = false, description = false, url = false, totalSupply = 0, trxRatio = 1, // How much TRX will `tokenRatio` cost? tokenRatio = 1, // How many tokens will `trxRatio` afford? saleStart = Date.now(), saleEnd = false, freeBandwidth = 0, // The creator's "donated" bandwidth for use by token holders freeBandwidthLimit = 0, // Out of `totalFreeBandwidth`, the amount each token holder get frozenAmount = 0, frozenDuration = 0 } |
Updated over 5 years ago