Build Crypto Wallets using APIs

build crypto wallets

Blockchain seems to be going through a daily self-learning experience. The goal is simple: secure, fast and robust transaction completion. Crypto wallets are one of the main products where these changes are quickly seen. Let’s help you build crypto wallets then!

Nowadays, crypto wallets are hardwares or softwares that are being used to store ownership information. These are the addresses and the secure (private) digital keys. Priorities have been diversified in a sense that users are reaching out for long-term solutions that cover:

  • access
  • support
  • security

Cryptocurrency wallet development companies are filling the market. Now they can be set to be compared in important metrics, unlike years ago. These metrics include the number of users in the platform, the number of supported currencies, the number of posed threats in the past, etc. The company may either hold the client’s properties on their behalf or take full responsibility through its high encryption modes or it can provide private keys to the user.

 In addition, APIs are being used as a backbone to the processes. Here are a few examples what can be done with Blockchain APIs using Bitcoin support, following these docs:

1. Generate a hot wallet for each user

The user can either create a normal wallet or HD wallet.

Create Normal Wallet

  • conn = http.client.HTTPConnection(“https://api.cryptoapis.io”)
    payload = “{\n\t\”addresses\”: [\”2MuLVwmhmxM6RzNBZ347sW9xyRtJoHf8v77\”,\”n3jYBjCzgGNydQwf83Hz6GBzGBhMkKfgL1\”, \”2NDhzMt2D9ZxXapbuq567WGeWP7NuDN81cg\”]}”
    headers = {
    Content-Type’: “application/json”,
    ‘X-API-Key’: “my-api-key”
    }
    conn.request(“POST”, “/v1/bc/btc/testnet/addresses/show-multiple, payload, headers)
    res = conn.getresponse()
    data = res.read()
    print(data.decode(“utf-8”))

Mandatory attributes for this request is:

  1. WALLET_NAME
  2. ADDRESSES array

Create HD Wallet

This facilitates the management of more than 1 address under 1 $NAME. (check “HD Wallet” in our glossary)

  • import http.clientconn = http.client.HTTPConnection(“https://api.cryptoapis.io”)
    payload = “{\n\t\”walletName\” : \”demohdwallet\”,\n\t\”addressCount\” : 5,\n\t\”password\” : \”8a0690d2cd4fad1371090225217bb1425b3700210f51be6111eb225d5142ac32\”\n}”
    headers = {
    ‘Content-Type’: “application/json”,
    ‘X-API-Key’: “my-api-key”}
    conn.request(“POST”, “/v1/bc/btc/mainnet/wallets/hd”, payload, headers)
    res = conn.getresponse()
    data = res.read()
    print(data.decode(“utf-8”))

Mandatory attributes for this request are:

  1. WALLET_NAME
  2. ADDRESSES count
  3. PASSWORD

2. Auto forward the funds to a wallet

This is a POST request. Firstly, the user sets the connection. Then forwarding payments from HD wallet is done with this data:

  • {
    “from”: “${FROM_ADDRESS}”,
    “to”: “${TO_ADDRESS}”,
    “callback”: “${CALLBACK_URL}”,
    “wallet”: ${HD_WALLET_NAME},
    “password”: ${WALLET_PASSWORD}
    “confirmations”: ${CONFIRMATIONS}
    “fee”: ${FEE} (optional)
    }

3. Check the balance

GET request based on the WALLET_NAME includes balance details

Check balance in Normal Wallet

  • import http.clientconn = http.client.HTTPConnection(“https://api.cryptoapis.io”)
    headers = {
    “Content-Type”: “application/json”,
    “X-API-Key”, “my-api-key”
    }
    conn.request(“GET”, “/v1/bc/btc/testnet/wallets/demowallet”, headers=headers)
    res = conn.getresponse()
    data = res.read()
    print(data.decode(“utf-8”))

Check balance in HD Wallet

  • import http.client
    conn = http.client.HTTPConnection(“https://api.cryptoapis.io”)
    headers = {
    “Content-Type”: “application/json”,
    “X-API-Key”, “my-api-key”
    }
    conn.request(“GET”, “/v1/bc/btc/testnet/wallets/hd/demohdwallet”, headers=headers)
    res = conn.getresponse()
    data = res.read()
    print(data.decode(“utf-8”))

4. Check wallet transactions

This GET requests details regarding the transaction using the transaction id

  • import requests
    url = ‘https://api.cryptoapis.io/v1/bc/btc/mainnet/txs
    /txid/5a4ebf66822b0b2d56bd9dc64ece0bc38ee7844a23ff1d7320a88c5fdb2ad3e2′
    headers = {
    “Content-Type”: “application/json”,
    “X-API-Key”: “my-api-key”
    }
    response = requests.get(url, headers=headers)

Note: The mentioned code examples are not to be approached in a parallel manner; meaning that the expected results will show as each request has been done serially or sequentially. And the code is in Python, but it can be changed to JS, Node.js, PHP, Java, GO, Ruby etc.

Companies can build crypto wallets through these endpoints. This saves time and effort by focusing on the application logic. The more companies define and validate their use cases, the more competitive advantages they gain.