Build Crypto Wallet in 30 min (Step-by-step guide)

Filip Dite
Tatum
Published in
5 min readFeb 4, 2021

If you want to use crypto, you need a wallet. That’s clear for everyone. But what about developing a robust crypto wallet? That’s when clarity turns into ambiguity.

Let’s introduce a simple yet powerful guide which clears out all the ambiguity around blockchain development. (Code included — we have got you covered developers)

NOTE: The guide will focus specifically on custodial wallet’s backend. However, I will also post a link for a non-custodial wallet guide at the end in case you are interested in that one.

The Old-school Way to Develop Blockchain Apps

Back in the old days, you would have to create a development plan, raise some juicy capital, hire blockchain developers (good luck finding them tho) and give them a few months to code.

On that way, you would encounter new problems or find the things you have done need to be changed. So more coding takes more time and requires more capital — and that is exactly how historically around 95% of attempts to build blockchain apps failed.

The New Model

This old model is unsuitable for the current era. Nowadays, one year in the blockchain space feels like a century. There is a push to bring products to market fast and to not miss the wave. There is a push to create MVPs to validate your product, get traction and collect feedback with minimal investments. There is a need for flexibility in your code to direct your product towards the emerging opportunities in the blockchain space. And then there is a ledger platform Tatum which lets you do just that.

Tatum supports over 25 blockchains, unifies the interface into a simple API for easy access, takes care of compliance, offers a powerful off-chain feature to scale beyond blockchain’s limitations and eliminate transaction costs. The API can be used for the development of anything from simple wallets to robust enterprise solutions.

There are three logical groups of actions which must be done to create a wallet:

  1. The Application Setup
  2. Registration of New Users into the Application
  3. User’s application journey

The Application Setup

This phase is a one-time step that must be done before the launch of the wallet.

To communicate with Tatum, you have to sign up for the API Key in the Dashboard. This API Key is used for every request to Tatum as an HTTP Header. I highly recommend using the testnet before going on mainnet.

To generate a Bitcoin wallet, you need to call a request to the Bitcoin/wallet endpoint. The result contains two fields — mnemonic and xpub.

!WARNING! Blockchain wallets and private keys here are created using API, which is not a secure way of generating wallets. Your private keys and mnemonics should never leave your security perimeter. To correctly and securely generate a wallet, you can use Tatum CLI from the command line or use a complex Key Management System from Tatum KMS.

Mnemonic is a 24 word-long string, which you can understand as a password to our wallet. From mnemonic, every address and the private key can be generated. It is sensitive information and should not be revealed. Otherwise, you risk losing your funds.

Xpub is an abbreviation for an extended public key. You can understand it as a generator of addresses. With xpub, only addresses can be generated. You cannot generate private keys with xpub.

Every wallet generated from Tatum holds more than 2 billion addresses. To generate the specific address, you can use an endpoint to generate address — Bitcoin/address, where you enter your xpub and the index of the address you want to generate.

You can now see the result of the API call, the address for index number 1.

To generate a private key, the same mechanism is used. The only difference is that in this case, private keys are not generated from xpubs but from the mnemonic itself.

When you execute Bitcoin/wallet/priv endpoint request with mnemonic and index entered as the request body, you can see the generated private key for index number 1.

That was super easy. You made only three calls to Tatum, and you were able to generate the wallet and receive bitcoins on the blockchain addresses. The same principle applies to other blockchains supported by Tatum, such as Ethereum, Litecoin, Bitcoin Cash, and others…

Registration of New Users into the Application

After the configuration is done and the application is live, users are registering into the ecosystem. When a new user signs up for the application, ledger accounts must be created for them. Every account should be created with the external ID of the customer. Thanks to that, it will be possible to list all accounts for the specific customer.

When you create accounts, blockchain addresses should be created as well and connected to the ledger accounts. By doing so, the process of automatic synchronization of the incoming blockchain transactions starts. It is possible to enable webhook notifications on every incoming transaction to the account.

User’s Journey

When the user signs in to the application, a list of their accounts should be visible. Usually, also last transactions that happened on any of the accounts are presented as well.

The user can see the detail of the account and transactions connected only to this account. Usually, it is good to display blockchain addresses connected to this account to send a blockchain transaction there. Finally, there should be a possibility to send the transaction from the account to a blockchain address.

That’s it! To find out more about the API calls used, visit our API docs. A guide for a custodial wallet can be accessed here. A guide for a non-custodial wallet is available here.

If you encounter any issues or have any questions, write us on Reddit. You can also join our community of developers on Telegram, stay in touch.

Happy coding!

This post first appeared on the LinkedIn published by Martin Půlpán (Project consultant at Tatum.io).

--

--