How to create a blockchain wallet

Generating a Bitcoin wallet in three API calls

To communicate with Tatum, you have to sign up for an API Key in the Dashboard. This API Key is used in every HTTP request to Tatum as an HTTP Header.

Do you know that many developers do not know how to handle private keys securely and store them somewhere in their infrastructure? For 2 million users, they store 2 million private keys.

Today, you will be working with Bitcoin to generate a BIP44 compatible wallet. The most important feature of this type of wallet is that you only need to store one secret mnemonic for more than 2 billion private keys and addresses.

BIP 44 is originally a Bitcoin proposal to generate multiple addresses for different blockchains from a single mnemonic seed.

Creating a blockchain wallet

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

Request
Response
Request
curl --request GET \
--url 'https://api-eu1.tatum.io/v3/bitcoin/wallet' \
--header 'x-api-key: YOUR_API_KEY'
Response
{
"mnemonic": "zebra parent avocado margin ready heart space orchard police junior travel today bag action rough system novel large rain detail route spare add mail",
"xpub": "xpub6FPGLmppWEemTJ56aq6wcSkjeZN4iEw1CBvQzkusgbJpqyoiPPJASLpbduzKrNF54i348moHyoVGkyz1H2TC3iEPLfacjPFEfTENkD6YzzZ"
}

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 our complex key management system, Tatum KMS.

Generating an address from the wallet

A mnemonic is a 24 word-long string that you can understand as a password to our wallet. Every address and the private key can be generated from a mnemonic. 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 a specific address, you can use an endpoint to generate the address - Bitcoin/address, where you enter your xpub and the index of the address you want to generate.

Request
Response
Request
curl --request GET \
--url https://api-eu1.tatum.io/v3/bitcoin/address/xpub6FPGLmppWEemTJ56aq6wcSkjeZN4iEw1CBvQzkusgbJpqyoiPPJASLpbduzKrNF54i348moHyoVGkyz1H2TC3iEPLfacjPFEfTENkD6YzzZ/1 \
--header 'x-api-key: YOUR_API_KEY'
Response
{
"address": "1BZWZ89vWpb8htzpBmPMwcWPxt5f6usdZN"
}

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

Generating a private key from the wallet

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 a Bitcoin/wallet/priv endpoint request with the mnemonic and index entered as the request body, you can see the generated private key for index number 1.

Request
Response
Request
curl --request POST \
--url https://api-eu1.tatum.io/v3/bitcoin/wallet/priv \
--header 'content-type: application/json' \
--header 'x-api-key: YOUR_API_KEY' \
--data '{"index":1,"mnemonic":"zebra parent avocado margin ready heart space orchard police junior travel today bag action rough system novel large rain detail route spare add mail"}'
Response
{
"key": "L2A9CvxKQ26LudMRN1air5JpRNZU6Wadno1shxkfq3X3kLtTVQ9z"
}

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

To find out more about the API calls we have just used, visit our API reference.