To use features of Tron like sending of TRX, TRC10, and TRC20 token, you need to use a call method through the TronService class that inherits the CoinService interface. The TronService class is available to get from the CoinServiceFactory.getCoinService().
Get TronService
CoinServiceFactory includes getCoinService, a static method to get the specific inherited CoinService.
If you want to use TronService, a CoinNetworkInfo that assigns CoinType.TRX is required. After creation, reassigning of CoinNetworkInfo is not allowed. If you want to change the NetworkType or RPC_ENDPOINT, you should create a new instance through the CoinServiceFactory.getCoinService().
An account has a TronTokenType which affects sendTokenTransaction and getTokenBalance.
createTronPaymentSheetActivityIntent – Creates an Intent that shows up in the Tron Payment Sheet.
createTrc10PaymentSheetActivityIntent – Creates an Intent that shows up in the TRC10 token Payment Sheet.
createTrc20PaymentSheetActivityIntent – Creates an Intent that shows up in the TRC20 token Payment Sheet.
createSmartContractPaymentSheetActivityIntent – Creates an Intent that shows up in the Smart Contract Payment Sheet.
Base CoinService APIs
TronService class inherits the CoinService. Base APIs are implemented through the TronService.
The list below are the APIs in CoinService.
getBalance – Get the balance of the input account with CoinNetworkInfo in the CoinService.
tronService.getBalance(tronAccount).setCallback(
new ListenableFutureTask.Callback<BigInteger>() {
@Override
public void onSuccess(BigInteger result) {
//success
}
@Override
public void onFailure(ExecutionException exception) {
//failure
}
@Override
public void onCancelled(InterruptedException exception) {
//cancelled
}
});
sendRawTransaction - Sends a raw transaction. This API can be blocked with the AvailabilityException by the SDK’s availability of the smart contract in case of critical issue or Tron’s own problem.
try {
tronService.sendRawTransaction(
connectedWallet,
trxAccount,
rawTx // raw transaction
).setCallback(
new ListenableFutureTask.Callback<TransactionResult>() {
@Override
public void onSuccess(TransactionResult result) {
//success
}
@Override
public void onFailure(ExecutionException exception) {
//fail
}
@Override
public void onCancelled(InterruptedException exception) {
//cancelled
}
});
} catch (AvailabilityException e) {
//handle exception
}
Tron specific APIs
sendTransaction – Sends a TRX. It requires a connected HardwareWallet instance that can sign with the user’s private key. This API can be blocked with the AvailabilityException by the SDK’s availability of the smart contract in case of critical issue or Tron’s own problem.
sendTokenTransaction – Sends a Tron Token (TRC10, TRC20 by account type) transaction with parameters. It requires a connected HardwareWallet instance that can sign with the user’s private key. This API can be blocked with the AvailabilityException by the SDK’s availability of the smart contract in case of critical issue or Tron’s own problem.
try {
tronService.sendTokenTransaction(
connectedWallet,
tronTokenAccount,
toAddress,
new BigInteger("1000") // value of TRC10 or TRC20 by account
).setCallback(
new ListenableFutureTask.Callback<TransactionResult>() {
@Override
public void onSuccess(TransactionResult result) {
//success
}
@Override
public void onFailure(ExecutionException exception) {
//failure
}
@Override
public void onCancelled(InterruptedException exception) {
//cancelled
}
});
} catch (AvailabilityException e) {
//handle exception
}
getTokenBalance – Get Tron Token (TRC10, TRC20 by account type) balance with parameters. This API can be blocked with the AvailabilityException by the SDK’s availability of the smart contract in case of critical issue or Tron’s own problem.
tronService.getTokenBalance(tronTokenAccount).setCallback(
new ListenableFutureTask.Callback<BigInteger>() {
@Override
public void onSuccess(BigInteger result) {
//success
}
@Override
public void onFailure(ExecutionException exception) {
//failure
}
@Override
public void onCancelled(InterruptedException exception) {
//cancelled
}
});
getTokenInfo – Retrieves the (TRC10, TRC20) token information.
sendSmartContractTransaction – Sends a Tron Smart Contract transaction with parameters. It requires a connected HardwareWallet instance that can sign with the user’s private key. This API can be blocked with the AvailabilityException by the SDK’s availability of the smart contract in case of critical issue or Tron’s own problem.
tronService.sendSmartContractTransaction(
connectedWallet,
tronAccount,
contractAddress,
encodedFunction,
value,
tokenId,
tokenValue,
feeLimit,
).setCallback(
new ListenableFutureTask.Callback<TransactionResult>() {
@Override
public void onSuccess(TransactionResult result) {
//success
}
@Override
public void onFailure(ExecutionException exception) {
//failure
}
@Override
public void onCancelled(InterruptedException exception) {
//cancelled
}
getTransactionDetail – Gets the detailed information for a single Tron transaction by txId. It will return as a TronTransaction that contains the transaction data like block number, hash, value, and etc.
tronService.getTransactionDetail(txId)
.setCallback(
new ListenableFutureTask.Callback<TronTransactionHistoryItem>() {
@Override
public void onSuccess(TronTransactionHistoryItem result) {
// success
}
@Override
public void onFailure(ExecutionException exception) {
// failure
}
@Override
public void onCancelled(InterruptedException exception) {
// cancel
}
addTokenAccount – Adds the token (TRC10, TRC20) address to the TronAccount.
We use cookies to improve your experience on our website and to show you relevant
advertising. Manage you settings for our cookies below.
Essential Cookies
These cookies are essential as they enable you to move around the website. This
category cannot be disabled.
Company
Domain
Samsung Electronics
.samsungdeveloperconference.com
Analytical/Performance Cookies
These cookies collect information about how you use our website. for example which
pages you visit most often. All information these cookies collect is used to improve
how the website works.
Company
Domain
LinkedIn
.linkedin.com
Meta (formerly Facebook)
.samsungdeveloperconference.com
Google Inc.
.samsungdeveloperconference.com
Functionality Cookies
These cookies allow our website to remember choices you make (such as your user name, language or the region your are in) and
tailor the website to provide enhanced features and content for you.
Company
Domain
LinkedIn
.ads.linkedin.com, .linkedin.com
Advertising Cookies
These cookies gather information about your browser habits. They remember that
you've visited our website and share this information with other organizations such
as advertisers.
Company
Domain
LinkedIn
.linkedin.com
Meta (formerly Facebook)
.samsungdeveloperconference.com
Google Inc.
.samsungdeveloperconference.com
Preferences Submitted
You have successfully updated your cookie preferences.