Simple Payment UI

The Blockchain Platform SDK supports the simple payment UI with cryptocurrency. This simple payment UI feature is embedded in the SDK and doesn’t need any other information on UI components. It supports Ethereum and Tron. See each section for detailed information.

Ethereum

It supports to send Ethereum, ERC20, and ERC721. There are three options for the transaction fee: faster, normal, and slower. It's estimated value is based on the Big Data analysis of the proxy node of Samsung. Take note that it is not estimated in real time.

ETH

createEthereumPaymentSheetActivityIntent creates an Intent instance for the Ethereum payment sheet activity. Optionally, you can use data and nonce parameters. If you want to get the txid for results, you should call startActivityForResult(Intent intent, int requestCode) instead of the startActivity(Intent intent). This API can be blocked with the AvailabilityException by the SDK’s Availability smart contract in case of critical issue or Ethereum’s own problem.

EthereumTransactionType ethereumTransactionType = EthereumTransactionType.EIP1559;

Intent intent = etherService
    .createEthereumPaymentSheetActivityIntent(
        context,
        connectedWallet,
        ethereumTransactionType,
        ethAccount,
        toAddress,
        EthereumUtils.convertEthToWei(BigDecimal.ONE), // value in wei
        null,
        null
    );
startActivityForResult(intent, 0);

ERC20

createTokenPaymentSheetActivityIntent creates an Intent instance for the ERC20 token payment sheet activity. Optionally, you can use the data and nonce parameters. If you want to get the txid for results, you should call the startActivityForResult(Intent intent, int requestCode) instead of the startActivity(Intent intent). It does require the token’s contract address for payment. This API can be blocked with the AvailabilityException by the SDK’s Availability smart contract in case of critical issue or Ethereum’s own problem.

EthereumTransactionType ethereumTransactionType = EthereumTransactionType.EIP1559;

Intent intent = etherService
    .createTokenPaymentSheetActivityIntent(
        context,
        connectedWallet,
        ethereumTransactionType,
        tokenAccount,
        toAddress,
        contractAddress,
        new BigInteger("10000000000"),
        null,
);
startActivityForResult(intent, 0);

ERC721

There are two methods for ERC721 (https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md) specifying the safe/unsafe transfer feature.

createNftPaymentSheetActivityIntent and createSafeNftPaymentSheetActivityIntent creates an Intent instance for the ERC721 token payment sheet activity. Optionally, you can use the data and nonce parameters. If you want to get the txid for result, you should call the startActivityForResult(Intent intent, int requestCode) instead of the startActivity(Intent intent). It requires the token’s contract address and tokenId for payment. This API can be blocked with the AvailabilityException by SDK’s Availability smart contract in case of critical issue or Ethereum’s own problem.

EthereumTransactionType ethereumTransactionType = EthereumTransactionType.EIP1559;

Intent intent = etherService
    .createNftPaymentSheetActivityIntent(
        context,
        connectedWallet,
        ethereumTransactionType,
        tokenAccount,
        toAddress,
        contractAddress,
        new BigInteger("18"), // token id
        null
 );
startActivityForResult(intent, 0);

Tron

It supports to send TRX, TRC-10 and TRC-20.

TRX

createTronPaymentSheetActivityIntent creates an Intent instance for the Tron payment sheet activity. If you want to get the txid for results, you should call startActivityForResult(Intent intent, int requestCode) instead of the startActivity(Intent intent). This API can be blocked with the AvailabilityException by the SDK’s Availability smart contract in case of critical issue or Tron’s own problem.

Intent intent = tronService
    .createTronPaymentSheetActivityIntent(
        context,
        connectedWallet,
        trxAccount,
        toAddress,
        TronUtils.convertTrxToSun(BigDecimal.ONE)
);
startActivityForResult(intent, 0);

TRC10

createTrc10PaymentSheetActivityIntent creates an Intent instance for the TRC10 token payment sheet activity. If you want to get the txid for results, you should call the startActivityForResult(Intent intent, int requestCode) instead of the startActivity(Intent intent). It does require the token id for payment. This API can be blocked with the AvailabilityException by the SDK’s Availability smart contract in case of critical issue or Tron’s own problem.

Intent intent = tronService
    .createTrc10PaymentSheetActivityIntent(
        context,
        connectedWallet,
        trc10Account,
        toAddress,
        "1002000", // token id
        new BigInteger("1000")
    );
startActivityForResult(intent, 0);

TRC20

createTrc20PaymentSheetActivityIntent creates an Intent instance for the TRC20 token payment sheet activity. If you want to get the txid for results, you should call the startActivityForResult(Intent intent, int requestCode) instead of the startActivity(Intent intent). It does require the token’s contract address for payment. This API can be blocked with the AvailabilityException by the SDK’s Availability smart contract in case of critical issue or Tron’s own problem.

Intent intent = tronService
    .createTrc20PaymentSheetActivityIntent(
        context,
        connectedWallet,
        trc20Account,
        toAddress,
        contractAddress,
        new BigInteger("1000")
    );
startActivityForResult(intent, 0);

Result of payment

After completing a payment, you can get the txid and coin type from onActivityResult(int requestCode, int resultCode, Intent data). You can get the txid in the received Intent parameter with the txid key. You can get the coin type in the received Intent parameter with the coinType key.

@Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (requestCode == 0) {
            switch (resultCode) {
                case Activity.RESULT_OK:
                    Log.d(TAG, "txid : " + data.getStringExtra("txid"));
                    Log.d(TAG, "coinType: " + data.getStringExtra("coinType"));
                    break;
                case Activity.RESULT_CANCELED:
                    Log.d(TAG, "user canceled");
                    break;
            }
        }
    }