MiniWallet only supports the EOS network. With MiniWallet, developers can do some special actions without pulling up TokenPocket. This way can provide a better user experience.

Ready to start

dependencies {
    compile(name:'wallet-sdk-release', ext:'aar')
  • Deobfuscation

# tokenpocket sdk
-dontwarn com.tokenpocket.opensdk.**
-keep class com.tokenpocket.opensdk.**{*;}
-keep interface com.tokenpocket.opensdk.**{*;}

How to use

  • Initialize SDK

        //Set the mainnet and nodes
        TPManager.getInstance().setBlockChain(this, NetTypeEnum.EOS_MAINNET, "");
        //Set the miniwallet address
        TPManager.getInstance().setAppPluginNode(this, "");
        //Set password to protect miniwallet data, here //using 12345 as an example 
        TPManager.getInstance().setSeed(this, "123456");
  • Authorization This step will customize the permission group and link the operations that need to use miniwallet to the permission group

        AuthorizePerm authorizePerm = new AuthorizePerm();
        //set account for the permission
        //permission name
        //actions to be linked
        LinkAction linkAction = new LinkAction();
        //Here we take tpt transfer as an example. link this action to testtransfer permission

        TPManager.getInstance().auth(AuthActivity.this, authorizePerm, new TPListener() {
                    public void onSuccess(String data) {
                        //The hash of this operation will be returned after the operation is successful,   
                        Toast.makeText(AuthActivity.this, data, Toast.LENGTH_SHORT).show();

                    public void onError(String data) {
                        Toast.makeText(AuthActivity.this, data, Toast.LENGTH_SHORT).show();

                    public void onCancel(String data) {
                        Toast.makeText(AuthActivity.this, data, Toast.LENGTH_SHORT).show();

After the authorization is successful, you can use the key corresponding to the custom permission group to sign related operations

  • Build transaction data

    String actions = "[\n" +
            "        {\n" +
            "          \"account\": \"eosiotptoken\",\n" +
            "          \"name\": \"transfer\",\n" +
            "          \"authorization\": [\n" +
            "            {\n" +
            "              \"actor\": \"ljxlzdh54321\",\n" +
            "              \"permission\": \"testtransfer\"\n" +
            "            }\n" +
            "          ],\n" +
            "          \"data\": {\n" +
            "            \"from\": \"ljxlzdh54321\",\n" +
            "            \"memo\": \"ddd\",\n" +
            "            \"quantity\": \"0.0100 TPT\",\n" +
            "            \"to\": \"clementtes51\"\n" +
            "          }\n" +
            "        }\n" +
            "      ]";

Attention should be paid to this step: the permission of authorization should be filled with the name of the defined permission group.

  • Send transaction

Before sending a transaction, check whether the permission in the transaction data has been linked first. If not, replace the permission in the authorization of the transaction data built in the previous step with active. then pull up TokenPocket to finish this transaction. If the link has been successful, you do not need to pull up the wallet and complete the operation directly in the Dapp.

 private void pushTx() {
        final Transaction transaction = getTxData();
        //First, determine whether the operation permission is already in the account throught the interface. You can refer to account authorization about the process of this link.	
        TPManager.getInstance().isPermLinkAction(this, transaction, new TPListener() {
            public void onSuccess(String data) {
                //If this operation has been authorized by miniwallet, modify the parameters of the operation to the permission group defined by the developer. In the demo instance,Our custom permission group is testtransfer, and details can be found in Authorization	
                replacePerm(transaction, transaction.getPerm());
            public void onError(String data) {
                //If the permission group of the current operation is not linked to the account, the miniwallet cannot complete the current operation, and still needs to pull up the wallet to authorize.	       
                replacePerm(transaction, "active");
            public void onCancel(String data) {
     * @param transaction
     * @param permission
    private void replacePerm(Transaction transaction, String permission) {
        Json actions = new Json(transaction.getActions());
        for (int i = 0; i < actions.getLength(); i++) {
            Json authorization = actions.getObject(i, "{}").getArray("authorization", "[]")
                    .getObject(0, "{}");
            authorization.putString("permission", permission);
        //After replacing the permission of the operation with a custom permission group, the operation can be completed directly in the miniwallet without pulling up the tp wallet. 
    private void realPushTx(Transaction transaction) {
        TPManager.getInstance().pushTransaction(PushTxActivity.this, transaction, new TPListener() {
            public void onSuccess(String data) {
                Toast.makeText(PushTxActivity.this, data, Toast.LENGTH_LONG).show();
            public void onError(String data) {
                Toast.makeText(PushTxActivity.this, data, Toast.LENGTH_LONG).show();
            public void onCancel(String data) {
                Toast.makeText(PushTxActivity.this, data, Toast.LENGTH_LONG).show();

Method description

initSDK() initializes the SDK

isPermLinkAction() Checks if the permission is linked

getAccounts Get authorized accounts

clearAuth Clear authorization

auth authorize


Demo for more details :


  • Permission link failed, please check if the account has enough resources

  • After linking successfully, we still need to pull up TokenPocket. First, ensure the operating parameters are configured correctly. In addition, for some operations involving the security of user assets, even if the configuration is correct, it is still necessary to pull up TokenPocket to confirm.

Last updated