Hemi
DiscordGithub
  • 🏠Main
    • Welcome to the Hemi Docs
    • Getting Started
      • Developer Quickstart
      • Enthusiast Quickstart
      • Miner Quickstart
    • Network Details
  • ⛰️Foundational Topics
    • The Architecture
      • Consensus and Security Protocols
      • Ethereum Rollups
        • Pros & Cons
        • Decentralized Rollups
      • Sequencer Consensus
        • Proof-of-Stake (PoS)
        • PoS-Only Pitfalls
        • PoS Solutions
      • Proof-of-Proof (PoP)
        • Proof-of-Proof Consensus & Bitcoin Finality
        • Proof-of-Proof vs. Merged Mining
        • Running a PoP Mining
      • Tunnels
        • Ethereum Tunnel
        • Bitcoin Tunnel
      • Ethereum Virtual Machine (EVM)
      • Blocks
      • Transactions
      • Gas
    • Nodes & Clients
      • Node Guides
    • Wallet Support
  • 📖How-To Tutorials
    • Using Hemi
      • Wallet Setup
        • EVM Wallet Setup
        • BTC Wallet Setup
          • Switch Bitcoin Networks
      • Tunnel from Ethereum
        • Tunnel ERC20s via Native Tunnel
        • Tunnel ERC20s via 3rd Party
          • Tunnel via Stargate
      • Tunnel from Bitcoin
        • Tunnel BTC via Native Tunnel
        • Tunnel BTC via 3rd Party
      • Stake
      • Developer Tooling
        • Set Up a Safe Wallet
        • Create a Capsule
      • PoP Mining
        • CLI PoP Miner
          • (Testnet) Add tHEMI to MetaMask
          • (Mainnet) Add PoPPoints to Metamask
        • Web PoP Miner (deprecated)
    • Developing on Hemi
      • General
        • HelloWorld.sol
        • Deploy an ERC-20 Token
      • hVM & hBK
        • Using the hBK Demo App
        • Get Bitcoin Balance with Remix
  • ⚙️Building Bitcoin Apps
    • Introduction
    • Hemi Virtual Machine (hVM)
      • Motivation
      • Feature Summary
      • Deploy on hVM
    • Hemi Bitcoin Kit (hBK)
      • Overview
      • hBK Smart Contract
  • ⚙️Tooling
    • viem
    • Contract Addresses
    • Contract Verification
    • Data Indexing
    • Oracles
  • 📝Incentives
    • Points
    • Grants
    • Retroactive Funding
    • One-Off Spends
  • ⚡Additional Resources
    • Partners
    • FAQ
    • Official Links
    • Brand Kit
  • 📨Send Feedback
    • Bug Report
    • Contact Us
Powered by GitBook
On this page
  • 🌐 Overview
  • 🏁 Prerequisites
  • 1. Get Address Balance
  • 2. Get Latest Block Header
  • 3. Get Block Header by Height
  • 4. Get Transaction Details
  • 5. Get Transaction Confirmations
  • 6. List Address UTXOs

Was this helpful?

Edit on GitHub
Export as PDF
  1. How-To Tutorials
  2. Developing on Hemi
  3. hVM & hBK

Using the hBK Demo App

📜 TL;DR:

  • The Hemi Bitcoin Kit (hBK) Demo App enables seamless interaction with Bitcoin data in an Ethereum-compatible environment.

  • Key features include:

    • Query Bitcoin address balances.

    • Retrieve the latest block header or specific block headers by height.

    • Fetch Bitcoin transaction details and confirmation counts.

    • List UTXOs (Unspent Transaction Outputs) for a Bitcoin address.

  • Developers can easily integrate Bitcoin data into dApps without external services, simplifying Bitcoin-aware application development.


🌐 Overview

  • The Hemi Bitcoin Kit (hBK) Demo App is a tool designed for developers to interact with Bitcoin blockchain data directly from an Ethereum-compatible environment.

  • This demo app provides a user-friendly interface for querying Bitcoin information.

  • By abstracting the complexities of interacting with Bitcoin data, the app allows developers to seamlessly retrieve and use Bitcoin blockchain data in their dApps without needing external services.

  • This makes it an effective resource for experimenting with Bitcoin-aware applications and understanding hBK’s capabilities within the Hemi ecosystem.


🏁 Prerequisites

To follow along, you’ll need:

  • Nothing!


1. Get Address Balance

Retrieves the current balance (in satoshis) of a specified Bitcoin address.

// Sample output
514853116

Verifying our Output

Navigate to https://blockstream.info and input the Bitcoin address to confirm the above output.


2. Get Latest Block Header

Returns the latest Bitcoin block header containing metadata like hash, height, and timestamp.

// Sample output
{
  "height": 3520643,
  "blockHash": "0x00000000002be0cd198317218f374a484bd0b3c5fe4eaf098bb5dfc97d0fb8a7",
  "version": 536870912,
  "previousBlockHash": "0x00000000000000019bebcf5e1d1dc6baf664c5859f82add17f5543b3018c82de",
  "merkleRoot": "0xcc50e3a3ca39e37a7ccd5867a7f2a82192c98861f28a50d94f558305672d65de",
  "timestamp": 1733342457,
  "bits": 486604799,
  "nonce": 1100503385
}

Verifying our Output

Navigate to https://blockstream.info and input the Block header to confirm the above output.


3. Get Block Header by Height

Fetches the block header for a specific block height.

// Sample output
{
  "height": 1321358,
  "blockHash": "0x000000000000023bf34cd847acfcd73ad3b010f9a9434069e9bc5941cf61a1bf",
  "version": 536870912,
  "previousBlockHash": "0x00000000000002d213e95ae971060d49f93d51c3ce0ac84c452f76a45c962036",
  "merkleRoot": "0xd0f34249cd9b3929b56a418ab6fe965e685f1765f2dcd605ed08a1382199e506",
  "timestamp": 1527980035,
  "bits": 436539705,
  "nonce": 3252632758
}

Verifying our Output

Navigate to https://blockstream.info and input the Block header height to confirm the above output.


4. Get Transaction Details

Fetches the details of a Bitcoin transaction using its transaction ID, including all of its inputs and outputs.

// Sample output

{
  "containingBlockHash": "0x00000000280425e8f1f2170230b3946bf4bf058d5ef9677a3f361d2fbead994f",
  "transactionVersion": "2",
  "size": "116",
  "vSize": "116",
  "lockTime": "0",
  "inputs": [
    {
      "inValue": "4834",
      "inputTxId": "0xe7b262c5ead12343f1c5734b65848fbe19362907fafcd9d07c999c9aa2ec79f0",
      "sourceIndex": "11689",
      "scriptSig": "0x",
      "sequence": "2",
      "fullScriptSigLength": "0",
      "containsFullScriptSig": false
    }
  ],
  "outputs": [],
  "totalInputs": "1",
  "totalOutputs": "0",
  "containsAllInputs": true,
  "containsAllOutputs": true
}

Verifying our Output

Navigate to https://blockstream.info and input the transaction ID to confirm the above output.


5. Get Transaction Confirmations

Retrieves the number of confirmations for a specific transaction based on its transaction ID.

// Sample output
653358

Verifying our Output

Navigate to https://blockstream.info and input the transaction ID to confirm the above output.


6. List Address UTXOs

Returns the UTXOs (Unspent Transaction Outputs) of a Bitcoin address, with pagination support.

// Sample output
[
  {
    "txId": "0xbd7b64df58115ca4e9c273b0bae477de3607154412a517dc31fdf5cd9f46e048",
    "index": "0",
    "value": "197506250"
  },
  {
    "txId": "0x452142a3dc4c9231ef8fd26674fa31ad55dfac5e880183d4b9d7452dd84e8b4f",
    "index": "0",
    "value": "199244750"
  },
  ...
]

Verifying our Output

Navigate to https://blockstream.info and input the Bitcoin address to confirm the above output.

PrevioushVM & hBKNextGet Bitcoin Balance with Remix

Last updated 5 months ago

Was this helpful?

📖