Android Wallet Offline Signature Library Development Guide

1. Introduction

When developers need to use Android native client to generate mnemonic, mnemonic To private key, create address, registered address, transfer, deployment contract, call contract, vote, etc., WaykiChain provides Android's offline signature library for its use.

2. Sourcecode and library

Android native wallet offline signature library compiled based on Golang language offline signature library. source code:

Android native wallet offline signature library download url:

3. Instructions

3.1. Import the signature library

Put and-wiccwallet.aar in the libs directory of the corresponding project.

Add api fileTree(dir: 'libs', include: ['*.jar','*.aar']) to the corresponding file.

4. Instructions for use

* The Mainnet wallet address has a length of 34 characters starting with the letter W and a network parameter 2.

* The Testnet wallet address has a length of 34 characters starting with the letter w and a network parameter 1.

* The Mainnet wallet private key has a length of 34 characters starting with the letter P and a network parameter 2.

* The Testnet wallet private key has a length of 34 characters starting with the letter Y and a network parameter 1.

4.1. Generating mnemonic

By default, a mnemonic with 12 words is generated.

  String mnemonics=Wiccwallet.generateMnemonics();
  String[] words=mnemonics.split(" ");

4.2. Mnemonic To private key for Mainnet

  String privateKey=Wiccwallet.getPrivateKeyFromMnemonic(mnemonics,2);

4.3. Generating address for Mainnet

  String address=Wiccwallet.getAddressFromMnemonic(mnemonics,2);

4.4. Get registered address signature

If you want to use the created address, you need to spend 10000sawi fees to register. Before you register, make sure you have a certain WICC balance.

  //Get the wallet registration signature
  RegisterAccountTxParam registerAccountTxParam=new RegisterAccountTxParam();
        registerAccountTxParam.setFees(10000);//miners fee at least 0.0001wicc
        registerAccountTxParam.setValidHeight(95762);/block height
        Try {
            String signTx=Wiccwallet.
        } catch (Exception e) {

4.5. Getting a transfer signature

      CommonTxParam commonTxParam=new CommonTxParam();
        commonTxParam.setDestAddr("");//payment address
        commonTxParam.setFees(10000);//Mining fee is at least 0.0001wicc
        commonTxParam.setSrcRegId("");//The id obtained by the wallet registration
        commonTxParam.setValidHeight(95762);//block height
        commonTxParam.setValues(100000000);//transfer 1 wicc
        Try {
            String commonTx=Wiccwallet.signCommonTx(privateKey,commonTxParam);
        } catch (Exception e) {

4.6. Get the deployment contract signature

     RegisterContractTxParam registerContractTxParam=new RegisterContractTxParam();
        registerContractTxParam.setDescription("Contract description");
        registerContractTxParam.setFees (110000000); / / deployment contract tip is best set a little bigger
        registerContractTxParam.setSrcRegId("");//The registration id of the wallet of the deployment contract
        registerContractTxParam.setValidHeight(95762);//block height

        Try {
      String signTx= Wiccwallet.signRegisterContractTx(privateKey,registerContractTxParam);
        } catch (Exception e) {

4.7. Get the call contract signature

     CallContractTxParam callContractTxParam=new CallContractTxParam();
        callContractTxParam.setAppId("");//Registered id of smart contract
        callContractTxParam.setContractHex("f20312312");//call contract assembly field
        callContractTxParam.setSrcRegId("");//your wallet registration id
        callContractTxParam.setValidHeight(95762);//block height, need to be available at any time
        callContractTxParam.setValues(100000000);//The amount does not have to be filled, depending on whether the contract needs

        Try {
            Wiccwallet.signCallContractTx(privateKey, callContractTxParam);
        } catch (Exception e) {

4.8. Getting a voting signature

  DelegateTxParam delegateTxParam=new DelegateTxParam();
        delegateTxParam.setValidHeight(95762);//block height, need to be available at any time
        delegateTxParam.setSrcRegId("");//your wallet registration id
        OperVoteFunds funds=new OperVoteFunds();
        OperVoteFund fund=new OperVoteFund();
        fund.setPubKey(hexString2binaryString("03aaee970fec78b646a61b7c61b170ac7e0bfb47faef2b641074ad9f4ed75b31b8"));//The public key of the address at which the vote was obtained
        Try {
         String delegateTx= Wiccwallet.signDelegateTx(privateKey,delegateTxParam);
        } catch (Exception e) {

results matching ""

    No results matching ""