Tatum
Search…
Your First App
Let's generate a Bitcoin wallet, address, and private key in 3 steps.
Our first app will create a wallet for Bitcoin and Ethereum. We will also generate one blockchain address and one private key from the wallet.
What is a blockchain wallet, mnemonic, and private key?
Like Bitcoin or Ethereum, major public blockchains use the terms wallet, mnemonic, and private key. What's does all this mean?
In one wallet, you might have many blockchain addresses. A blockchain address is similar to a bank account. In a public blockchain, the blockchain address, balance, and all the transactions to/from the address are known by everyone. Each blockchain address has a corresponding private key. Anyone with a private key can send digital assets from the blockchain address to another one. Therefore, it is crucial to keep your private keys secure.
Similarly, as a blockchain address has a corresponding private key, each wallet has a corresponding mnemonic. A mnemonic is sometimes called a "seed phrase" and represents a wallet. The mnemonic allows you to create a new blockchain address and corresponding private key in the wallet, or recover a private key for a blockchain address that belongs to your wallet. Never reveal your mnemonic to anybody. Otherwise, you can lose all your funds.
To learn more about how public and private keys work, check out this article: https://www.mycryptopedia.com/public-key-private-key-explained/​

1. Getting your API key

This guide assumes you already have a Tatum account. Don't have an account? No worries. Sign up here. It's free.

2. Generating a Bitcoin wallet

The first step is to generate a wallet. Tatum supports over 40 blockchain protocols and thousands of digital assets. You can use our Tatum JS (our JavaScript SDK) or directly communicate with our REST API.
Let's generate a wallet for Bitcoin first.
Curl
Javascript
1
curl --request GET \
2
--url 'https://api-eu1.tatum.io/v3/bitcoin/wallet' \
3
--header 'accept: application/json' \
4
--header 'x-api-key: YOUR_API_KEY' # Use API key from step 1
Copied!
1
// You need to install Javascript library
2
// https://github.com/tatumio/tatum-js
3
const {generateWallet, Currency} = require("@tatumio/tatum");
4
​
5
const btcWallet = generateWallet(Currency.BTC, false);
6
console.log(btcWallet);
Copied!
The output will look like this:
1
{
2
"mnemonic": "panel result private alien mail remove shift mandate loyal analyst ghost mutual swear faint road raccoon patient cost kit impact believe fun brown way",
3
"xpub": "xpub6FL3wUosaTYs2U4Tf8qk7XexhzHup8UHKhDKKMi72SJpip6QmBjPaeEwCkXmFscMC6B5n3Y6uHPoaxRUKHQRuYXAYCEs9kbhGVf2JXSjomi"
4
}
Copied!

3. Creating a Bitcoin address

We can create more than 4 billion addresses from 1 wallet. Each address has its own unique index, so let's create an address with the number 1.
Curl
Javascript
1
# Replace <<xpub>> with xpub you've got from step 2
2
curl --request GET \
3
--url 'https://api-eu1.tatum.io/v3/bitcoin/address/<<xpub>>/1' \
4
--header 'accept: application/json' \
5
--header 'x-api-key: YOUR_API_KEY'
Copied!
1
// Replace <<xpub>> with xpub you've got from step 2
2
const {generateAddressFromXPub, Currency} = require("@tatumio/tatum");
3
​
4
const btcAddress = generateAddressFromXPub(Currency.BTC, false, "<<xpub>>", 1);
5
console.log(btcAddress);
Copied!
The output will look like this:
1
{
2
"address": "1HDSRhBkAvvaij7SYmgyYerDPA2zP3Dxjf"
3
}
Copied!
So there you have it. We've created a blockchain address for Bitcoin. We can now accept transactions at this address. To send a transaction from the address somewhere else, we need to know the private key to sign the transaction.

4. Creating a private key

Since we created address no. 1 for the Bitcoin wallet, we need to create a private key with the same index from our wallet.
Working with private keys
In this guide, we are using our API to create blockchain wallets and private keys, which is fine for testing and demo purposes.
However, for production use, your private keys and mnemonics should never leave your security perimeter. To correctly and securely generate wallets and work with private keys, we recommend using Tatum CLI from the command line or our complex key management system, Tatum KMS.
Here's the call to generate a private key for the address we have created:
Curl
Javascript
1
# Replace <<mnemonic>> with mnemonic you've got from step 2
2
curl --request POST \
3
--url 'https://api-eu1.tatum.io/v3/bitcoin/wallet/priv' \
4
--header 'Content-Type: application/json' \
5
--header 'x-api-key: YOUR_API_KEY' \
6
--data-raw '{
7
"mnemonic": "<<mnemonic>>",
8
"index": 1
9
}'
Copied!
1
// Replace <<xpub>> with xpub you've got from step 2
2
const {generateAddressFromXPub, Currency} = require("@tatumio/tatum");
3
​
4
const btcAddress = generateAddressFromXPub(Currency.BTC, false, "<<xpub>>", 1);
5
console.log(btcAddress);
Copied!
The output will look like this:
1
{
2
"key": "L2JL4C4TDsHQejaBm3aw9WyVdVkoL4WfoHUMS11WMpFbWZVKw8yx"
3
}
Copied!
Now, we have a private key to our address and we can send Bitcoin from this address to anyone.
Never disclose your mnemonic or private keys to anyone!
Excellent work, congratulations on your first app! Now let's take a look at Tatum's architecture.
Last modified 1mo ago