To use features of ethereum like sending an ERC20 token, you need to use a call method through the EthereumService class that inherits the CoinService interface. The EthereumService class is available to get from the CoinServiceFactory.getCoinService().
Get EthereumService
CoinServiceFactory includes a static method that is the getCoinService to get the specific inherited CoinService.
If you want to use a new EthereumService, a CoinNetworkInfo that assigns CoinType.ETH is required. After creation, reassigning of CoinNetworkInfo is not allowed. If you want to change the NetworkType or 'JSON-RPC URL', you should create a new instance through the CoinServiceFactory.getCoinService().
createEthereumPaymentSheetActivityIntent – Creates an Intent that shows up in the Ethereum Payment Sheet.
createTokenPaymentSheetActivityIntent – Creates an Intent that shows up in the ERC20 token Payment Sheet.
createNftPaymentSheetActivityIntent – Creates an Intent that shows up in the unsafe ERC721 token Payment Sheet.
createSafeNftPaymentSheetActivityIntent – Creates an Intent that shows up in the safe ERC721 token Payment Sheet.
Base CoinService APIs
EthereumCoinService class inherits the CoinService. Base APIs are implemented through the EthereumCoinService.
The list below are the APIs in CoinService.
getBalance – Get the balance of the input account with CoinNetworkInfo in the CoinService.
etherService.getBalance(account).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
}
});
isValidAddress – Returns whether the address is valid or not.
boolean result = etherService.isValidAddress(ethAddress);
getFeeInfo - Get the fee information of the coin.
Deprecated:
getFeeInfo() API has been deprecated in 1.2.00.
Use getFeeInfo(ethereumTransactionType) instead.
EthereumTransactionType ethereumTransactionType = EthereumTransactionType.EIP1559;
etherService.getFeeInfo(ethereumTransactionType).setCallback(
new ListenableFutureTask.Callback<FeeInfo>() {
@Override
public void onSuccess(FeeInfo feeInfo) {
//success
}
@Override
public void onFailure(@NonNull ExecutionException e) {
//failure
}
@Override
public void onCancelled(@NonNull InterruptedException e) {
//cancelled
}
});
sendRawTransaction - Sends a raw transaction. You can create the RawTransaction instance by using RawTransaction.createEtherTransaction. This API can be blocked with the AvailabilityException by SDK’s Availability smart contract in case of critical issue or Ethereum’s own problem.
getTransactionDetail – Gets the detailed information for a single Ethereum transaction by txId. It will return as an EthereumTransaction that contains the transaction data like block number, hash, value, nonce, and etc.
sendTransaction – Sends an Ethereum 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 Ethereum’s own problem.
sendTokenTransaction – Sends an Ethereum Token (ERC20) 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 Ethereum’s own problem.
try {
etherService.sendTokenTransaction(
connectedWallet,
account,
toAddress,
toContractAddress,
EthereumUtils.convertGweiToWei(new BigDecimal(maxPriorityFeePerGas)),
EthereumUtils.convertGweiToWei(new BigDecimal(maxFeePerGas)),
new BigInteger(gasLimit),
new BigInteger(tokenAmount),
nonce
).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
}
sendSmartContractTransaction – Sends an Ethereum 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 AvailabilityException by the SDK’s availability of the smart contract in case of critical issue or Ethereum’s own problem.
sendSafeNftTransaction - Sends an Ethereum Non-Fungible Token (ERC721) safe 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 SDK’s availability of the smart contract in case of critical issue or Ethereum’s own problem.
sendNftTransaction – Sends an Ethereum Non-Fungible Token (ERC721) unsafe 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 Ethereum’s own problem.
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.