How to build a non-custodial wallet

How to build a backend for a non-custodial wallet in 30 minutes.

The wallet is a simple application where users can sign in, generate accounts in different blockchains, send and receive payments. They are owners of the private keys for every blockchain address and the wallet provider has no access to them.

The wallet can store any assets. It can be customer ERC-20 tokens, standard blockchain assets, or government-issued currencies.

In this tutorial, you will learn how to build a custodial wallet backend on Tatum. All you will have to do after this tutorial is to create a nice frontend for your application.

A custodial wallet is the type of wallet where users have full control over their funds and the associated private key.

There are two logical groups of actions that must be done to create a wallet:

  • registration of new users into the application - what must be done during the registration phase

  • user's application journey - what kind of operations users do during their stay in the application

Registration of the new user

When a new user signs up for the application, blockchain wallets and ledger accounts must be created. Every user should have their own blockchain wallet. 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 account's balance is available in the accounts list by default and does not have to be queried separately.

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.

Finally, there should be a possibility to send the transaction from the account to a blockchain address.

When developing a non-custodial wallet, the Bitcoin transaction should have attr field present in the request body. This will be used as a change address for the rest of the not spent funds, and it must be the first address connected to the ledger account.

That's it. There are many more things to enhance and many more features to have, but this could be a reasonable start for you and your wallet.