So you wanna build a Tezos wallet?

in #tezos6 years ago

As you might probably know, Tezos is a new decentralized blockchain that governs itself by establishing a true digital commonwealth. Tezos is also a smart contracts platform, based on DPOS (delegated proof of stake), where token holders use their tez to secure the network through "baking" (the term in Tezos analog to "mining").

At the present date (august 2018) Tezos network runs the Betanet. The Mainnet is expected to be launched until the end of quarter 3, probably September 30th.

There are few Tezos wallets available now. The main ones being TezBox (from Stephen Andrews), Galleon (by Cryptonomic), Tezos Blue and Wetez Wallet.

To foster Tezos wallet development and ecosystem, I've created a Tezos Software Develpment Kit library named TezosJ SDK. It allows Android Java developers to easily implement native Tezos Wallets.

The present article is a tutorial that will show how to start a new Android Tezos Wallet project step by step, using TezosJ SDK.

1 - Open Android Studio and create a new project.

image1.png

2 - In app build.gradle file, change compiledSdkVersion, minSdkVersion and targetSdkVersion values as seen below.

image2.png

3 - Remove android:allowBackup="true" line from your AndroidManifest file.

image2.5.png

4 - Add the following permissions to AndroidManifest file:

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

5 - Add TezosJ SDK library reference to your app build.gradle file.

image3.png

6 - Sync your build.gradle file. There should be no errors.

7 - Open your MainActivity.java file and add the code below to your onCreate method.

  new Thread(new Runnable()
  {
      public void run()
      {

            try
            {

                // Instantiates a new Tezos Wallet (create new).
                TezosWallet wallet = new TezosWallet("myPassphrase");

                // Or...
                // Instantiates a previously owned Tezos Wallet (import).
                // TezosWallet wallet = new TezosWallet("word1 word2 word3...word15", "myPassphrase");
                
                // Gets its public key hash.
                wallet.getPublicKeyHash();

                // Gets its mnemonic words.
                wallet.getMnemonicWords();

                // Gets wallet balance.
                wallet.getBalance();

            }
            catch (Exception e)
            {
                e.printStackTrace();
            }


        }
    }).start();

8 - Run your project. And that's all!

Put breakpoints in your code, watch the instantiated wallet, explore its methods. You can also send funds already, TezosJ SDK uses Betanet.

I wrote this software as a way of contributing to the Tezos community and hope that it helps to flourish native Android wallets soon. I intend to publish my own Tezos wallet and to make a plain Java version of the library. Also, I will migrate it to Coldfusion/Lucee, so that web developers can build wallets just by using an HTML tag!

Comments, suggestions and reviews are welcome!

Sort:  

Congratulations @milfont! You have received a personal award!

1 Year on Steemit
Click on the badge to view your Board of Honor.

Do not miss the last post from @steemitboard:

Introducing SteemitBoard Ranking

Support SteemitBoard's project! Vote for its witness and get one more award!

Congratulations @milfont! You received a personal award!

Happy Birthday! - You are on the Steem blockchain for 2 years!

You can view your badges on your Steem Board and compare to others on the Steem Ranking

Vote for @Steemitboard as a witness to get one more award and increased upvotes!

Coin Marketplace

STEEM 0.22
TRX 0.26
JST 0.040
BTC 98409.57
ETH 3478.48
USDT 1.00
SBD 3.24