Using the Tron Paymaster service
Making TRC20 transactions on the Tron network can be challenging due to the need for sufficient resources like Bandwidth and Energy. To perform a transaction, you often need to load a significant amount of TRX into your wallet, which can be both complex and expensive. To simplify this process, we have introduced the Tron Paymaster Service, which automatically handles resource management for your transactions.
WARNING
This is a BETA feature. You might encounter some issues. please always reach out to support@chaingateway.io if you have any issues with this feature
How it works
Step 1: Funding the Paymaster Wallet
For detailed API documentation, including calls and parameters, please refer to our Paymaster API Docs
To begin, deposit funds into the paymaster wallet Once your wallet is funded, you can perform Paymaster transactions in much the same way as you would with regular Tron transactions on Chaingateway.
Step 2: Asynchronous Processing
Since resource management (Energy and Bandwidth) takes time, we cannot provide a transaction ID immediately after your API call. Instead, we initiate an asynchronous process and provide you with a unique id to track your request's status. The lifecycle of the Paymaster request is illustrated in the graphic below:
You can check the status of your request or retrieve the transaction ID in one of two ways:
- Polling: Use the API to check the status periodically.
- Webhook Callback: If you provide a callback_url, we will notify you once the transaction ID is generated or if there’s an error.
Create a paymaster request
To create a Paymaster request, use the /api/v2/tron/paymater
endpoint with the following payload format:
{
"type": "TRC20",
"from": "THG9nncwASg3ub5rvVquocAHwwQbnKZxpH",
"to": "TPUjdnMrS7XDUFp5W6zgh4QDCW34nXa2x1",
"contractaddress": "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t",
"amount": 2832.001791,
"privatekey": "XXXXX",
"callback_url": "https://api.chaingateway.io/receiver/webhooks/tron"
}
This request format is similar to the standard Tron transaction API, but includes additional parameters for Paymaster service usage.
Parameter | Description | Mandatory |
---|---|---|
url | The URL of your webhook receiver endpoint | No |
from | The sender address | Yes |
to | The receiver address | Yes |
contractaddress | The contract address of the token | for TRC20 and TRC721 |
token_id | Token ID of TRC10 or TRC721 Token | for TRC10 and TRC721 |
type | The type of transaction (TRX, TRC10, TRC20, TRC721) | Yes |
Estimating the costs
To estimate the cost of a Paymaster request, use the /api/v2/tron/paymaster/estimate
endpoint with the same payload as the /api/v2/tron/paymaster
request. Here’s an example response:
{
"status": 200,
"ok": true,
"message": "Successfully estimated the fees",
"data": {
"energy_consumption": 0,
"bandwidth_consumption": 267,
"paymaster_fee": 0.08
}
}
The paymaster_fee
field shows the estimated fee in USDT.