Skip to content

Commit

Permalink
Adding More Tron Pages
Browse files Browse the repository at this point in the history
  • Loading branch information
productshiv committed Apr 8, 2024
1 parent 0791573 commit 8de28e3
Show file tree
Hide file tree
Showing 12 changed files with 1,421 additions and 0 deletions.
91 changes: 91 additions & 0 deletions v1.0/RPC Nodes/rpc-others/rpc-tron/rpc-tron-broadcasthex.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
---
title: "broadcasthex"
slug: "rpc-tron-broadcasthex"
excerpt: "Tron RPC"
hidden: false
metadata:
description: "Tron RPC"
image: []
keywords: "tron, rpc"
robots: "index"
createdAt: "Wed Mar 06 2024 10:35:44 GMT+0000 (Coordinated Universal Time)"
updatedAt: "Sat Apr 06 2024 15:36:44 GMT+0000 (Coordinated Universal Time)"
---
[block:html]
{
"html": "<div style=\"padding: 10px 20px; border-radius: 5px; background-color: #e6e2ff; margin: 0 0 30px 0;\">\n <h5>Archive Method</h5>\n <p>Only on the full archive nodes. Complex queries might take longer and incur additional cost</p>\n</div>"
}
[/block]


### How to use it

{% code overflow="wrap" lineNumbers="true" %}

```typescript
// yarn add @tatumcom/js

import { TatumSDK, Tron, Network } from '@tatumcom/js'

const tatum = await TatumSDK.init<Tron>({network: Network.TRON})

const res = await tatum.rpc.broadcastHex('transactionHex')

await tatum.destroy() // Destroy Tatum SDK - needed for stopping background jobs
```

{% endcode %}

### Overview

The `broadcastHex` method is used to broadcast a signed transaction to the TRON network. This is a crucial step in performing operations on the blockchain, such as transferring TRX tokens or interacting with smart contracts.

The method requires the signed transaction in hexadecimal format.

### Parameters

`transaction` (string): The signed transaction in hexadecimal format. This is a required parameter.

### Return Object

The response object contains the following fields:

`result` (boolean): Whether the broadcast was successful. true - successful; false - failed, and this field will not be displayed in the returned result.

`txid` (string): The Transaction ID of the broadcasted transaction.

`code` (string): The error code in case the broadcast fails.

`message` (string): Detailed error information in case the broadcast fails.

`transaction` (Transaction):

- `raw_data.contract` - The main content of the transaction,`contract` is a list, but only one element is used at present. Different types of transactions have different contract contents. For example, for a TRX transfer type transaction, the contract will include the transfer amount, receiver address and other information. TRON supports multiple types of contracts, please refer to the official documentation [Types of Transaction](https://developers.tron.network/docs/tron-protocol-transaction#types-of-transaction).
- `raw_data.ref_block_bytes` - The height of the transaction reference block, using the 6th to 8th (exclusive) bytes of the reference block height, a total of 2 bytes. The reference block is used in the TRON TAPOS mechanism, which can prevent a replay of a transaction on forks that do not include the referenced block. Generally, the latest solidified block is used as the reference block.
- `raw_data.ref_block_hash` - The hash of the transaction reference block, using the 8th to 16th (exclusive) bytes of the reference block hash, a total of 8 bytes. The reference block is used in the TRON TAPOS mechanism, which can prevent a replay of a transaction on forks that do not include the referenced block. Generally, the latest solidified block is used as the reference block.
- `raw_data.expiration` - Transaction expiration time, beyond which the transaction will no longer be packed. If the transaction is created by calling the java-tron API, its expiration time will be automatically set by the node to the value of adding 60 seconds to the timestamp of the node's latest block. The expiration time interval can be modified in the node's configuration file, the maximum value cannot exceed 24 hours.
- `raw_data.data` - Transaction memo.
- `raw_data.timestamp` - Transaction timestamp, set as the transaction creation time.
- `raw_data.fee_limit` - The maximum energy cost allowed for the execution of smart contract transactions. Only deploying and triggering smart contract transactions need to be set, others not.
- `signature` - The sender's signature for the transaction. This proves that the transaction could only have come from the sender and was not sent fraudulently.
- `txID` - transaction id

### HTTP Request Example

```json
{
"transaction": "0A8A010A0202DB2208C89D4811359A28004098A4E0A6B52D5A730802126F0A32747970652E676F6F676C65617069732E636F6D2F70726F746F636F6C2E5472616E736665724173736574436F6E747261637412390A07313030303030311215415A523B449890854C8FC460AB602DF9F31FE4293F1A15416B0580DA195542DDABE288FEC436C7D5AF769D24206412418BF3F2E492ED443607910EA9EF0A7EF79728DAAAAC0EE2BA6CB87DA38366DF9AC4ADE54B2912C1DEB0EE6666B86A07A6C7DF68F1F9DA171EEE6A370B3CA9CBBB00"
}
```

### HTTP Response Example

```json
{
"result": false,
"code": "TAPOS_ERROR",
"txid": "38a0482d6d5a7d1439a50b848d68cafa7d904db48b82344f28765067a5773e1d",
"message": "Tapos check error.",
"transaction": "{\"raw_data\": {\"ref_block_bytes\": \"02db\",\"ref_block_hash\": \"c89d4811359a2800\",\"expiration\": 1560496575000,\"contract\": [{\"type\": \"TransferAssetContract\",\"parameter\": {\"type_url\": \"type.googleapis.com/protocol.TransferAssetContract\",\"value\": \"0a07313030303030311215415a523b449890854c8fc460ab602df9f31fe4293f1a15416b0580da195542ddabe288fec436c7d5af769d242064\"}}]},\"signature\": [\"8bf3f2e492ed443607910ea9ef0a7ef79728daaaac0ee2ba6cb87da38366df9ac4ade54b2912c1deb0ee6666b86a07a6c7df68f1f9da171eee6a370b3ca9cbbb00\"]}"
}
```
102 changes: 102 additions & 0 deletions v1.0/RPC Nodes/rpc-others/rpc-tron/rpc-tron-broadcasttransaction.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
---
title: "broadcasttransaction"
slug: "rpc-tron-broadcasttransaction"
excerpt: "Tron RPC"
hidden: false
metadata:
description: "Tron RPC"
image: []
keywords: "tron, rpc"
robots: "index"
createdAt: "Wed Mar 06 2024 10:35:44 GMT+0000 (Coordinated Universal Time)"
updatedAt: "Sat Apr 06 2024 15:36:44 GMT+0000 (Coordinated Universal Time)"
---
[block:html]
{
"html": "<div style=\"padding: 10px 20px; border-radius: 5px; background-color: #e6e2ff; margin: 0 0 30px 0;\">\n <h5>Archive Method</h5>\n <p>Only on the full archive nodes. Complex queries might take longer and incur additional cost</p>\n</div>"
}
[/block]


### How to use it

Below is an example of how to use the `broadcastTransaction` method with the Tatum SDK:

{% code overflow="wrap" lineNumbers="true" %}

```typescript
// Install Tatum SDK
// yarn add @tatumio/tatum

import { TatumSDK, Tron, Network } from '@tatumio/tatum'

// Initialize the SDK for the TRON network
const tatum = await TatumSDK.init<Tron>({network: Network.TRON})

// Define a transaction raw body
const rawBody = {
// fill out appropriate data
}

// Call broadcastTransaction RPC method
const res = await tatum.rpc.broadcastTransaction(rawBody);

await tatum.destroy() // Destroy Tatum SDK - needed for stopping background jobs
```

{% endcode %}

### Overview

The `broadcastTransaction` method is used to broadcast a raw transaction to the TRON blockchain network. It submits the transaction for inclusion in the blockchain and returns the result of the broadcast attempt, including the transaction id and any error information.

### Parameters

This method accepts a single parameter, `rawBody`, which is a `TronTxRawBody` object with the following properties:

- `txID` (string): Transaction identifier.
- `visible` (boolean): Specifies the visibility of the transaction. It can be set to either true or false.
- `raw_data` (json): Raw data of the transaction.
- `raw_data_hex` (string): Raw data of the transaction in hexadecimal format.
- `signature` (array of strings): Array of signatures for the transaction.

### Return Object

This method returns a Promise resolving to an object with the following parameters:

- `result` (boolean): Indicates whether the broadcast was successful. If the broadcast failed, this field will not be displayed in the returned result.
- `txid` (string): Transaction id.
- `code` (string): Error code, present if the broadcast failed.
- `message` (string): Detailed error information, present if the broadcast failed.

### HTTP Request Example

JSON request body example:

```json
{
"raw_data": "{\"contract\":[{\"parameter\":{\"value\":{\"amount\":1000,\"owner_address\":\"41608f8da72479edc7dd921e4c30bb7e7cddbe722e\",\"to_address\":\"41e9d79cc47518930bc322d9bf7cddd260a0260a8d\"},\"type_url\":\"type.googleapis.com/protocol.TransferContract\"},\"type\":\"TransferContract\"}],\"ref_block_bytes\":\"5e4b\",\"ref_block_hash\":\"47c9dc89341b300d\",\"expiration\":1591089627000,\"timestamp\":1591089567635}",
"raw_data_hex": "<0a025e4b220847c9dc89341b300d40f8fed3a2a72e5a66080112620a2d747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e5472616e73666572436f6e747261637412310a1541608f8da72479edc7dd921e4c30bb7e7cddbe722e121541e9d79cc47518930bc322d9bf7cddd260a0260a8d18e8077093afd0a2a72e>"
}
```

### HTTP Response Example

A successful HTTP response returns a JSON body similar to the following example:

```json
{
"result": true,
"txid": "77ddfa7093cc5f745c0d3a54abb89ef070f983343c05e0f89e5a52f3e5401299"
}
```

In case of an error, the HTTP response returns a JSON body with an error message:

```json
{
"code": "SIGERROR",
"txid": "77ddfa7093cc5f745c0d3a54abb89ef070f983343c05e0f89e5a52f3e5401299",
"message": "56616c6964617465207369676e6174757265206572726f723a206d69737320736967206f7220636f6e7472616374"
}
```
105 changes: 105 additions & 0 deletions v1.0/RPC Nodes/rpc-others/rpc-tron/rpc-tron-clearabi.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
---
title: "clearabi"
slug: "rpc-tron-clearabi"
excerpt: "Tron RPC"
hidden: false
metadata:
description: "Tron RPC"
image: []
keywords: "tron, rpc"
robots: "index"
createdAt: "Wed Mar 06 2024 10:35:44 GMT+0000 (Coordinated Universal Time)"
updatedAt: "Sat Apr 06 2024 15:36:43 GMT+0000 (Coordinated Universal Time)"
---
[block:html]
{
"html": "<div style=\"padding: 10px 20px; border-radius: 5px; background-color: #e6e2ff; margin: 0 0 30px 0;\">\n <h5>Archive Method</h5>\n <p>Only on the full archive nodes. Complex queries might take longer and incur additional cost</p>\n</div>"
}
[/block]


### How to use it

{% code overflow="wrap" lineNumbers="true" %}

```typescript
// yarn add @tatumio/tatum

import { TatumSDK, Tron, Network, VisibleOption } from '@tatumio/tatum'

const tatum = await TatumSDK.init<Tron>({network: Network.TRON})

const res = await tatum.rpc.clearAbi('TSNEe5Tf4rnc9zPMNXfaTF5fZfHDDH8oyW', 'TG3XXyExBkPp9nzdajDZsozEu4BkaSJozs', {
visible: true,
})

await tatum.destroy() // Destroy Tatum SDK - needed for stopping background jobs
```

{% endcode %}

### Overview

The `clearAbi` method allows clearing the ABI (Application Binary Interface) information of a smart contract on the TRON blockchain. This operation is often used when there is a need to remove outdated or incorrect ABI information from a smart contract.

### Parameters

- `ownerAddress` (string): The account address that owns the smart contract. It can be in base58check format if visible is true; otherwise, it should be in hex format.
- `contractAddress` (string): The address of the smart contract. It can be in base58check format if visible is true; otherwise, it should be in hex format.
- `options` (object, optional): This is an optional parameter that can include:
- `visible` (boolean, optional): Specifies whether the address is in base58 format.

### Return Object

- `raw_data.contract` - The main content of the transaction,`contract` is a list, but only one element is used at present. Different types of transactions have different contract contents. For example, for a TRX transfer type transaction, the contract will include the transfer amount, receiver address and other information. TRON supports multiple types of contracts, please refer to the official documentation [Types of Transaction](https://developers.tron.network/docs/tron-protocol-transaction#types-of-transaction).
- `raw_data.ref_block_bytes` - The height of the transaction reference block, using the 6th to 8th (exclusive) bytes of the reference block height, a total of 2 bytes. The reference block is used in the TRON TAPOS mechanism, which can prevent a replay of a transaction on forks that do not include the referenced block. Generally, the latest solidified block is used as the reference block.
- `raw_data.ref_block_hash` - The hash of the transaction reference block, using the 8th to 16th (exclusive) bytes of the reference block hash, a total of 8 bytes. The reference block is used in the TRON TAPOS mechanism, which can prevent a replay of a transaction on forks that do not include the referenced block. Generally, the latest solidified block is used as the reference block.
- `raw_data.expiration` - Transaction expiration time, beyond which the transaction will no longer be packed. If the transaction is created by calling the java-tron API, its expiration time will be automatically set by the node to the value of adding 60 seconds to the timestamp of the node's latest block. The expiration time interval can be modified in the node's configuration file, the maximum value cannot exceed 24 hours.
- `raw_data.data` - Transaction memo.
- `raw_data.timestamp` - Transaction timestamp, set as the transaction creation time.
- `raw_data.fee_limit` - The maximum energy cost allowed for the execution of smart contract transactions. Only deploying and triggering smart contract transactions need to be set, others not.
- `signature` - The sender's signature for the transaction. This proves that the transaction could only have come from the sender and was not sent fraudulently.
- `txID` - transaction id

Since the transaction type is `ClearABIContract`, the fields contained in `raw_data.contract[0].parameter.value` in the transaction are as follows:

- `owner_address` - Account address.
- `contract_address` - Contract address.

### HTTP Request Example

```json
{
"owner_address": "TSNEe5Tf4rnc9zPMNXfaTF5fZfHDDH8oyW",
"contract_address": "TG3XXyExBkPp9nzdajDZsozEu4BkaSJozs",
"visible": true
}
```

### HTTP Response Example

```json
{
"visible": true,
"txID": "0841733f1141ecd4f932551a26db7b7a4c8077e95bfa78d28ab806d85a3114b1",
"raw_data": {
"contract": [
{
"parameter": {
"value": {
"owner_address": "TSNEe5Tf4rnc9zPMNXfaTF5fZfHDDH8oyW",
"contract_address": "TG3XXyExBkPp9nzdajDZsozEu4BkaSJozs"
},
"type_url": "type.googleapis.com/protocol.ClearABIContract"
},
"type": "ClearABIContract"
}
],
"ref_block_bytes": "ee6c",
"ref_block_hash": "1819e770abbc2e4c",
"expiration": 1684770510000,
"timestamp": 1684770452476
},
"raw_data_hex": "0a02ee6c22081819e770abbc2e4c40b0a997a184315a630830125f0a2d747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e436c656172414249436f6e7472616374122e0a1541b3dcf27c251da9363f1a4888257c16676cf54edf12154142a1e39aefa49290f2b3f9ed688d7cecf86cd6e070fce793a18431"
}
```
Loading

0 comments on commit 8de28e3

Please sign in to comment.