# Introduction

The **Hemi Network** is a modular Layer-2 protocol for superior scaling, security, and interoperability, powered by Bitcoin and Ethereum.

Whereas other projects approach Bitcoin and Ethereum as ecosystem silos, Hemi views them as components of a single supernetwork. This unlocks new levels of programmability, portability, and potential.

At Hemi's core: the **Hemi Virtual Machine (hVM)**, which incorporates a full Bitcoin node within an **Ethereum Virtual Machine**.

Combined with the **Hemi Bitcoin Kit (hBK)**, developers have a familiar yet powerful platform for creating Hemi decentralized applications (hApps).

***

## Overview

* The **Hemi Network** represents a different way of thinking about Layer-2 scaling, by approaching **Bitcoin** and **Ethereum** as components of a supernetwork.
* This modular protocol aims to scale these networks and maximize their utility, creating a more connected and efficient blockchain ecosystem.
* Through features such as the **hVM**, Hemi equips developers with robust tools for building next-generation **dApps** with Bitcoin *and* Ethereum interoperability.

***

## The Benefits of Hemi

* **Ease of Development**

  The Hemi Virtual Machine (hVM) integrates a full Bitcoin node within an Ethereum Virtual Machine (EVM), providing developers with a familiar programming interface while harnessing the power of both Bitcoin and Ethereum.
* **Bitcoin Programmability**

  Building with the Hemi Bitcoin Kit (hBK) provides smart contracts with highly granular indexed views of Bitcoin state, unlocking Bitcoin DeFi applications were previously impractical or impossible to execute via an EVM.
* **Bitcoin Superfinality**

  Hemi's **Proof-of-Proof (PoP)** consensus mechanism ensures transactions surpass Bitcoin's level of security in just a few hours.
* **Trustless Cross-chain Portability**

  The hVM's unique awareness of Bitcoin's and Ethereum's states enables secure, seamless asset transfers between Hemi and other chains through its "Tunnels" feature.
* **Extensibility**

  Hemi allows external projects to create their own chains secured by Hemi's technology, facilitating Bitcoin-Security-as-a-Service and enhancing dual-chain interoperability.
* **Superior Asset Handling**

  Advanced on-chain functionalities, including routing, time-lock, and password protection, are made possible through Hemi, elevating asset management and security.


# Getting Started

## Overview

Welcome to the technical documentation for Hemi, a Layer-2 solution for Bitcoin and Ethereum blockchains that offers true scalability and interoperability.&#x20;

This documentation is designed to guide builders and enthusiasts in understanding and utilizing the [Hemi Virtual Machine (hVM)](/building-bitcoin-apps/hemi-virtual-machine-hvm). The hVM is Hemi's modular protocol that provides developers with a familiar programming interface.

***

## Navigating the Docs

Our documentation is organized into the following sections to help you find relevant information quickly:

* **Quickstart:** Whether you plan to develop, explore, or mine on Hemi, we have identified some crucial resources to quickstart your journey.
* **Foundational Topics:** Learn about the architecture, sequencer consensus, PoP consensus & Bitcoin finality, tunneling, and more.
* **How-To Tutorials:** Whether you are using or developing on Hemi, these basics will get you started! Set up your MetaMask Wallet, tunnel ETH and BTC to Hemi, start with Remix IDE, deploy an ERC-20 token and run a PoP miner.
* **Tooling:** Understand and access the tools required to build on Hemi.
* **Incentives:** Check out our points, grants, retroactive funding, and one-off spends.
* **Additional Resources:** Partners inquiry, FAQ, official links, and our brand kit.
* **Send Feedback:** We'd love to hear from you, good or bad! Found a bug? Got a hackathon coming up? Slide into our DMs.


# Developer Quickstart

{% hint style="info" %}

## 📜 **TL;DR:**

* What is the [Hemi Virtual Machine (hVM)](/building-bitcoin-apps/hemi-virtual-machine-hvm)?
* [Set up an EVM and BTC wallet](/foundational-topics/wallet-support) and connect to Hemi Network.
* [Tunnel ERC20s](/how-to-tutorials/using-hemi/tunnel-from-ethereum), including Ethereum, to Hemi.
* [Tunnel BTC to Hemi.](/how-to-tutorials/using-hemi/tunnel-from-bitcoin)
* Discover the [Hemi Bitcoin Kit (hBK)](/building-bitcoin-apps/hemi-bitcoin-kit-hbk) and [hBK Demo App](/how-to-tutorials/developing-on-hemi/hvm-and-hbk/using-the-hbk-demo-app).
* View our [Github](https://github.com/hemilabs), join our [Discord](https://discord.gg/hemixyz), and [refer a friend](https://points.absinthe.network/hemi/start)!
  {% endhint %}

***

## 🌐 **Welcome to the Hemi Developer Quickstart Guide!**&#x20;

This guide provides an overview of the essential steps and resources to get you started with building on Hemi. Whether you’re new to blockchain development or an experienced web3 developer, this guide will help you navigate Hemi’s ecosystem and leverage its full potential.

***

### 1️⃣ Explore the Hemi Network

Begin by familiarizing yourself with the Hemi network’s architecture, key features, and its unique approach to interoperability and scalability.&#x20;

* Learn about Hemi's [Architecture](/foundational-topics/the-architecture).
* What are Hemi [Tunnels](/foundational-topics/the-architecture/tunneling)?
* How does [PoP mining](/foundational-topics/the-architecture/proof-of-proof/pop-mining) secure Hemi?
* What is the [Hemi Virtual Machine (hVM)](/building-bitcoin-apps/hemi-virtual-machine-hvm)?
* Which [ETH and BTC wallets](/foundational-topics/wallet-support) does Hemi currently support?
* Read the [Hemi Whitepaper](https://hemi.xyz/whitepaper).

***

### 2️⃣ Set Up Your Development Environment

Prepare your development environment to start building on Hemi by setting up the necessary tools and configurations. This step ensures you have everything in place to interact with the Hemi network effectively.

* [Set up an EVM wallet ](/how-to-tutorials/using-hemi/wallet-setup/metamask-wallet-setup)and [connect to the Hemi Network.](/discover/network-details)
* [Set up a BTC wallet](/how-to-tutorials/using-hemi/wallet-setup/btc-wallet-setup).
* Join our [Discord](https://discord.gg/hemixyz) and collaborate with the community.

***

### 3️⃣ Interact with Hemi Apps

Dive into the Hemi ecosystem by exploring and interacting with decentralized applications (dApps) built on the network. This hands-on approach helps you understand Hemi’s functionality and how dApps operate within the blockchain environment.

* Visit [Crypto Chords](https://cryptochords.hemi.xyz) and see how we interact with Hemi Network endpoints.
* Start PoP mining using the [CLI](/how-to-tutorials/using-hemi/pop-mining/setup-part-1).
* [Tunnel ETH and other ERC20s](/how-to-tutorials/using-hemi/tunnel-from-ethereum) to Hemi.
* [Tunnel BTC](/how-to-tutorials/using-hemi/tunnel-from-bitcoin) to Hemi.
* Mint an OnlyMeID via [DEMOS](https://app.demos.global) on Hemi.
* Explore the [Hemi Bitcoin Kit](/how-to-tutorials/developing-on-hemi/hvm-and-hbk/using-the-hbk-demo-app) via our [demo app.](https://bitcoin-kit.hemi.xyz)

***

### 4️⃣ Build on Hemi!

Start developing your own decentralized applications (dApps) on Hemi using its powerful suite of developer tools and resources. This section will guide you through the process of creating, testing, and deploying your projects on the Hemi network.

* [Deploy a smart contract on Hemi](/how-to-tutorials/developing-on-hemi/general/using-remix-ide).
* [Deploy an ERC-20 token on Hemi](/how-to-tutorials/developing-on-hemi/general/erc-20).
* Learn about developing with [viem](/tooling/viem).
* Discover the [Hemi Bitcoin Kit (hBK)](/building-bitcoin-apps/hemi-bitcoin-kit-hbk) and [build Bitcoin apps](/building-bitcoin-apps/introduction).
* [Dive into our Github](https://github.com/hemilabs).

***

## ❓ What Now?

Congratulations on getting started with Hemi! 🎉&#x20;

Now that you’ve set up your environment, explored various apps, and begun building on the network, here are the next steps to deepen your engagement and maximize the potential of your development journey on Hemi.

* Learn about[ incentives](/incentives/incentives) and our rewards [dashboard](https://points.absinthe.network/hemi/start).
* [Create a Capsule](/how-to-tutorials/using-hemi/developer-tooling/create-a-capsule) with Hemi assets.
* [Set up a Safe Wallet](/how-to-tutorials/using-hemi/developer-tooling/set-up-a-safe-wallet) on Hemi.
* [Refer a friend](https://points.absinthe.network/hemi/start) to Hemi!
* Follow us on [X](https://x.com/hemi_xyz).

***

## 📐Troubleshooting

If you encounter any issues or need assistance at any step, the following resources are available to help:

* [Discord Channel](https://discord.com/channels/1202677849887080508/1217860733820469298)
* Email <support@hemi.xyz>


# Enthusiast Quickstart

{% hint style="info" %}

## 📜 **TL;DR:**

* [Set up an EVM and BTC wallet](/foundational-topics/wallet-support) and connect to Hemi Network.
* [Tunnel ERC20s](/how-to-tutorials/using-hemi/tunnel-from-ethereum), including Ethereum, to Hemi.
* [Tunnel BTC to Hemi.](/how-to-tutorials/using-hemi/tunnel-from-bitcoin)
* Discover the [hBK Demo App](/how-to-tutorials/developing-on-hemi/hvm-and-hbk/using-the-hbk-demo-app).
* View our [Github](https://github.com/hemilabs), join our [Discord](https://discord.gg/hemixyz), and [refer a friend](https://points.absinthe.network/hemi/start)!
  {% endhint %}

***

## 🌐 **Welcome to the Hemi Developer Quickstart Guide!**&#x20;

This guide provides an overview of the essential steps and resources to get you started navigating Hemi’s ecosystem and leveraging its full potential.

***

### 1️⃣ Explore the Hemi Network

Begin by familiarizing yourself with the Hemi network’s architecture, key features, and its unique approach to interoperability and scalability.&#x20;

* What are Hemi [Tunnels](/foundational-topics/the-architecture/tunneling)?
* How does [PoP mining](/foundational-topics/the-architecture/proof-of-proof/pop-mining) secure Hemi?
* What is the [Hemi Virtual Machine (hVM)](/building-bitcoin-apps/hemi-virtual-machine-hvm)?
* Which [ETH and BTC wallets](/foundational-topics/wallet-support) does Hemi currently support?

***

### 2️⃣ Set Up Your Wallets

Prepare your various wallets to start exploring Hemi by setting up an EVM and BTC wallet. This step ensures you have everything in place to interact with the Hemi network effectively.

* [Set up an EVM wallet ](/how-to-tutorials/using-hemi/wallet-setup/metamask-wallet-setup)and [connect to the Hemi Network.](/discover/network-details)
* [Set up a BTC wallet](/how-to-tutorials/using-hemi/wallet-setup/btc-wallet-setup).
* Join our [Discord](https://discord.gg/hemixyz) and collaborate with the community.

***

### 3️⃣ Interact with Hemi Apps

Dive into the Hemi ecosystem by exploring and interacting with decentralized applications (dApps) built on the network. This hands-on approach helps you understand Hemi’s functionality and how dApps operate within the blockchain environment.

* Visit [Crypto Chords](https://cryptochords.hemi.xyz) and see how we interact with Hemi Network endpoints.
* Start PoP mining using the [CLI](/how-to-tutorials/using-hemi/pop-mining/setup-part-1).
* [Tunnel ETH and other ERC20s](/how-to-tutorials/using-hemi/tunnel-from-ethereum) to Hemi.
* [Tunnel BTC](/how-to-tutorials/using-hemi/tunnel-from-bitcoin) to Hemi.
* Mint an OnlyMeID via [DEMOS](https://app.demos.global) on Hemi.
* Explore the [Hemi Bitcoin Kit](/how-to-tutorials/developing-on-hemi/hvm-and-hbk/using-the-hbk-demo-app) via our [demo app.](https://bitcoin-kit.hemi.xyz)

***

## ❓ What Now?

Congratulations on getting started with Hemi! 🎉&#x20;

Now that you’ve set up your environment, explored various apps, and begun building on the network, here are the next steps to deepen your engagement and maximize the potential of your journey on Hemi.

* Learn about[ incentives](/incentives/incentives) and our rewards [dashboard](https://points.absinthe.network/hemi/start).
* [Create a Capsule](/how-to-tutorials/using-hemi/developer-tooling/create-a-capsule) with Hemi assets.
* [Set up a Safe Wallet](/how-to-tutorials/using-hemi/developer-tooling/set-up-a-safe-wallet) on Hemi.
* [Refer a friend](https://points.absinthe.network/hemi/start) to Hemi!
* Follow us on [X](https://x.com/hemi_xyz).

***

## 📐Troubleshooting

If you encounter any issues or need assistance at any step, the following resources are available to help:

* [Discord Channel](https://discord.com/channels/1202677849887080508/1217860733820469298)
* Email <support@hemi.xyz>


# Miner Quickstart

{% hint style="info" %}

## 📜 **TL;DR:**

* Learn about [PoP mining](/foundational-topics/the-architecture/proof-of-proof/pop-mining) and run a [PoP Miner](/how-to-tutorials/using-hemi/pop-mining/setup-part-1).
* View our [Github](https://github.com/hemilabs), join our [Discord](https://discord.gg/hemixyz), and [refer a friend](https://points.absinthe.network/hemi/start)!
  {% endhint %}

***

## 🌐 **Welcome to the Hemi Miner Quickstart Guide!**&#x20;

This guide provides an overview of the essential steps and resources to get you started PoP mining  on Hemi.

***

### 1️⃣ Explore the Hemi Network

Begin by familiarizing yourself with some of the key Hemi network terms and features.

* What is [Proof-of-Proof](/foundational-topics/the-architecture/proof-of-proof) (PoP)?
* Learn about [PoP Consensus and Bitcoin Finality](/foundational-topics/the-architecture/proof-of-proof/pop-consensus-and-bitcoin-finality).
* An overview of [PoP mining](/foundational-topics/the-architecture/proof-of-proof/pop-mining) and [mining rewards](/foundational-topics/the-architecture/proof-of-proof/pop-mining).

***

### 2️⃣ Set Up Your Wallets

Prepare your various wallets to start PoP mining on Hemi by setting up an EVM and BTC wallet.&#x20;

* \[*Optional*] [Set up an EVM wallet](/how-to-tutorials/using-hemi/wallet-setup/metamask-wallet-setup) and [connect to Hemi](/discover/network-details).
* \[*Optional*] [Set up a BTC wallet](/how-to-tutorials/using-hemi/wallet-setup/btc-wallet-setup).
* \[*Optional*] Mint an OnlyMeID via [DEMOS](https://app.demos.global) on Hemi.
* Join our [Discord](https://discord.gg/hemixyz) and chat with the community.

***

### 3️⃣ Start Mining

The [CLI (Command Line Interface) PoP Miner](/how-to-tutorials/using-hemi/pop-mining/setup-part-1) is designed for long-term, continuous operation, requiring some technical knowledge but provides robust security and operational efficiency.&#x20;

***

## ❓ What Now?

Congratulations 🎉 Now that you’re PoP miner is running, here are some next steps to deepen your engagement and maximize the potential of your journey on Hemi.

* [Tunnel Ethereum and other ERC20s to Hemi](/how-to-tutorials/using-hemi/tunnel-from-ethereum/tunnel-eth-to-hemi).
* Learn about[ incentives](/incentives/incentives) and our rewards [dashboard](https://points.absinthe.network/hemi/start).
* [Refer a friend](https://points.absinthe.network/hemi/start) to Hemi!.
* Follow us on [X](https://x.com/hemi_xyz).
* **Become a** [**Hemi Developer**](/discover/getting-started/developers)**.**

***

## 📐Troubleshooting

If you encounter any issues or need assistance at any step, the following resources are available to help:

* [**Discord Channel**](https://discord.com/channels/1202677849887080508/1217860733820469298)
* Email <support@hemi.xyz>


# Network Details

Everything you need to connect to the Hemi network.

## Hemi Mainnet

<table><thead><tr><th width="293"></th><th></th></tr></thead><tbody><tr><td>Chain ID</td><td><code>43111</code></td></tr><tr><td>Currency symbol / Gas Token</td><td><code>ETH</code></td></tr><tr><td>RPC URL</td><td><a href="https://rpc.hemi.network/rpc">https://rpc.hemi.network/rpc</a></td></tr><tr><td>Block Explorer URL</td><td><a href="https://explorer.hemi.xyz">https://explorer.hemi.xyz</a></td></tr></tbody></table>

{% hint style="info" %}
Need to bring assets to Hemi? Visit the [**Hemi Tunnel**](https://app.hemi.xyz/en/tunnel/).
{% endhint %}

## Hemi Testnet

{% hint style="warning" %}
Testnet is a testing environment for validating new features and deployments before they reach mainnet. Testnet tokens have no monetary value — do not send real assets to testnet addresses. Hemi testnet may undergo maintenance or be reset without notice.
{% endhint %}

<table><thead><tr><th width="289"></th><th></th></tr></thead><tbody><tr><td>Chain ID</td><td><code>743111</code></td></tr><tr><td>Currency symbol / Gas Token</td><td><code>ETH</code></td></tr><tr><td>RPC URL</td><td><a href="https://testnet.rpc.hemi.network/rpc">https://testnet.rpc.hemi.network/rpc</a></td></tr><tr><td>Block Explorer URL</td><td><a href="https://testnet.explorer.hemi.xyz">https://testnet.explorer.hemi.xyz</a></td></tr></tbody></table>

{% hint style="info" %}
Public RPC endpoints are rate-limited to approximately 300 requests per minute and are intended for development and testing. These limits are subject to change. For production applications, use a third-party provider.
{% endhint %}

***

## Third-Party RPC Providers

We partner with leading node providers to allow dApps to seamlessly integrate with the Hemi network. These providers offer reliable and scalable RPC endpoints, allowing you to concentrate on development while they handle node infrastructure.

#### dRPC

[dRPC](https://drpc.org) provides high-performance RPC access to Hemi, backed by a distributed network of node providers. A free tier is available.

[Sign up at drpc.org →](https://drpc.org)

<table><thead><tr><th width="132.30859375">Network</th><th>HTTPS</th><th>WebSocket</th></tr></thead><tbody><tr><td>Mainnet</td><td><code>https://hemi.drpc.org</code></td><td><code>wss://hemi.drpc.org</code></td></tr><tr><td>Testnet</td><td><code>https://hemi-testnet.drpc.org</code></td><td><code>wss://hemi-testnet.drpc.org</code></td></tr></tbody></table>

#### DIN (via Infura)

[DIN](https://www.infura.io/solutions/decentralized-infrastructure-service) is Infura's Decentralized Infrastructure Network. Hemi is available on all Infura plans, including the free tier. An API key is required.

[Sign up at infura.io →](https://www.infura.io)

<table><thead><tr><th width="131.5390625">Network</th><th>HTTPS</th></tr></thead><tbody><tr><td>Mainnet</td><td><code>https://hemi-mainnet.infura.io/v3/YOUR_API_KEY</code></td></tr><tr><td>Testnet</td><td><code>https://hemi-testnet.infura.io/v3/YOUR_API_KEY</code></td></tr></tbody></table>


# Token Contract Details

Official Hemi token contrat

## `$HEMI` **Contract Details**

<table data-full-width="false"><thead><tr><th width="165.0078125">Network</th><th>Contract Address</th></tr></thead><tbody><tr><td>Ethereum</td><td><a href="https://etherscan.io/address/0xeb964a1a6fab73b8c72a0d15c7337fa4804f484d#code"><code>0xeb964a1a6fab73b8c72a0d15c7337fa4804f484d</code></a></td></tr><tr><td>Hemi</td><td><a href="https://explorer.hemi.xyz/address/0x99e3dE3817F6081B2568208337ef83295b7f591D"><code>0x99e3de3817f6081b2568208337ef83295b7f591d</code></a></td></tr><tr><td>BNB Chain</td><td><a href="https://bscscan.com/address/0x5ffd0eadc186af9512542d0d5e5eafc65d5afc5b"><code>0x5ffd0eadc186af9512542d0d5e5eafc65d5afc5b</code></a></td></tr></tbody></table>


# The Architecture

{% hint style="info" %}

## 📜 **TL;DR:**

* **The Hemi Network operates four** kinds of specialized nodes: Bitcoin finality governors, Bitcoin-secure sequencers, Proof-of-Proof miners, and a modified Geth node.
* The network’s nodes maintain its EVM and ensure decentralized operability across **Bitcoin**, **Ethereum**, and other EVM-compatible chains.
  {% endhint %}

***

## 🌐 Overview

* The Hemi Network connects to both the **Bitcoin and Ethereum networks**, allowing asset portability across both, enabling a third-party cross-chain ecosystem. To create this highly secure multichain ecosystem, the Hemi Network operates several kinds of decentralized nodes: **Bitcoin finality governors, Bitcoin-secure sequencers, Proof-of-Proof miners, and a modified Geth node.**

***

## 🛡️ **Bitcoin Finality Governors (BFGs)**

* Regulate the network's security status by analyzing Bitcoin blocks for Hemi Network state proofs.
* Determine the network's finality status, ensuring security.
* Coordinate with Bitcoin-secure sequencers and proof-of-proof miners.

***

## ⚙️ **Bitcoin-Secure Sequencers (BSS Nodes)**

* Integrate Hemi Network transactions with Ethereum mainnet transactions.
* Maintain the network's consensus layer and manage staking, unstaking, and slashing operations.
* Ensure a seamless connection between the Hemi Network and Ethereum for asset transfers.

***

## 🛠️Modified Geth Node

* Operates as a customized Ethereum node, providing compatibility and connectivity between the Hemi Network and Ethereum.
* Ensures data synchronization and transaction processing within the Hemi Network ecosystem.

***

## 🔗 **Proof-of-Proof Miners (PoP Miners)**

* Secure the network by embedding state proofs into the Bitcoin blockchain.
* Hash network headers to create cryptographic proofs and publish these to Bitcoin.
* Receive tokens as rewards for their contributions.

***

{% hint style="success" %}

## 👀 Sneak Peek WIP

***Challengers***

* *Monitor the Hemi Network for data accuracy and completeness.*
* *Initiate challenge-response processes for discrepancies, ensuring integrity.*
* *Receive a portion of the penalized stake for successful challenges.*
  {% endhint %}

***

### ⚡️ Achieving Decentralized Interoperability

This innovative approach ensures secure, decentralized interoperability among Bitcoin, Ethereum, the Hemi Network, and other EVM-compatible chains.


# Consensus and Security Protocols

{% hint style="info" %}

### 📜 **TL;DR:**

* Incorporates Bitcoin's security to prevent attacks, with PoP Miners embedding consensus data on the Bitcoin blockchain.
* **Rewards PoP Miners** in native tokens for strengthening consensus.
* **Utilizes Bitcoin confirmations** to ensure network integrity, achieving "Bitcoin Finality" for robust defense against reorganizations.
  {% endhint %}

***

{% hint style="success" %}

### 👀 Sneak Peek WIP

***Overview***

The Hemi Network's sequencer consensus combines **Proof-of-Stake** with **Proof-of-Proof** to address weak subjectivity and censorship attacks inherent in traditional PoS systems.

*This hybrid model prevents forged chains through state proofs on the Bitcoin network and allows legitimate sequencers to regain control in adversarial conditions, ensuring the network's resilience and security.*
{% endhint %}

***

#### 🔒 **Network Security and Finality**

* To inherit Bitcoin security, a new type of miner (a “PoP Miner”) publishes Hemi consensus information to the Bitcoin blockchain.
* After a state publication to Bitcoin, the Hemi Network’s consensus layer incorporates cryptographic proofs of these publications, with PoP Miners receiving a reward in the protocol’s native token. The network uses these proofs during fork resolution to prevent reorganizations with the full force of Bitcoin’s security.
* As they are produced, the Hemi Network’s chain segments initially receive Bitcoin confirmations, which means an attacker **would have to control increasingly large ratios of staking power to successfully affect a reorganization.**
* During normal operation, each block on the Hemi Network reaches full **“Bitcoin Finality”** **after 90 minutes, or nine Bitcoin blocks, on average**.

> At this point, it is mathematically impossible for anyone to reorganize the network without 51% attacking Bitcoin itself.


# Ethereum Rollups

{% hint style="info" %}

## 📜 **TL;DR:**

* 🚗 Rollups optimize Ethereum's performance by gathering transactions "off the main Ethereum highway" (Layer 1) and then officially process them on a "side road" **(Layer 2).**
  {% endhint %}

***

## 🌐 Overview

* Ethereum Rollups are a Layer-2 scaling solution designed to enhance the ***throughput and features*** of the Ethereum network.
* They operate by "rolling up," or bundling, multiple transactions off-chain and submitting them in batches to the Ethereum mainnet for data availability. By doing so, they significantly reduce congestion and gas fees while maintaining interoperability with Ethereum.
* Rollups can also add new protocol features that would be impossible directly on Ethereum (e.g., PoP security to inherit Bitcoin Finality and Hemi's hVM Bitcoin Interoperability system).


# Pros & Cons

{% hint style="info" %}

## 📜 **TL;DR:**

* Optimistic Rollups: Faster, presumed valid until proven otherwise; has delays, user fraud detection, relies on centralization.
* Zero-knowledge Rollups: Prior validation is needed, enhanced privacy; complex vulnerabilities, trusted setup, reliance on centralization.
* Centralized Influence: Centralized proposers could disrupt decentralized frameworks.
* Verifiers and Challenges: Vulnerabilities demand verifiers, lack of incentives leads to centralization.
* Denial-of-Service Risks: Centralized "batchers" in L2 networks risk refusing to publish transactions back to Ethereum, potentially causing service denial.
  {% endhint %}

***

## 🌀 **Conventional Rollups**

<table data-card-size="large" data-view="cards"><thead><tr><th></th><th></th><th></th></tr></thead><tbody><tr><td><strong>Optimistic Rollups</strong></td><td><p>✅ Pros:</p><ul><li>Allow faster transaction processing on Layer 2</li><li>Presume transactions are valid unless disputed within a specific period.</li><li>Reduce congestion on the main chain (L1)</li></ul></td><td><p>❌ Cons:</p><ul><li>Introduce finalization delays due to the challenge period for dispute resolution</li><li>Place the responsibility of fraud detection on users</li><li><em><strong>Rely on centralized sequencers and proposers, causing hidden transaction queues (mempools) and centralized chain state communication</strong></em></li></ul></td></tr><tr><td><strong>Zero-knowledge Rollups</strong></td><td><p>✅ Pros:</p><ul><li>Validate transactions before confirming them on the main chain (L1)</li><li>Potentially enable privacy features by leveraging zk proofs (although current implementations like ZKsync do not currently incorporate significant privacy features)</li><li>Reduce congestion on the main chain (L1).</li></ul></td><td><p>❌ Cons:</p><ul><li>Introduce potential vulnerabilities due to complex cryptographic systems</li><li>Often require a trusted setup for implementation.</li><li><em><strong>Rely on centralized sequencers and proposers, causing hidden transaction queues (mempools) and centralized chain state communication</strong></em></li></ul></td></tr></tbody></table>

***

## 💭 Things to Consider

### Centralized Influence in a Decentralized Sequencing World

Within frameworks aiming for decentralized sequencing, the presence of a centralized proposer could wield significant influence, *potentially disrupting their intended decentralized nature*.

Such control might result in the withholding of valid state rollups from Ethereum, leading to coercion of decentralized sequencers into potential censorship or halting communication of specific chain segments back to Ethereum for settlement.

***

### &#x20;🟩 Verifiers and Challenges

Vulnerabilities in optimistic rollup networks pose risks of asset theft through forged L2 states. To address this, rollups introduce verifiers, but the lack of proper incentives for this role presents challenges.

These lack of incentives can lead to difficulties such as:

* 🔒 Securing a sufficient number of verifiers to perform the complex and expensive verification process required.
* 👥 Relying heavily on users or nodes funded by development teams resulting in centralization.
* 📣 Potential bias or influence.
* 🌎 Sustainability and scalability issues.

***

### ✋ Denial-of-Service Risks

L2 networks' reliance on centralized "batchers" can expose them to denial-of-service risks if batchers refuse to publish transactions back to Ethereum for data availability.


# Decentralized Rollups

{% hint style="info" %}

## 📜 **TL;DR:**

* The **Hemi Network** champions decentralized roles, leverages Bitcoin's security, promotes open participation, fault tolerance, and fee efficiency to enhance Layer 2 solutions.
  {% endhint %}

***

## **🌐 Overview**

* In contrast to other Layer 2 (L2) rollup solutions, the Hemi Network introduces a more decentralized approach to data publication and validation, addressing critical issues present in current L2 setups:
  * **✅ Decentralized Roles:** Introduces a decentralized approach with Publishers handling key roles asynchronously, mitigating the risks associated with centralized control found in other L2 networks.
  * **✅ Incentivized Participation:** Allows open participation through staking tokens with Ethereum-side validation contracts, fostering consistent and incentivized data sharing even during times of increased fee activity.
  * **✅ Fault Tolerance and Reward System:** Implements a system to discourage malicious behavior, slashing stakes of Publishers submitting invalid data while rewarding Challengers who identify faults, thereby promoting network integrity.
  * **✅ Efficient Ethereum Fee Management:** Manages rewards via Ethereum-side validation contracts, ensuring consistent incentives for Publishers despite Ethereum fee fluctuations.


# Sequencer Consensus

{% hint style="info" %}

## 📜 **TL;DR:**

* This approach addresses key PoS vulnerabilities: weak subjectivity and censorship attacks.
* Forged chains would be invalidated by the state proofs on the Bitcoin network.
* Integration with the Bitcoin network validates the blockchain and helps maintain integrity even under attack.
  {% endhint %}

{% hint style="success" %}

## 👀 Sneak Peek WIP

*The Hemi Network uses a hybrid of Proof-of-Stake (PoS) and Proof-of-Proof (PoP) to secure its blockchain.*
{% endhint %}

***

## 🌐 **Overview**

The Hemi Network utilizes the Bitcoin-Secure Sequencer (BSS), a type of Proof-of-Stake (PoS) node, to achieve consensus, or agreement, on the network’s status. By leveraging the Bitcoin blockchain, the Hemi Network decentralizes its security measures, reducing reliance on internal network validators.

***

{% hint style="success" %}

## 👀 Sneak Peek WIP

***Enhanced Consensus Mechanism***

*The network combines traditional PoS with Proof-of-Proof (PoP), creating a more secure and robust consensus mechanism than standard PoS systems.*
{% endhint %}

***

## 🛠️ **How?**

⛓️ It incorporates state proofs from the Bitcoin network to validate the Hemi blockchain, ensuring the network's history cannot be easily altered or falsified.

🛡️ The hybrid model provides a unique defense against majority stake attacks, a common vulnerability in pure PoS networks.

🔐 In the event of an overwhelming attack, the network can offload transactions to the Bitcoin network, ensuring continuous operation and security.


# Proof-of-Stake (PoS)

{% hint style="info" %}

## 📜 **TL;DR:**

* Pure Proof-of-Stake networks rely on social consensus to prevent censorship by majority stakers and long-range attacks using old **PoS keys (weak-subjectivity attacks).**
* **Staking** is the risking of an asset in return for the chance to construct a block.
* A user who acts maliciously will have his stake **slashed** (reduced) as punishment for attacking the network.
* **The Hemi Network** uses a hybrid staking system that incorporates network state proofs published to the Bitcoin network, preventing both censorship attacks and weak-subjectivity attacks.
  {% endhint %}

***

## 🌐 **Overview**

* In Proof-of-Stake (PoS) consensus protocols, **staking** is a form of virtual mining in which users risk some amount of tokens (a “stake”) for the chance to construct a block and earn block rewards.  If the staker misbehaves (for example, by trying to cheat the system), the network will remove some or all of the stake (a process called “slashing”).  Under normal conditions when stakers act honestly, slashing is a rare occurrence.  PoS is a popular alternative to Proof-of-Work (as in Bitcoin) because staking is far less energy intensive than mining.

***

## ⚠️ **Security Risks in Proof-of-Stake**

* Conventional PoS networks, however, face two security risks inherent to staking.  If a malicious actor were to acquire more than half of the staking power on the network, he could censor transactions, including slashing transactions, which would prevent other honest validators from regaining control of the network. PoS systems also suffer from weak subjectivity.&#x20;
* If a malicious actor acquired enough old PoS keys to have the majority of staking power, he could use the old keys to create a valid alternative chain.  Pure PoS chains like Ethereum rely on social consensus to address these issues because the protocols themselves are vulnerable.

***

{% hint style="success" %}

## 👀 Sneak Peek WIP

**The Hemi Network's Hybrid Staking Approach**

The Hemi Network uses a modified PoS protocol to provide security. Sequencers and publishers on the Hemi Network stake the network’s native token, as part of their normal operations.  However, because of the network state proofs which proof-of-proof miners publish to the Bitcoin network, old staking keys cannot be used to construct a valid alternative chain.  Constructing a valid alternative chain would require also reorganizing the Bitcoin network to publish corresponding alternative state proofs.

Furthermore, even a staker with an overwhelming majority of staking power on the Hemi Network would not be able to censor transactions. They would still be forced to include Bitcoin block headers in the PoS blocks he produced, and any Hemi Network user could bypass active PoS censorship attacks by offloading transactions to the Bitcoin network.  The attacker’s stake would then be slashed and other validators would be allowed to process transactions.&#x20;
{% endhint %}


# PoS-Only Pitfalls

{% hint style="info" %}

### 📜 TL;DR:

* Standard **Proof-of-Stake (PoS)** systems like Ethereum face two primary risks:
  1. **Weak Subjectivity**, where attackers could potentially gain majority control by accumulating old PoS keys, enabling them to create alternative chains; and
  2. **Censorship**, where a current majority stakeholder blocks or ignores transactions, akin to a traditional 51% attack.
     {% endhint %}

***

## 🚨 Weak Subjectivity

* This risk involves an attacker accumulating enough keys of old PoS miners to gain majority control **at some point in the past**. With this control, they could create a valid, alternative/competing version of the blockchain which would appear equally valid to a bootstrapping node attempting to sync the network for the first time, and could also be used to create seemingly valid zero-knowledge proofs of chain state that differs from the legitimate canonical chain.
* While Ethereum relies on community consensus to avoid long-range reorganizations of its chain, its PoS protocol doesn’t *technically* prevent this type of attack.

***

## 🚫 Censorship

* An attacker with **current majority stake** could potentially block or ignore certain transactions, exercising a form of **majority control** that undermines the network's decentralization and fairness.

***

## ❌ Lack of Protocol-Level Defenses

* Since PoS operates entirely within its network, it lacks **protocol-level defenses** against the types of attacks mentioned above.
* Among the vulnerabilities, the limitations are:
  * **No External Correction Mechanism**: If internal rules fail or are exploited, there's no external system to protect or correct the network.
  * **Self-Contained Security**: PoS systems handle all their security internally within the blockchain network.
* By using PoP, Hemi prevents against weak subjectivity attacks because the illegitimate chain an attacker produces when attempting a long-range reorg could not be appropriately published to Bitcoin. Hemi's fork resolution algorithm prevents a reorg from occurring if the new proposed fork does not have PoP publications that are in-step with or before the current chain's publications. As a result, Hemi's consensus algorithm has strong subjectivity and reorganizing a segment of Hemi's chain which has reached Bitcoin finality would require the attacker to 51% attack Hemi and Bitcoin simultaneously.
* As a dual-chain L2, Hemi can also provide robust censorship resistance against attacks from majority block-consensus power actors. Any valid Hemi transaction can be published to either Bitcoin or Ethereum, and Hemi's block derivation protocol will force the inclusion of these transactions in Hemi blocks.


# PoS Solutions

{% hint style="info" %}

## 📜 **TL;DR:**

* The Hemi Network combines **Proof-of-Stake (PoS)** with **Proof-of-Proof (PoP)** for enhanced security which:
  * **Protects against weak subjectivity** using Bitcoin's state proofs.
  * **Prevents censorship attacks** by offloading transactions to Bitcoin.
    {% endhint %}

***

## 🛡️ Against Weak Subjectivity

Even if an attacker gathers old staking keys, they can't alter the state proofs on the Bitcoin blockchain. These state proofs confirm the Hemi Network's transaction history, so any fake blockchain the attacker creates would be recognized as invalid.

***

## 🚫 Against Censorship Attacks

In a worst-case scenario where an attacker controls all the sequencers (the nodes that create blocks in the blockchain), the Hemi Network can still function by using the Bitcoin network.

Transactions can be processed (or "offloaded") to Bitcoin, which prevents the attacker from having total control.

***

## 🔚 Conclusion

The Hemi Network’s hybrid **PoS-PoP consensus model** hardens the network protocol against both weak subjectivity and censorship. Even with an overwhelming majority of old staking keys, an attacker would be unable to forge finalized state proofs on the Bitcoin blockchain, and the established state proofs would invalidate the altered Hemi Network chain.


# Proof-of-Proof (PoP)

{% hint style="info" %}

## 📜 **TL;DR:**

* The Hemi Network utilizes **Proof-of-Proof (PoP)** to leverage Bitcoin's renowned security.
* **PoP Miners** enhance security by publishing Hemi's network data on Bitcoin's blockchain.
* Bitcoin confirmations further bolster Hemi's defenses, ensuring a robust and secure network.
  {% endhint %}

***

## 🛡️ Inherits Bitcoin's Security

* Hemi's network capitalizes on Bitcoin's formidable security through a mechanism known as **Proof-of-Proof (PoP)**. This approach allows Hemi to inherit the solid Proof-of-Work (PoW) security of Bitcoin.

***

## 🔍 How?

* To achieve this, Hemi deploys specialized miners, referred to as **PoP Miners**. These miners are responsible for:
  * Gathering crucial network details and publishing them on Bitcoin's blockchain, thereby linking Hemi's security directly to Bitcoin's proven system.
  * Employing sophisticated algorithms to generate proofs that are vital for the network's security.
  * Ensuring Hemi's network integrity by leveraging Bitcoin's security, providing a dual layer of protection.
* This integration with the Bitcoin blockchain affords Hemi an additional security layer, utilizing Bitcoin's PoW system as a basis for resolving disputes and ensuring trustworthiness.

***

## 🏗️ Block Confirmations

* New segments in the Hemi chain receive confirmations from Bitcoin, significantly raising the barrier for potential attacks. These confirmations:
  * Serve as **"security bricks,"** each one strengthening the network's defenses.
  * Ensure that any attempt to compromise the network requires substantial power, making unnoticed attacks virtually impossible.
  * As Bitcoin confirmations accumulate, the Hemi Network's "security wall" becomes increasingly formidable, creating an effective deterrent against malicious actors.

***

## 🔚 Conclusion

* The **Proof-of-Proof (PoP) consensus mechanism** uniquely positions the Hemi Network by:
  * Allowing Bitcoin miners to secure Hemi indirectly, without direct involvement in Hemi's consensus processes.
  * Facilitating scalable transaction throughput in the Hemi ecosystem without expanding its Bitcoin footprint significantly.
  * Setting a high barrier for network reorganizations, as disrupting Hemi would necessitate a highly improbable 51% attack on Bitcoin itself, a task too daunting even for nation-states.
* This approach not only extends Bitcoin's security to the Hemi Network but also introduces a scalable, robust framework for transaction processing and network integrity.


# Proof-of-Proof Consensus & Bitcoin Finality

{% hint style="info" %}

## 📜 TL;DR:

* In **Proof-of-Proof (PoP) consensus**, a PoP miner periodically publishes proof of the Hemi Network’s state to the Bitcoin blockchain.
* By building on Bitcoin, PoP consensus **inherits the security and finality** of Bitcoin’s consensus.
* After **six Bitcoin blocks**, PoP consensus reaches a state of **superfinality**, where the security of the Hemi Network exceeds that of Bitcoin.
  {% endhint %}

***

## 🌐 Overview

* Proof-of-Proof (PoP) is the Hemi Network’s additive consensus protocol, building on **Bitcoin’s consensus** for superior security. PoP miners publish cryptographic network-state proofs to the Bitcoin blockchain, protecting Hemi consensus with Bitcoin's proof of work.
* Hemi blocks achieve **finality** typically nine blocks (approximately an hour and a half) after their proofs are published to Bitcoin.

***

## ⏱️ Finality Delay in the Hemi Network

* The Hemi Network accounts for fluctuations in Bitcoin's transaction fees and block timings, recognizing that network-state proofs might not appear in every block.
* To manage this variability, a **finality delay** of nine Bitcoin blocks is implemented.

> If no competing fork publishes proofs to Bitcoin during this period, the network assumes finality, requiring a **51% attack on both the Hemi and Bitcoin networks** to alter this.

***

{% hint style="success" %}

## 👀 Sneak Peek WIP

*♾️ Superfinality: A New Benchmark in Blockchain Security*

*Upon reaching this finality, the Hemi Network attains a state of **'superfinality,'** where its chain state's security surpasses Bitcoin's.*

*How?*

*This is achieved by combining Bitcoin’s **Proof-of-Work** consensus with Hemi’s **Proof-of-Stake**. After superfinality, altering the Hemi Network’s state proof would be economically infeasible even for nation-states. An attacker would need so simultaneously 51% attack Bitcoin and Hemi, which is even harder than attacking Bitcoin itself.*
{% endhint %}


# Proof-of-Proof vs. Merged Mining

{% hint style="info" %}

## 📜 **TL;DR:**

* [**Merged mining** ](https://www.techopedia.com/definition/merged-mining)allows Bitcoin miners to simultaneously mine a Bitcoin sidechain, which can limit decentralization and lead to an attack on the sidechain.
* The **Proof-of-Proof (PoP)** consensus protocol utilized by Hemi enables PoP miners to independently publish data to the Bitcoin blockchain, cutting off this attack vector.

{% endhint %}

***

## ⛔️ The Trouble With Merged Mining

* Bitcoin miners must choose to participate by running nodes for the sidechain, which can curtail decentralization.
* This makes the sidechain more susceptible to attack, as Bitcoin miners can collude to attack the sidechain at no cost while reaping Bitcoin block rewards.
* Merged mining can introduce new security problems and issues with incentives.

***

## 🔍 **How Proof-of-Proof Works**

* Hemi uses a consensus protocol called **Proof-of-Proof (PoP)**, which allows Hemi to exceed Bitcoin's security at scale.
* Bitcoin miners don’t need to participate in Hemi directly; they confirm blocks that include Hemi transactions and collect transaction fees for doing so.
* Users who *do* want to earn rewards in Hemi’s native token can run a super-lightweight PoP miner to publish Hemi consensus data to Bitcoin.

<mark style="color:orange;">**👉**</mark>[ <mark style="color:orange;">**It’s simple: Help create proofs and get tokens.**</mark>](/foundational-topics/the-architecture/proof-of-proof/pop-mining#run-a-pop-miner)&#x20;

* Each new Hemi block receives a Bitcoin confirmation, making reorganization increasingly unlikely until the block reaches finality.
* Bitcoin requires about 60 minutes to reach finality; **Hemi takes nine Bitcoin blocks (about 90 minutes)** to reach finality and **achieves** [**Superfinality**](/foundational-topics/the-architecture/consensus-and-security-protocols) (*WIP*) in just **two hours.**

Thus, in the Proof-of-Proof protocol, unlike with merged mining, Bitcoin miners needn’t be active to benefit; they can’t collude to attack the chain, and superfinality comes fast.

***


# Running a PoP Mining

{% hint style="info" %}

### 📜 **TL;DR:**

* Participants can secure the Hemi Network to Bitcoin and earn rewards by operating the PoP Miner application.
  {% endhint %}

***

## 🌐 **Overview**

* Mining within the Hemi Network involves a specialized process designed to intertwine the security of the Hemi Network with that of the Bitcoin blockchain.
* This is achieved through the operation of the PoP Miner application, which plays a pivotal role in this symbiotic security mechanism.

***

## 🛠️ **How It Works**

1. **Fetching Headers**: The PoP Miner retrieves network headers from the Bitcoin Finality Governor for Bitcoin blockchain publication.
2. **Transaction Construction**: The miner constructs Bitcoin transactions embedding aforementioned Hemi Network headers.
3. **Proof of Publication**:  Miners broadcast transactions through the Governor. These transactions are then integrated into Hemi’s consensus layer after being validated via the Bitcoin network, resulting in miner rewards.

***

## ⛏️ Run a PoP Miner

The [CLI](/how-to-tutorials/using-hemi/pop-mining/setup-part-1) (Command Line Interface) version of PoP mining is designed for long-term, continuous operation. It requires some technical knowledge for setup and maintenance but provides robust security and operational efficiency.&#x20;

***

## 💸 **Earning Rewards**

|                                   |                                                                                                                                                                                                                                                                                                                                                                                                                               |
| --------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| 🔍 **Tracking Miner Activity**    | Visit the [Hemi Block Explorer](https://testnet.explorer.hemi.xyz) and visit [Run a PoP Miner](/how-to-tutorials/using-hemi/pop-mining/setup-part-1) to see your miner's history and activity.                                                                                                                                                                                                                                |
| ⏳ **Payout Processing Time**      | It takes about **4 hours** on mainnet (30 minutes on testnet) after sending a transaction to receive a PoP payout.                                                                                                                                                                                                                                                                                                            |
| ⚡️ **Quick Confirmation Rewards** | You will earn PoP rewards for transactions that are quickly confirmed **(within the next 2-3 Bitcoin blocks)**.                                                                                                                                                                                                                                                                                                               |
| 🎁 **Rewards**                    | <p>Testnet rewards are fixed, with each successful transaction earning <strong><code>1</code></strong> <strong>tHEMI</strong>. Payouts occur after the transaction is successfully confirmed. You may expect a brief delay between transaction confirmation and the distribution of tHEMI to your address.<br><br><em>In future testnets and on the mainnet, rewards will depend on the number of active PoP miners.</em></p> |
| 🔗 **Additional Links**           | [**github.com/hemilabs/heminetwork**](https://github.com/hemilabs/heminetwork)                                                                                                                                                                                                                                                                                                                                                |

{% hint style="danger" %}
**Protect Your Private Key**

Your private key is the most sensitive part of your Bitcoin wallet and should be treated with the highest level of security. Access to your private key grants complete control over the funds associated with the wallet, including the Bitcoin you send to the miner and the rewards you collect. If someone gains access to your private key, they can steal your funds and rewards without your ability to recover them.
{% endhint %}

{% hint style="info" %}

### 📝 **Tips**

* 🚫 **Single Key, Single Miner**: Using the same key for multiple PoP miner instances can lead to conflicts, as they may attempt to use the same Bitcoin UTXO simultaneously, causing operational issues.
* 🗂 **Purpose of** **`popm-address.json`**: This file serves as a secure storage for your generated keys, meant for reference. The actual Bitcoin key used by the PoP Miner is specified through an environment variable at the program's start.
* 🔑 **Unified Private Key**: Your single private key generates both a Bitcoin address and a Hemi address. The Hemi network automatically processes your public key from Bitcoin transactions, converting it into a Hemi address to receive payouts.
* ⚡ **Bitcoin Testnet Dynamics**: Bitcoin testnet can undergo periods of rapid block generation due to block difficulty adjustments after inactive periods. This unusual pace can temporarily impact the timing and processing of payouts.
  {% endhint %}

***

## 🕵️ **Behind the Scenes**

* A Bitcoin Secure Sequencer (BSS) generates and broadcasts a new block.
* BSS nodes send the block header to Bitcoin Finality Governor (BFG) nodes.
* BFG nodes direct the header to PoP Miners.
* Miners create and send back signed Bitcoin transactions containing the header.
* BFG nodes push these transactions into the Bitcoin network.
* Once included in a Bitcoin block, BFG nodes generate PoP Transactions with proofs of Bitcoin inclusion.
* These transactions and Bitcoin headers are incorporated into a new Hemi block by a BSS node, updating the EVM with the latest Bitcoin state.
* Rewards are calculated and distributed to PoP Miners post-mining.


# Tunnels

{% hint style="info" %}

## 📜 **TL;DR:**

* Bridging i.e. Tunneling allows the transfer of assets between disparate blockchains (such as between distinct L1s or between an L1 and an L2).
* While bridging addresses the siloed nature common to most blockchains, it typically suffers from centralization because most blockchains do not maintain state awareness of other networks.
* Hemi Network enables sophisticated asset transfer and decentralization by maintaining protocol-level state awareness of both Bitcoin and Ethereum.
  {% endhint %}

***

## 🌐 **Overview**

* Blockchain networks typically operate as independent systems with no knowledge of other networks, creating a siloed environment. This isolation makes it impossible to transfer assets directly from one chain to another.
* **Bridges** are developed to address this issue, enabling asset transfers between different blockchains. They function by accepting a token from one blockchain **(chain A)** and issuing a corresponding placeholder or wrapped token on another blockchain **(chain B).** This wrapped token represents the original token and can be redeemed for it.

***

## 🖼️ **Example**

* To illustrate, consider the process of transferring bitcoin to Ethereum. A user sends bitcoin to a bridge connecting to the Ethereum network. This bridge then issues a wrapped Ethereum token representing the bitcoin.
* The user can utilize this wrapped bitcoin within the Ethereum network or return it to the bridge to reclaim the original bitcoin on the Bitcoin network.

***

## 🔍 **Broader Applications & Limitations of Bridges**

* Bridges are not limited to transferring assets between distinct blockchains. They can also facilitate transfers between different network layers, like connecting a Layer 1 (**L1**) blockchain like Ethereum to a Layer 2 (**L2**) rollup chain. This connection allows assets to benefit from the L2's lower fees and other features.
* However, bridges often rely on centralized infrastructure due to the lack of protocol-level awareness between the connected chains. For example, while an L2 might maintain the state of its corresponding L1, the L1 lacks inherent knowledge of the L2. This disconnect necessitates a centralized third party to maintain awareness of both chains.

***

## 🔒 Security and Efficiency

* The security model behind Hemi’s Ethereum Tunnels leverages the strengths of both Ethereum and Bitcoin. By integrating Bitcoin finality, Hemi ensures that cross-chain transactions achieve a level of finality backed by Bitcoin’s Proof-of-Work consensus, widely considered the most secure consensus mechanism in blockchain technology.&#x20;
* This significantly reduces the time it takes to finalize cross-chain transactions and provides strong protection against censorship or fraud attempts during the tunneling process.
* The decentralized Challenger role also strengthens Hemi’s security. Rather than relying on a centralized entity to raise disputes, any participant in the Hemi ecosystem can act as a Challenger, further decentralizing the network and increasing its resistance to fraud.&#x20;
* This approach contrasts with centralized bridges, which can be vulnerable to manipulation or collusion by a single entity overseeing the dispute process.

***

## &#x20;🏗️ A Phased Approach

The phased approach to Hemi’s Ethereum and Bitcoin Tunnels aims to progressively enhance the security, decentralization, and asset support for cross-chain transfers. Each phase introduces key improvements to the settlement mechanisms and expands the range of assets that can be tunneled across Ethereum, Bitcoin, and Hemi, all while focusing on increasing trust minimization and reducing reliance on centralized actors.

<table data-view="cards"><thead><tr><th></th><th></th><th></th></tr></thead><tbody><tr><td><p></p><h3>Phase 0 (Current State)</h3><p><strong>Ethereum Tunnels:</strong></p><ul><li>Optimistic (fault-dispute) model, where disputes are raised within a dispute window.</li><li>ETH-based assets tunneled between Ethereum and Hemi.</li></ul><p><strong>Bitcoin Tunnels:</strong></p><ul><li>Over-collateralized multisig/threshold signatures, providing moderate decentralization.</li><li>BTC itself tunneled to and from Hemi.</li></ul></td><td></td><td></td></tr><tr><td><p></p><h3>Phase 1 (Expansion)</h3><p><strong>Ethereum Tunnels:</strong></p><ul><li>ZK proof-based settlement with an optimistic fallback if the ZK system fails.</li><li>ETH-based assets plus support for Hemi-native assets, including BTC-based assets, tunneled to Ethereum.</li></ul><p><strong>Bitcoin Tunnels:</strong></p><ul><li>Introduction of BitVM2+hVM, a decentralized 1-of-N trust system for enhanced security.</li><li>BTC itself, with groundwork for supporting fungible BTC assets (BRC-20s, Runes).</li></ul></td><td></td><td></td></tr><tr><td><p></p><h3>Phase 2 (Maturity)</h3><p><strong>Ethereum Tunnels:</strong></p><ul><li>Redundant ZK proof system (2-of-3), providing higher security with multiple ZK proofs.</li><li>Full support for Hemi-native assets, including BTC-based fungible and non-fungible assets (Ordinals) tunneled to Ethereum.</li></ul><p><strong>Bitcoin Tunnels:</strong></p><ul><li>A mature BitVM2+hVM model for trust minimization.</li><li>Full support for fungible BTC assets (BRC-20s, Runes) and non-fungible assets (Ordinals).</li></ul></td><td></td><td></td></tr></tbody></table>

***

{% hint style="success" %}

## 👀 Sneak Peek WIP

**Introducing Tunnels for Decentralized Asset Transfers**

To promote greater decentralization and address the limitations of bridges, the Hemi Network introduces **tunnels**.&#x20;

***Tunnels*** allow for sophisticated, noncustodial bidirectional asset transfers between networks, such as Bitcoin and Ethereum. Unlike traditional bridges, tunnels within the Hemi Network maintain state awareness of both networks at the protocol level.

This enables a variety of custodianship approaches, both centralized and decentralized. For instance, BRC-20 tokens can be tunneled from Bitcoin to the Hemi Network or Ethereum, facilitating trading on Ethereum-based decentralized exchanges (DEXes). Additionally, tunnels benefit from the security features of the Hemi Network’s Bitcoin-based superfinality
{% endhint %}


# Ethereum Tunnel

{% hint style="info" %}

## 📜 **TL;DR:**

* Hemi’s Ethereum Tunnels facilitate secure and efficient asset transfers between Ethereum and the Hemi network.&#x20;
* While similar to other “lock-and-mint” cross-chain mechanisms, Hemi’s Tunnels are distinguished by their integration with Bitcoin’s Proof-of-Work finality model and decentralized dispute mechanisms, offering faster settlement times and enhanced security.
* By integrating these features, Hemi’s Ethereum Tunnels offer a more efficient and secure mechanism for cross-chain asset transfers, benefiting from both Ethereum’s smart contract capabilities and Bitcoin’s unrivaled security.
  {% endhint %}

***

## 🚊 How Ethereum Tunnels Work

The Ethereum Tunnel process involves locking assets on one network while minting corresponding representative tokens on the other network. For Ethereum-native assets, tokens are minted on Hemi once the assets are locked in a Hemi validation contract on Ethereum.

This allows seamless asset transfers across chains, enabling users to leverage the strengths of both networks while minimizing the friction of cross-chain operations.

#### **Deposit to Hemi**

1. The process begins with the user initiating a deposit transaction on Ethereum. This deposit locks up Ethereum-native tokens in a Hemi validation contract on Ethereum. The validation contract plays a critical role by securing the assets and ensuring they remain locked throughout the tunneling process.
2. Once the deposit is secured in an Ethereum block, Hemi’s block derivation protocol kicks in. The Sequencer, responsible for ordering and generating Hemi blocks, is required to include the deposit in the first Hemi block derived from the Ethereum block that contains the deposit transaction. This ensures that the deposit is acknowledged in Hemi’s L2 environment almost immediately after its validation on Ethereum.&#x20;
3. After the deposit is included, Hemi mints a representative token on the Hemi Network, which serves as the equivalent of the locked asset on Ethereum. This token can now be freely used within the Hemi ecosystem, allowing users to engage with dApps or perform any transaction that requires the asset. You should receive your deposit within **0-2 minutes**.

#### **Withdrawal to Ethereum**

1. To return the assets back to Ethereum, the user submits a withdrawal transaction on Hemi. When the withdrawal request is submitted, the representative tokens on Hemi are burned, which signals the user’s intent to withdraw their corresponding Ethereum-native assets.&#x20;
2. Hemi’s state transition system updates its rollup state root, which is then submitted to Ethereum by a Publisher. The state root acts as a cryptographic proof of the transactions that occurred on Hemi, including the user’s withdrawal request.
3. The key to finalizing the withdrawal lies in Hemi’s use of Bitcoin finality, which is a significant differentiator from other optimistic rollup bridges. (In traditional optimistic rollups, the finality of cross-chain transactions is delayed by a dispute window, during which fraud proofs can be raised. Hemi accelerates this process by leveraging Bitcoin’s highly secure Proof-of-Work consensus mechanism to finalize the state root on Ethereum.) This process takes roughly 4**0 minutes.**
4. Once Bitcoin finality is achieved, and assuming no disputes are raised through the decentralized Challenger role, the state root is confirmed, and the user can submit a withdrawal proof on Ethereum to claim their assets from the Hemi validation contract. A proof may take up to **24 hours.**
5. The withdrawal proof ensures that the burned representative tokens on Hemi correspond to the original locked Ethereum-native tokens. Upon successful validation of the proof, the Ethereum-native assets are unlocked, completing the cross-chain asset transfer.&#x20;

***

## 🔄 Tunneling Hemi-Native and Bitcoin-Native Assets to Ethereum

Hemi’s tunneling process is not limited to Ethereum-native assets. Phase 2 of Hemi's Ethereum Tunnel will support Hemi-native and Bitcoin-native assets, extending the functionality of the tunnels to a broader range of assets. This capability is crucial for enabling the use of Bitcoin within Ethereum’s extensive decentralized finance (DeFi) ecosystem, which traditionally lacks native Bitcoin interoperability.&#x20;

#### **Withdrawal to Ethereum**

1. The process for tunneling Hemi-native assets begins with the user submitting a deposit transaction on Hemi, locking their native assets within Hemi’s native asset tunnel contract.&#x20;
2. Similar to Ethereum-native asset transfers, the state root containing this deposit transaction is published to Ethereum.&#x20;
3. Once the rollup state root is confirmed (following Bitcoin finality and the absence of any disputes), the user submits a deposit proof on Ethereum to claim the corresponding representative tokens. These tokens represent the Hemi-native assets within the Ethereum ecosystem and can be used in Ethereum dApps or traded just like any other Ethereum-based token.

**Deposit to Hemi**

1. Moving Hemi-native assets back to Hemi from Ethereum involves a similar process. The user initiates a withdrawal on Ethereum, burning the representative tokens.&#x20;
2. This triggers Hemi’s block derivation protocol to include the withdrawal in the next Hemi block derived from the corresponding Ethereum block.&#x20;
3. Once the withdrawal is processed, the Hemi-native assets are transferred from Hemi’s native asset tunnel contract back to the user, completing the return to Hemi’s L2 environment.

One of the core advantages of this system is its flexibility. It allows Bitcoin-native assets, which are traditionally siloed on the Bitcoin network, to be tunneled through Hemi and into Ethereum. This enables Bitcoin to participate in Ethereum’s DeFi ecosystem while maintaining the security and decentralization that Bitcoin’s Proof-of-Work consensus provides.

***

## 🔍 Comparison to Standard Ethereum Bridges

While Hemi’s Ethereum Tunnels share the foundational principles of traditional bridges like the  Standard Bridge, there are several critical distinctions:

* The primary distinction between Hemi’s Tunnels and standard bridges lies in the finality model and security architecture. Standard bridges depend on an optimistic model with a delayed dispute window. The withdrawal process on these bridges typically takes **a week or longer**, as they await the potential for fraud proofs before finalizing the transaction.
* Hemi Tunnels enhance this process by incorporating Bitcoin finality. Instead of relying solely on an Ethereum-based dispute window, Hemi uses Bitcoin’s Proof-of-Work consensus as an additional layer of security. This allows Hemi to finalize transactions more quickly, as the Bitcoin network’s finality period is shorter and more secure than the traditional dispute windows of optimistic rollups.
* Hemi will decentralize the dispute process by distributing the Challenger role across a wider set of participants. This decentralization mitigates the risk of collusion or centralization of power within the bridging system, offering a more secure alternative to centralized or semi-centralized dispute mechanisms found in standard bridges.


# Bitcoin Tunnel

{% hint style="info" %}

### 📜 **TL;DR:**

* Hemi’s Bitcoin Tunnel enables the secure transfer of Bitcoin and Bitcoin-native assets (such as Ordinals and BRC-20 tokens) between Bitcoin, Hemi, and eventually, EVM-compatible networks.
* The Bitcoin Tunnel contract uses hVM to track Bitcoin addresses and outputs tied to custodianship vaults, ensuring efficient and secure asset management.
* Hemi will offer two custodianship models: overcollateralized multisig and BitVM. These ensure decentralized, trust-minimized asset tunneling with high security and performance.
  {% endhint %}

***

## 🚊 How Bitcoin Tunnels Work

The Bitcoin Tunnels allow Bitcoin assets to move between Bitcoin and Hemi by locking assets in custodial vaults and minting representative tokens on Hemi. Users can freely use these tokens on Hemi, and eventually, tunnel them to Ethereum or other EVM-compatible networks.

#### **Deposit to Hemi**

1. Users generate a deposit transaction by sending Bitcoin (or Bitcoin-native assets) to the selected custodianship vault’s Bitcoin address, managed by the multisig.
2. Once sent, the Bitcoin assets are locked in the custodianship vault.
3. Hemi’s Bitcoin Tunnel verifies the successful deposit on the Bitcoin network by monitoring the UTXO table for the corresponding deposit. If the deposit is successfully verified, the system moves to the next step.&#x20;
4. Upon verification, Hemi mints representative tokens equivalent to the deposited Bitcoin assets. These tokens are sent to the user’s Hemi address. Hemi mints the representative tokens after 6 Bitcoin confirmations, or approximately **one hour.**

#### Withdrawal to Bitcoin

1. The user on Hemi initiates a withdrawal transaction by selecting the amount of representative tokens they want to convert back to Bitcoin.
2. These representative tokens are burned on the Hemi network, signaling the system that the user intends to withdraw the corresponding amount of Bitcoin from the custodianship vault.
3. Hemi’s Bitcoin Tunnel updates the rollup state root with the details of the withdrawal transaction. This state root is submitted to Bitcoin by a Publisher to ensure that the withdrawal is accurately recorded.
4. Hemi’s Bitcoin Tunnel verifies the correct burning of tokens and prepares the custodianship system for withdrawal.
5. The custodianship vault is notified of the withdrawal request. In the case of a multisig vault, the required number of signatures is collected to authorize the withdrawal.
6. Once verified, the custodianship vault releases the corresponding Bitcoin or Bitcoin-native assets to the user’s Bitcoin address. It may take up to **12 hours** to verify and release withdrawn BTC.
7. The hVM system constantly monitors for any unauthorized withdrawals. In Phase 0, this requires an externally owned account (EOA) to flag any potential issues. In later phases, event notifications will allow automatic detection of unauthorized actions. If any misbehavior is detected during the withdrawal process, the responsible custodian is slashed on Hemi, and corrective measures are taken to prevent unauthorized fund transfers.

***

## 🔍 Comparison to Other Bitcoin Interoperability Solutions

* Hemi’s Bitcoin Tunnels leverage the power of hVM (Hemi Virtual Machine) to monitor and secure Bitcoin-based asset transfers.
* The Bitcoin Tunnel contract uses hVM to track Bitcoin addresses and outputs tied to custodianship vaults, ensuring efficient and secure asset management.
* In hVM Phase 0, an externally owned account (EOA) is required to notify the contract of any irregular withdrawals. Once flagged, hVM can verify the offending transaction and respond by slashing misbehaving custodians.
* This contrasts with BTC interoperability solutions like BTC header relay, where users must manually construct cryptographic proofs of misbehavior and relay them to the contract for validation, introducing higher costs and risks of error.


# Ethereum Virtual Machine (EVM)

{% hint style="info" %}

## 📜 **TL;DR:**

* The Ethereum Virtual Machine (EVM) serves as a global, decentralized computer designed to execute smart contracts.
* The Hemi Network offers seamless compatibility with the EVM, allowing it to not only execute Ethereum-based smart contracts directly but also facilitate interactions among various smart contracts across networks.
* **The Hemi Network also extends this compatibility to Bitcoin** through a protocol-level awareness of the state of the Bitcoin network.
  {% endhint %}

***

## 🌐 **Overview**

* **The Ethereum Virtual Machine (EVM)** represents a cornerstone of blockchain technology, functioning as a distributed computational engine that executes smart contracts. These contracts are *self-executing agreements* with the terms directly written into code, enabling a wide array of decentralized applications (DApps). The Ethereum network's primary role is to maintain the operational integrity and accessibility of the EVM, ensuring a trustless environment for executing these contracts.

***

## 💡 **An EVM-Compatible L2**

* On the innovative front, the Hemi Network emerges as an EVM-compatible Layer 2 (L2) solution, architecturally designed atop Ethereum's foundation.
* This compatibility empowers the Hemi Network to directly execute smart contracts developed for the Ethereum ecosystem and establish communicative bridges with other EVM-compatible smart contracts, fostering an interconnected blockchain environment.

***

## 🔗 **Integration with Bitcoin**

* Through a deep, protocol-level insight into Bitcoin's state, the **Hemi Network** facilitates the creation and execution of EVM-compatible smart contracts that can interact with Bitcoin. This expands the utility and applications of smart contracts and tunnels the capabilities of Ethereum with the robust security and widespread adoption of Bitcoin, marking a significant advancement in blockchain interoperability and functionality. 🤝


# Blocks

{% hint style="info" %}

## 📜 TL;DR:

* **Blocks** in blockchain technology are packets of transactions and data, made secure through links to previous blocks.
* Altering past blocks requires modifying all subsequent ones, a security feature. The Hemi Network enhances this by segmenting blocks into five-minute "**keystone**" intervals, with a security proof sent to the Bitcoin network every second interval.
  {% endhint %}

***

## 🌐 Overview

* A block is a component of blockchain technology that contains transactions and their associated data.&#x20;
* Its security is enhanced because all subsequent blocks in the chain cryptographically reference it, reinforcing the integrity of the entire blockchain with each new block added. Tampering with an earlier block requires altering not only that block but also every block after it.

***

## 🟦 Hemi Blocks

* In the Hemi Network, blocks are organized into **five-minute intervals known as keystones**. To inherit Bitcoin’s security, \*one Hemi Network state proof must be published to the Bitcoin network every two keystone intervals. \*
* The first block of each interval **cryptographically references the previous two keystone blocks**, ensuring that the network cannot be reorganized without a 51-percent attack against Bitcoin itself, a scenario considered highly unlikely even for powerful entities like nation-states.


# Transactions

{% hint style="info" %}

## 📜 TL;DR:

* **A cryptocurrency transaction updates a network's decentralized ledger.**
* *It requires the sender's cryptographic signature to ensure the transaction is authorized.*
* **To increase the speed and number of transactions, transactions can be offloaded to an L2 network**, which bundles transactions before settling them on the main chain.
* **Transactions on the Hemi Network inherit the programming abilities of Ethereum and the robust security of Bitcoin** while still encouraging decentralization and resistance to censorship.&#x20;
  {% endhint %}

***

## 🌐 **Overview**

* **A cryptocurrency transaction fundamentally represents an update to the network's decentralized ledger.**
* Such a transaction mandates a cryptographic signature from the sender's wallet, serving as a verification mechanism to authorize the transaction. Within the Bitcoin ecosystem, scripting capabilities enable the execution of more complex transaction types.
* Conversely, **Ethereum operates as a distributed virtual machine,** allowing for the execution of sophisticated programs known as smart contracts. These contracts, embedded directly on the blockchain, can operate autonomously based on their programming.

***

## ⚖️ **The Blockchain Trilemma and L1 Challenges**

* L1 chains like Bitcoin and Ethereum typically have relatively slow transaction times—a problem commonly known as the blockchain trilemma.&#x20;
* The process of improving transaction throughput on a blockchain necessitates an expansion of data storage capacity, as each transaction must be individually recorded on the ledger. This requirement potentially centralizes the operation of full nodes to entities possessing considerable computational and financial resources.
* In response, Layer 2 (L2) networks present a strategic solution by aggregating multiple transactions off-chain prior to their collective finalization on the primary Layer 1 (L1) blockchain. This methodology not only preserves the foundational security principles of the L1 blockchain but also contributes to a reduction in transaction fees and an acceleration of transaction processing times, thereby enhancing the efficiency and accessibility of blockchain technology. ⏩

***

## 🌉 **Tunneling Ethereum & Bitcoin with Hemi**

* The Hemi Network, as an EVM-compatible Layer 2 network built to bridge Ethereum and Bitcoin, enables rapid transaction settlement and finality.  Transactions inherit the complex programming abilities of Ethereum and the robust security of Bitcoin.  The Hemi Network’s design also encourages greater decentralization than typical L2 networks, preventing censorship and ensuring open access.


# Gas

{% hint style="info" %}

## 📜 TL;DR:

* **Gas fees on Hemi** is paid using ETH, the network's native token.
* This approach is similar to Ethereum Layer 2 rollups like Optimism, where gas fees are in their native bridged tokens.
  {% endhint %}

***

## 🌐 **Overview**

* In cryptocurrency networks, **gas** refers to the tokens used to pay transaction fees. These fees are essential for processing transactions and maintaining network security, compensating network operators for the real-world costs they incur.

***

## 🔧 **Fee Mechanisms: Other Networks**

* For example, in the **Bitcoin network**, transaction fees are paid in BTC. **Ethereum**, on the other hand, uses ETH as gas. These fees serve the same fundamental purpose across different blockchains but are paid in the respective network's native tokens.

***

## ⛽ **Gas Fees on Hemi**

* Hemi adopts a method akin to Ethereum Layer 2 rollups by using ETH as its gas token. This strategy enhances compatibility and user-friendliness, particularly for those accustomed to Ethereum's system.
* To interact with the Hemi Network, users can obtain ETH and **tunnel** to Hemi. This ensures a seamless and efficient means for users to engage with the Hemi Network's services.

🔍 [Explore Network Details](/discover/network-details)


# Nodes & Clients

{% hint style="info" %}

## 📜 **TL;DR:**

* In cryptocurrency networks, a `node` is a computer (physical or virtual) that connects to the network, while a `client` is the software \*\*that allows the node to communicate with the network.
* The Hemi Network utilizes **five specialized types of nodes** — Bitcoin finality governors (BFG), Bitcoin-secure sequencers (BSS), Proof-of-Proof miners (PoP), Challengers and modified Geth nodes — to enhance network reliability by distributing functions, thus mitigating the impact of single node failures.
  {% endhint %}

***

## 🖥️ **Nodes 101**

* Cryptocurrency networks are powered by a distributed array of computers, each referred to as **a node**, functioning in a peer-to-peer manner where each holds equal standing. Nodes, depending on the client software they run, fulfill different roles within the network.
* For instance, in the Bitcoin network, full nodes store a complete history of transactions for verification purposes, offering high security, while light nodes, focusing on transaction capability, rely on full nodes for information about the network's current state. This setup allows for a flexible network structure where nodes can freely join or leave without disrupting the network's overall functionality.

***

## 🛠️ **Hemi Node Structure**

* In contrast, the Hemi Network employs a more specialized node architecture to optimize network performance and security. It includes:
  * **Bitcoin Finality Governors**: Ensures transactions achieve finality on the Bitcoin blockchain.
  * **Bitcoin-Secure Sequencers**: Orders transactions in a secure manner, leveraging Bitcoin's security.
  * **Proof-of-Proof Miners:** Validates transactions across blockchains without requiring the entire blockchain data.
  * **Modified Geth Node:** Manages Ethereum transactions and block headers in a way tailored for Hemi’s bridging protocols.
  * **Challengers**: Monitors and verifies the correctness of transactions and state proofs (Note: running a Challenger node will be enabled in the near future).
* This segmentation of responsibilities across different node types significantly enhances the Hemi Network's fault tolerance. By isolating specific functions to particular node types, the network ensures that issues within one node type do not compromise the entire network's operations, thereby improving the system's overall reliability.
* This architecture allows user clients to interact seamlessly with both the Bitcoin and Ethereum networks without the complexity of managing diverse node functions.


# Node Guides

## Proof-of-Proof Miners (PoP Miners)

#### 🌐 Overview

* PoP Miners embed Hemi headers — L2 keystones — into Bitcoin blocks, effectively “anchoring” Hemi state to Bitcoin’s security.
* PoP Miners receive Hemi headers from a BFG, create BTC transactions with those headers, and forward them to Bitcoin for inclusion in blocks.
* Successful PoP Miners are earn rewards on the Hemi network, incentivizing them to maintain network operation.

#### **🙋‍♂️ Who might run a PoP Miner?**

* **Network Miners and Operators:** Operators or enthusiasts who want to earn rewards by using their Bitcoin node connectivity. More PoP miners = stronger finality guarantees.

#### **🏁 Requirements**

**➡️ View complete instructions via the** [**PoP Miner tutorial.**](/how-to-tutorials/using-hemi/pop-mining/setup-part-1)

***

## Bitcoin Finality Governor (BFG)

#### **🌐 Overview**

* BFG nodes look for Proof-of-Proof (PoP) transactions that embed Hemi headers into Bitcoin, determining if Hemi blocks have attained Bitcoin-level finality.
* BFG nodes serve as the “checkpoint” mechanism for finality by confirming whether competing versions of Hemi blocks exist on-chain and identifying possible reorgs. The nodes then supply Hemi data to PoP Miners, parse resulting PoP transactions and communicate finality info to BSS nodes.

#### **🙋‍♂️ Who might run a BFG node?**

* **PoP Miners:** A custom BFG daemon can notify your local PoP miner and this will broadcast them to your Electrs+bitcoind setup so you don't rely on Hemi Labs — or any third party — which may be congested.
* **Enterprise Node Operators:** Exchanges, large dApp platforms, or custodial services that need independent, verifiable finality checks on Hemi transactions.

#### **🏁 Requirements**

* A PostgreSQL database, bfgd expects the sql scripts in `./database/bfgd/scripts/` to be run to set up your schema.
* A connection to:
  * An Electrs node on the proper Bitcoin network (testnet or mainnet).
  * bitcoind
  * bfgd

**➡️ View complete instructions via the** [**hemilabs GitHub repo.**](https://github.com/hemilabs/heminetwork?tab=readme-ov-file#%EF%B8%8F-running-bfgd)

***

## Bitcoin-Secure Sequencers (BSS Nodes)

#### 🌐 Overview

* BSS nodes combine Hemi transactions with Ethereum mainnet batches, creating a hybrid solution that inherits Bitcoin security signals (via BFG) and uses Ethereum’s smart contract capabilities.
* These nodes coordinate staking, unstaking, and slashing operations to secure the network, while incorporating finality checkpoints from the BFG. BSS nodes also facilitate cross-chain asset transfers by ensuring that Hemi’s on-chain transactions align with Ethereum-based bridging logic.

#### **🙋‍♂️ Who might run a BSS node?**

* **Validator/Sequencer Operators:** Entities responsible for generating Hemi blocks and maintaining chain consensus.

#### **🏁 Requirements**

* Connect to a live [bfgd](https://github.com/hemilabs/heminetwork/blob/main/cmd/bfgd) instance.

**➡️ View complete instructions via the** [**hemilabs GitHub repo.**](https://github.com/hemilabs/heminetwork?tab=readme-ov-file#%EF%B8%8F-running-bssd)

***

## Modified Geth Node

#### **🌐 Overview**

* Hemi Network runs a specialized Geth implementation that supports extended functionalities, enabling seamless interaction between Hemi’s chain state and Ethereum’s mainnet.
* This modified Geth node manages Ethereum transactions and block headers in a way tailored for Hemi’s bridging protocols. The node also consolidates Ethereum state so that BSS nodes (and other Hemi components) can quickly verify or execute cross-chain logic.

#### **🏁 Requirements**

* Clone the [Hemi Network GitHub](https://github.com/hemilabs/heminetwork) and follow instructions for the Modified Geth build.


# Wallet Support

{% hint style="info" %}

## 📜 **TL;DR:**

* The Ethereum network currently comprises a variety of networks with varying functionality, however Hemi builds primarily on only two: Ethereum mainnet and Sepolia.
* The Bitcoin network currently comprises a variety of networks with varying functionality, however Hemi builds primarily on only two: Bitcoin Mainnet and Bitcoin Testnet.
  {% endhint %}

***

## 🔵 EVM Wallets

### Key Terms and Concepts

* [**EVM (Ethereum Virtual Machine):**](/foundational-topics/the-architecture/ethereum-virtual-machine-evm) A decentralized computing platform that allows developers to build and deploy smart contracts. MetaMask is an EVM wallet, meaning it can interact with any blockchain compatible with the EVM, not just Ethereum.
* **Private Key:** A secret code that allows you to access and control your cryptocurrency in your wallet. It is crucial never to share your private key with anyone, as it grants complete control over your funds.
* **Public Address:** An address that you can share with others to receive funds. It is a string of alphanumeric characters that acts like an account number on the blockchain.
* **Seed Phrase:** A series of 12 or 24 words that serve as a backup to restore access to your wallet. This phrase should be stored securely and privately; if lost or compromised, you could lose access to your funds.
* **Gas Fees:** Transaction fees paid to miners or validators on the blockchain to process and confirm transactions. Fees vary based on network congestion and the complexity of the transaction.
* **dApps (Decentralized Applications):** Applications that run on a blockchain network rather than a centralized server. MetaMask allows users to interact with dApps directly from their browser.

***

### Ethereum Explorer: Etherscan

[Etherscan](https://etherscan.io) is the primary blockchain explorer for Ethereum, providing a comprehensive interface to view transaction details, address balances, token transfers, and smart contract interactions. It’s an invaluable tool for MetaMask users to verify transaction status, track gas fees, and explore the Ethereum blockchain in depth.

* To view transaction details, address balances, token transfers, and smart contract interactions on the Hemi Network, visit the [Hemi block explorer](https://explorer.hemi.xyz).

***

### Ethereum Networks

The Ethereum network currently comprises a variety of networks with varying functionality, however Hemi build primarily on only two:

* **Ethereum Mainnet:** The primary Ethereum network where real ETH transactions occur. It is the live network that supports the Ethereum economy and decentralized applications (dApps), with transactions being irreversible and involving real value and fees.
* **Sepolia Testnet:** A testing environment for Ethereum that mimics the Mainnet but uses testnet ETH with no real value. It allows developers and users to test applications, transactions, and upgrades without risking real funds, providing a stable and efficient testing ground for Ethereum-based projects.

{% hint style="success" %}
If you are ready to get started with Ethereum, you can learn how to [**set up an EVM wallet** ](/how-to-tutorials/using-hemi/wallet-setup/metamask-wallet-setup)and interact with Ethereum on Hemi.
{% endhint %}

***

## 🟠 BTC Wallets

### Key Terms and Concepts

* **Private Key:** A secret code that allows you to access and control your cryptocurrency in your wallet. It is crucial never to share your private key with anyone, as it grants complete control over your funds.
* **Public Address:** An address that you can share with others to receive funds. It is a string of alphanumeric characters that acts like an account number on the blockchain.
* **Seed Phrase:** A series of 12 or 24 words that serve as a backup to restore access to your wallet. This phrase should be stored securely and privately; if lost or compromised, you could lose access to your funds.
* **Confirmation:** The process by which a Bitcoin transaction is included in a block on the blockchain. Each confirmation represents a layer of verification, with multiple confirmations providing increased security against double-spending.
* **UTXO (Unspent Transaction Output):** A key concept in Bitcoin that represents the amount of Bitcoin available to spend. UTXOs are outputs from previous transactions that have not yet been spent, and they form the balance of your Bitcoin wallet.
* **Mempool (Memory Pool):** The mempool is a holding area for unconfirmed transactions on a blockchain, where they wait to be included in the next block by miners or validators. Transactions are prioritized based on their attached fees; those with higher fees are typically confirmed faster. Monitoring the mempool helps users gauge current network congestion and set appropriate transaction fees for quicker confirmations.

***

### Bitcoin Address Types

Bitcoin addresses are the unique identifiers used to send and receive Bitcoin. Over time, several address types have been introduced to improve Bitcoin’s efficiency, security, and scalability.&#x20;

#### Types of Bitcoin Addresses:

* **Legacy (P2PKH):** This is the original and most widely recognized address format. &#x20;
* **Nested SegWit (P2SH-P2WPKH):** An interim solution that allows the benefits of SegWit while maintaining compatibility with Legacy wallets.
* **Native SegWit (bech32):** Native SegWit, also known as bech32, introduces significant improvements in transaction efficiency and scalability.&#x20;
* **Taproot:** Taproot is the latest upgrade to Bitcoin’s address formats, focusing on enhanced privacy, scalability, and flexibility.

***

### Bitcoin Explorer: Mempool.space

* [Mempool.space](https://mempool.space) is a blockchain explorer for Bitcoin that visualizes the current state of the mempool, the pool of unconfirmed transactions, and provides insights into transaction fees and block confirmations. It is particularly useful for BTC wallet users to check the status of their transactions and understand current network congestion.
* To view transaction details, address balances, token transfers, and smart contract interactions on the Hemi network, visit the [Hemi block explorer](https://explorer.hemi.xyz).

***

### Bitcoin Networks

The Bitcoin network currently comprises a variety of networks with varying functionality, however Hemi build primarily on only two:

* **Bitcoin Mainnet:** The primary Bitcoin network where real BTC transactions occur. It is the live network that supports the Bitcoin economy and has actual value, with transactions being irreversible and fees applying.
* **Bitcoin Testnet:** A testing environment for Bitcoin that mimics the Mainnet but uses test BTC with no real value. Developers and users can test applications, transactions, and upgrades without risking real funds. (Not to be confused with Bitcoin Testnet4, a version of Bitcoin Testnet with updated configurations and more stability for testing purposes. It offers an alternative and more reliable test environment compared to the older Testnet3, with no real value attached to the test BTC.

{% hint style="success" %}
If you are ready to get started with Bitcoin, you can learn how to [**set up a BTC wallet**](/how-to-tutorials/using-hemi/wallet-setup/btc-wallet-setup) and interact with Bitcoin on Hemi.
{% endhint %}

***

## 💼 Hardware Wallets

If you use a hardware wallet and want to interact with Hemi, you can connect it through MetaMask to manage your assets securely. This approach allows you to maintain control of your private keys while accessing the Hemi network. For a step-by-step guide on connecting MetaMask with a hardware wallet, please refer to [this guide from Ledger Academy](https://www.ledger.com/academy/security/the-safest-way-to-use-metamask).


# Using Hemi

Follow along with some of the tutorials to help you get a head start when building your first Hemi project.&#x20;

{% hint style="info" %}
**Note:** You may be eligible to earn Hemi [points](https://points.absinthe.network/hemi/start) by completing tutorials. Visit our [dashboard](https://points.absinthe.network/hemi/start) for more information on active quests.
{% endhint %}

### Wallet Setup

<table><thead><tr><th width="217">Tutorial</th><th width="384">Description</th><th>Difficulty</th></tr></thead><tbody><tr><td><a href="/pages/RzpetO4Pv4ZKpSkW6Bdd">Set Up an EVM Wallet</a></td><td>Learn how to set up and get started with an EVM (<a href="https://metamask.io">MetaMask</a>) wallet.</td><td>🟢 Easy</td></tr><tr><td><a href="/pages/MvU1gbQSInassxfNMvqv">Set Up a BTC Wallet</a></td><td>Learn how to set up and get started with a BTC (<a href="https://unisat.io">UniSat</a>) wallet.</td><td>🟢 Easy</td></tr></tbody></table>

***

### Tunneling

<table><thead><tr><th width="217">Tutorial</th><th width="384">Description</th><th>Difficulty</th></tr></thead><tbody><tr><td><a href="/pages/VkInzAODuwBzbXzmYFPz">Tunnel ETH to Hemi</a></td><td>Learn how to <a href="/pages/pOtZUR40iAPGyEG2SSi2">tunnel</a> (bridge) your ETH assets to and from Hemi.</td><td>🟢 Easy</td></tr><tr><td><a href="/pages/svWewuS7Xci0hL0rv1nG">Tunnel BTC to Hemi</a></td><td>Learn how to <a href="/pages/pOtZUR40iAPGyEG2SSi2">tunnel</a> (bridge) your BTC assets to and from Hemi.</td><td>🟢 Easy</td></tr><tr><td><a href="/pages/Xi81Pl47K7x6YmVgFZSi">Stake on Hemi</a></td><td>Learn about <a href="/pages/Xi81Pl47K7x6YmVgFZSi">staking</a> on Hemi.</td><td>🟢 Easy</td></tr></tbody></table>

***

### Developer Tooling

<table><thead><tr><th width="198">Tutorial</th><th width="397">Description</th><th>Difficulty</th></tr></thead><tbody><tr><td><a href="/pages/vKTk3OoJynYYddd2C7no">Set Up a Safe Wallet</a></td><td>Learn about multi-sig wallets and set up a <a href="https://safe.global">Safe</a> Wallet on Hemi.</td><td>🟢 Easy</td></tr><tr><td><a href="/pages/dGuMAFUfiy2iRSsk1MeE">Create a Capsule</a></td><td>Learn about gasless transactions, re-routing/recalling, and configurable security with <a href="/pages/0Tb3yNIIHy5udB9WaZbs">Capsules</a> on Hemi.</td><td>🟡 Medium</td></tr></tbody></table>

***

### PoP Miner

<table><thead><tr><th width="194">Tutorial</th><th width="397">Description</th><th>Difficulty</th></tr></thead><tbody><tr><td><a href="/pages/sNv0KyCzVXSLkYQsUnlM">Run the CLI PoP Miner</a></td><td>Set up and run your PoP miner, either by downloading pre-built binaries or by building from source.</td><td>🟡 Medium</td></tr><tr><td><a href="/pages/blcqrlWHY3zPQn9g3cz7">Add tHEMI to MetaMask</a></td><td>Earning tHEMI rewards from PoP mining? Add the token contract address and view rewards.</td><td>🟢 Easy</td></tr></tbody></table>


# Wallet Setup


# EVM Wallet Setup

{% hint style="info" %}

## 📜 **TL;DR:**

* [MetaMask](https://metamask.io/download/), available as a browser extension and mobile app, is designed to let users easily manage their cryptocurrencies and interact with dApps.
* This guide walks you through adding the Hemi network to MetaMask, including setting up network details like RPC URL, Chain ID, and Block Explorer URL.
* For a step-by-step guide on connecting MetaMask with a hardware wallet, please refer to [this guide from Ledger Academy](https://www.ledger.com/academy/security/the-safest-way-to-use-metamask).
  {% endhint %}

***

## 🏁 Prerequisites

* [MetaMask Extension Download ](https://metamask.io/download/)to execute transactions and smart contract interactions within the Ethereum network.

***

## 📚 Tutorial

### Video

{% embed url="<https://vimeo.com/1027100796?share=copy>" %}

### 1. Open the MetaMask Extension

<figure><img src="/files/WXY3gq9bJw4RuD0Kseog" alt="" width="188"><figcaption></figcaption></figure>

***

### 2. Access Network Selection Settings

Click on the network-selection dropdown, which is found at the top left of the MetaMask window.

<figure><img src="/files/aqdA18ALLfEOOPjEfbKu" alt="" width="359"><figcaption></figcaption></figure>

***

### 3. Select "Add Network"

<figure><img src="/files/g6HDnlP5UwdxUZdodxRg" alt="" width="348"><figcaption></figcaption></figure>

***

### 4. Add a Network Manually

<figure><img src="/files/NCsqa3plcQq0wpvTcHMd" alt=""><figcaption></figcaption></figure>

***

### 5. **Enter Network Details**

In the "`Add a network manually"` settings, input the following information for the Hemi testnet network:

<table><thead><tr><th width="289"></th><th>Hemi mainnet</th></tr></thead><tbody><tr><td><strong>Gas Token/Currency Symbol</strong></td><td>ETH</td></tr><tr><td><strong>ChainID</strong></td><td>43111</td></tr><tr><td><strong>RPC API endpoint</strong></td><td>https://rpc.hemi.network/rpc</td></tr><tr><td><strong>Explorer</strong></td><td><a href="https://explorer.hemi.xyz">https://explorer.hemi.xyz</a></td></tr></tbody></table>

For Hemi testnet, input the following information instead:

<table><thead><tr><th width="289"></th><th>Hemi testnet</th></tr></thead><tbody><tr><td><strong>Gas Token/Currency Symbol</strong></td><td>ETH</td></tr><tr><td><strong>ChainID</strong></td><td>743111</td></tr><tr><td><strong>RPC API endpoint</strong></td><td>https://testnet.rpc.hemi.network/rpc</td></tr><tr><td><strong>Explorer</strong></td><td><a href="https://testnet.explorer.hemi.xyz">https://testnet.explorer.hemi.xyz</a></td></tr></tbody></table>

***

### 6. **Your EVM wallet is ready to go! 🎉**

Select `Save` to add the Hemi network to your MetaMask.

***

## 🔄 Switch between Ethereum Mainnet and Sepolia

After you have set up your EVM wallet on MetaMask, you may want to explore some of the unique features on Hemi testnet. This requires switching the connected network in your MetaMask wallet.

{% hint style="info" %}
To ensure visibility of your `ETH` on the Sepolia testnet, toggle the `Show test networks`option in MetaMask:

* Select the drop down on the left
* Toggle `Show Test Networks`
* Select `Sepolia`
  {% endhint %}

<figure><img src="/files/IUZJBJqz5LVG1c7HmFOV" alt="" width="563"><figcaption></figcaption></figure>

***


# BTC Wallet Setup

{% hint style="info" %}
📜 **TL;DR:**

* [UniSat](https://unisat.io), available as a browser extension and mobile app, is designed to let users easily manage their Bitcoin assets and interact with dApps.
* This guide walks you through setting up your UniSat wallet.
  {% endhint %}

***

## 🏁 Prerequisites

#### 1. Add the UniSat Chrome extension

Navigate to the [UniSat extension download](https://chromewebstore.google.com/detail/unisat-wallet/ppbibelpcjmhbdihakflkdcoccbgbkpo) and click `'Add to Chrome.'`

<figure><img src="/files/jaRqZFJVaHK1wuEmlJZB" alt=""><figcaption></figcaption></figure>

Click `'Add extension.'`

***

## 📚 Tutorial

## Video

{% embed url="<https://vimeo.com/1027100341>" %}

### 1. Open the UniSat Chrome extension

Open the UniSat extension and click `'Create new wallet.'`

<figure><img src="/files/SOCYma0emDOUmCoZjYM3" alt=""><figcaption></figcaption></figure>

***

### 2. Create a password

<figure><img src="/files/M9GlVIv78aTKNO9aLS0Q" alt=""><figcaption></figcaption></figure>

***

### 3. Copy your secret recovery phrase

{% hint style="danger" %}
**Make sure to save your private key.** Your private key provides full access to your wallet and funds.

* Hemi team members will never ask you for private keys.
* Do not share it with anyone.
  {% endhint %}

<figure><img src="/files/7qlYxnNYIqYR86fWo6sW" alt=""><figcaption></figcaption></figure>

After you have saved your private key in a secure area, click `'Continue.'`

***

### 4. Select address type

Hemi currently uses two primary address types:

* **Legacy (P2PKH):** PoP mining currently requires a P2PKH address, although this may change at some point in the future.&#x20;
* **Native SegWit (P2WPKH):** For everything else on Hemi (i.e., Bitcoin tunneling), any address type can be used but P2WPKH will (generally) be the cheapest fee-wise.

{% hint style="info" %}
We recommend creating a **Native SegWit** wallet to jumpstart in the Bitcoin ecosystem. New wallets and other address types can be created in the future.
{% endhint %}

<figure><img src="/files/EqkgB9kHURl5RNgUJ5Ho" alt=""><figcaption></figcaption></figure>

After you have selected your address type, click `'Continue.'`

***

### 5. Your UniSat wallet setup is complete! 🎉

<figure><img src="/files/oWyZAwlmmCkH0A7nVMmV" alt=""><figcaption></figcaption></figure>

***


# Switch Bitcoin Networks

{% hint style="info" %}

## 📜 **TL;DR:**

* When setting up your UniSat wallet, the browser extension will default to the Bitcoin mainnet network.&#x20;
* If you plan on building on or interacting with Bitcoin testnet, you may need to change the network your UniSat wallet is set to in order to view your testnet assets.&#x20;
* This guide walks you through switching the connected network on your UniSat wallet.
  {% endhint %}

***

## 🏁 Prerequisites

* [UniSat Wallet Setup](/how-to-tutorials/using-hemi/wallet-setup/btc-wallet-setup)

***

## 📚 Tutorial

### 1. Open the UniSat browser extension ![](/files/qyKLY3CGr2A0HaskLBJl)

***

### 2. Select the network dropdown

Click the network dropdown in the top-right corner to view all Bitcoin networks. \
![](/files/QuCYXPWVie42ZxGjxl7q)

***

### 3. Select Bitcoin Testnet

Select `'Bitcoin Testnet'` from the list of networks. \
&#x20;![](/files/arD5i8XSgO8Y9yxZyZ4I)\
\
From here, the dropdown should expand and you can click on `'Bitcoin Testnet'.`\
![](/files/g4vJmYUZkK2INt19zf8L)

***

### 4. You are ready to interact on Bitcoin Testnet! 🎉

Your wallet is now ready to send, receive, and sign transactions on Bitcoin Testnet!


# Tunnel from Ethereum


# Tunnel ERC20s via Native Tunnel

{% hint style="info" %}

## 📜 **TL;DR:**

* Tunnel your ERC20s to Hemi by using the native Hemi Tunnel, enabling interactions within the Hemi Network ecosystem.
  {% endhint %}

***

## 🏁 Prerequisites

* [**EVM (MetaMask) Wallet Setup**](/how-to-tutorials/using-hemi/wallet-setup/metamask-wallet-setup) **-** Set up your EVM wallet and add the Hemi Network before interacting with any Hemi application.

***

## 📚 Tutorial

## Video

{% embed url="<https://vimeo.com/1027101057?share=copy>" %}

### 1. Visit the Hemi Portal&#x20;

Go to <https://app.hemi.xyz/en/tunnel/> to tunnel your ERC20 asset from Ethereum to the Hemi network.

{% hint style="info" %}
Confirm your network of choice via the network dropdown at the bottom left.&#x20;
{% endhint %}

<figure><img src="/files/x1zusGozdPWwoQxKPfAM" alt=""><figcaption></figcaption></figure>

***

### 2. Connect wallet

Click `'Connect Wallets'`  in the top-right corner of the Hemi Portal.

<figure><img src="/files/G65tU5qiWRLxhJp57D7G" alt=""><figcaption></figcaption></figure>

***

### 3. Connect your EVM wallet

Currently, MetaMask and Rabby are the only EVM wallets Hemi supports. Our team is working to add support for additional wallets.

<figure><img src="/files/nSrpePpTdiEJn9nUZvLa" alt=""><figcaption></figcaption></figure>

***

### 4. Connect to the Ethereum Network

Ensure that you are connected to the Ethereum Network. If you are not connected, the Portal will prompt you to connect.

<figure><img src="/files/vwqjVONyZVTDbC1UrnwT" alt=""><figcaption></figcaption></figure>

***

### 5. Select asset and enter the amount to tunnel

Use the token dropdown to select the asset you wish to tunnel. After selecting the asset, input the amount of the asset you wish to move to Hemi.

<figure><img src="/files/PojpGuUZj9r0dw08U5hq" alt=""><figcaption></figcaption></figure>

After you have confirmed the gas fee and wish to proceed with the deposit, click `'Deposit.'`

***

### 6. Confirm the deposit

Sign and confirm your deposit transaction in your connected wallet.

<figure><img src="/files/yzCrEPAp1yIuv7D5ptUd" alt=""><figcaption></figcaption></figure>

***

### 7. You have successfully tunneled to Hemi! 🎉

Your transaction should now be complete! You can check the status and view the transaction in the `'Transaction History'` tab.

<figure><img src="/files/6jPsUASmkt26z6E8723X" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/GTVxY00Av39P31qG0FRd" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
**Note**: You can also confirm your transaction was successful in the `Activity` tab of your wallet.

![](/files/ZUboEQ537aIgCeG6KLOp)
{% endhint %}


# Tunnel ERC20s via 3rd Party

{% hint style="info" %}

## 📜 **TL;DR:**

* Certain tokens are not yet supported by Hemi’s native Tunnel.&#x20;
* For these assets, you can use one of several third-party tunnel solutions to move tokens between Ethereum and Hemi.
  {% endhint %}

***

## 🔄 Why Use a Third-Party Bridge?

Hemi’s native Tunnel supports a range of popular ERC-20 tokens. However, some assets (e.g., USDC, USDT) are not yet integrated. In these cases, a third-party bridge provides:

• Fast bridging times.

• Established track record of security and reliability.

• Wide token support, including stablecoins like USDC and USDT.

***

## 🤝 Supported Third-Party Bridges

Below is a list of third-party bridges you can use to transfer assets to Hemi. Each bridge has its own UI, fees, and specific token support.&#x20;

<table><thead><tr><th width="245">Bridge</th><th>Link</th></tr></thead><tbody><tr><td>Stargate</td><td><a href="https://stargate.finance/bridge">https://stargate.finance/bridge</a></td></tr><tr><td>Eigenpie</td><td><a href="https://www.eigenlayer.magpiexyz.io/bridge">https://www.eigenlayer.magpiexyz.io/bridge</a></td></tr></tbody></table>


# Tunnel via Stargate

{% hint style="info" %}

## 📜 **TL;DR:**

* Tunnel your ERC20s to Hemi by using the Stargate third-party bridge.
* Supported assets include USDC, USDT, ETH, and more.
  {% endhint %}

***

## 🏁 Prerequisites

* [**EVM (MetaMask) Wallet Setup**](/how-to-tutorials/using-hemi/wallet-setup/metamask-wallet-setup) **-** Set up your EVM wallet and add the Hemi Network before interacting with any Hemi application.

***

## 📚 Tutorial

### 1. Visit the Stargate bridge&#x20;

Navigate to the [Stargate bridge ](https://stargate.finance/bridge?srcChain=ethereum\&dstChain=hemi)to tunnel your ERC20 asset from Ethereum to the Hemi network.

<figure><img src="/files/v3z96Wq05lWYKT9CEUKr" alt=""><figcaption></figcaption></figure>

***

### 2. Connect wallet

Click `'Connect Wallet'` in the top-right corner.

<figure><img src="/files/LisqQsPSqkFDtRzUnTBx" alt=""><figcaption></figcaption></figure>

***

### 3. Select the asset and confirm networks

Using the token dropdown, select the asset you wish to bridge to Hemi.&#x20;

{% hint style="info" %}
Before proceeding, confirm Ethereum as the FROM network and Hemi as the TO network.
{% endhint %}

<figure><img src="/files/F5DyjKfJU9og3ftD0wVd" alt=""><figcaption></figcaption></figure>

***

### 4. Enter the amount to bridge

Input the amount of asset you wish to bridge to Hemi.

<figure><img src="/files/ZPdkDawZrJ0NzZkmUHZB" alt=""><figcaption></figcaption></figure>

When you are satisfied with your transaction, click `'Transfer'.`

***

### 5. Approve and sign the transaction

From your connected wallet, approve the asset spend and sign the transaction.

<figure><img src="/files/4kxAC1veOM8XN5d2HPza" alt=""><figcaption></figcaption></figure>

***

### 6. You have successfully tunneled to Hemi! 🎉

After signing the transaction, look for the pending transaction bar at the top of the screen. It may take a few minutes to confirm the transaction.

<figure><img src="/files/l3zXtpMTviDplF6Wb6CL" alt=""><figcaption></figcaption></figure>


# Tunnel from Bitcoin


# Tunnel BTC via Native Tunnel

{% hint style="info" %}

## 📜 **TL;DR:**

* Move your BTC to Hemi by using the Bitcoin Tunnel, enabling interactions within the Hemi Network ecosystem with Bitcoin assets.
* An [EVM](/how-to-tutorials/using-hemi/wallet-setup/metamask-wallet-setup) and [BTC](/how-to-tutorials/using-hemi/wallet-setup/btc-wallet-setup) wallet are required to move BTC assets via the Bitcoin Tunnel.
* A minimum of `0.0001 BTC` is required to deposit and withdrawal using the Native Tunnel.
  {% endhint %}

***

## 🏁 Prerequisites

* **Acquire BTC** - BTC can be purchased on any number of exchanges and on-ramps.&#x20;
* [**EVM (MetaMask) Wallet Setup**](/how-to-tutorials/using-hemi/wallet-setup/metamask-wallet-setup) **-** Set up your EVM wallet and add Hemi Network.
* [**BTC Wallet Setup**](/how-to-tutorials/using-hemi/wallet-setup/btc-wallet-setup) **-** Set up your BTC wallet.

{% hint style="info" %}
**TESTNET ONLY**\
\
If you plan on developing on or interacting with Hemi testnet, alternative prerequisites may apply. To test out the Bitcoin Tunnel on testnet, you can obtain tBTC (Testnet Bitcoin) via the [**Direct Faucet Access**](https://coinfaucet.eu/en/btc-testnet/)**.**
{% endhint %}

***

## 📚 Tutorial

### 1. Visit the Hemi Portal&#x20;

Go to <https://app.hemi.xyz/en/tunnel/> to access the Hemi Portal.

{% hint style="info" %}
Select your network of choice using the network dropdown located at the bottom left.
{% endhint %}

<figure><img src="/files/zOEmXZP8d8jLJKD2gs6c" alt=""><figcaption></figcaption></figure>

***

### 2. Connect wallet

Click `'Connect Wallets'` in the top-right corner of the Hemi Portal.

<figure><img src="/files/thfYiDijNPZ7LoClZSfw" alt=""><figcaption></figcaption></figure>

***

### 3. Connect your EVM wallet

Currently, MetaMask and Rabby are the only EVM wallets Hemi supports. Our team is working to add  support for additional wallets.

{% hint style="info" %}
Connecting an EVM wallet is required for the initial version of the Bitcoin Tunnel. The address connected will receive the tunneled Bitcoin assets.&#x20;
{% endhint %}

<figure><img src="/files/ptBE8ZS51GchUDUR1lGw" alt=""><figcaption></figcaption></figure>

***

### 4. Connect your BTC wallet

Connect your BTC wallet (currently only UniSat supported). If you do not have a UniSat wallet, you can view our [tutorial](/how-to-tutorials/using-hemi/wallet-setup/btc-wallet-setup) to create and set one up.&#x20;

<figure><img src="/files/NINzT8st9lnz1cVGRz2F" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/SzLvRIAv9hK7WZgdQsEn" alt=""><figcaption></figcaption></figure>

***

### 5. Select 'Bitcoin' as the 'From Network'

Ensure that you are connected to the Bitcoin network.&#x20;

<figure><img src="/files/QfpZu8KjDrIk6ispI71C" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
**Tunneled BTC will be sent to the EVM address connected** (denoted by the '`Receiving Hemi Address`' at the bottom of the screen). In future versions, you will be able to manually input the preferred receiving address.
{% endhint %}

***

### 6. Enter the amount of BTC to tunnel

Input the amount of BTC you wish to tunnel to Hemi. There is a minimum amount of `0.0001 BTC` to deposit and withdrawal. &#x20;

<figure><img src="/files/tnkuNNLNo5YMdRMPvD7y" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/dgV4dYRqUId4TID8IQit" alt=""><figcaption></figcaption></figure>

After you have confirmed the gas fee and wish to proceed with the deposit, click `'Deposit.'`

***

### 7. Confirm the deposit in UniSat

Confirm your BTC deposit in the UniSat browser extension.

<figure><img src="/files/ETb3DqGSOHPCiFzqV8nb" alt=""><figcaption></figcaption></figure>

***

### 8. You have successfully tunneled BTC to Hemi! 🎉

Your transaction has been initiated and must go through two confirmation periods to confirm your deposit:

1. Withdrawal from BTC address (\~1hr) - When you initiate a deposit request, a transaction is signed from your BTC address to transfer the specified amount into a secure vault on the Bitcoin network. This deposit requires six block confirmations, which generally takes about one hour to complete.
2. Deposit into EVM Hemi address - Once the deposit is fully confirmed on the Bitcoin network, the Hemi Network validates the transaction and mints a corresponding token receipt (`hemiBTC`) on the Hemi blockchain, ensuring a seamless transition of assets.

You can check the status and view the transaction in the `'Transaction History'` tab.&#x20;

<figure><img src="/files/86xqexWOWmkIqd4E5Swk" alt=""><figcaption></figcaption></figure>

{% hint style="success" %}
`hemiBTC` can be tracked and added to your wallet at the following contract address: **`0xAA40c0c7644e0b2B224509571e10ad20d9C4ef28`**
{% endhint %}

#### Manual confirmation of deposit

After six confirmations, Hemi can confirm a successful deposit from the Bitcoin network and deposit the funds to your address. Occasionally, the vault operator will require a manual confirmation in order to complete the deposit.&#x20;

<figure><img src="/files/lurbNxyQmxyVOHJa2jDX" alt=""><figcaption></figcaption></figure>


# Tunnel BTC via 3rd Party

{% hint style="info" %}

## 📜 **TL;DR:**

* Certain tokens are not yet supported by Hemi’s native Tunnel.&#x20;
* For these assets, you can use one of several third-party tunnel solutions to move tokens between Bitcoin and Hemi.
  {% endhint %}

***

## 🔄 Why Use a Third-Party Bridge?

Hemi’s native Tunnel supports tunneling BTC, however, some assets (e.g., pumpBTC, iBTC) are not yet integrated. In these cases, a third-party bridge provides:

• Fast bridging times.

• Established track record of security and reliability.

• Wide token support.

***

## 🤝 Supported Third-Party Bridges

Below is a list of third-party bridges you can use to transfer BTC assets to Hemi. Each bridge has its own UI, fees, and specific token support.&#x20;

<table><thead><tr><th width="256">Bridge</th><th>Link</th><th data-hidden></th></tr></thead><tbody><tr><td>Free.tech</td><td><a href="https://free.tech/">https://free.tech</a></td><td></td></tr><tr><td>Meson</td><td><a href="https://meson.fi/swap">https://meson.fi/swap</a></td><td></td></tr><tr><td>Magpie</td><td><a href="https://www.babylon.magpiexyz.io/bridge">https://www.babylon.magpiexyz.io/bridge</a></td><td></td></tr></tbody></table>


# Tunnel via Free.Tech


# Tunnel via Meson


# Stake

{% hint style="info" %}

## 📜 **TL;DR:**

* Deposit BTC, ETH, or stablecoins into reward contracts and earn passive income from ecosystem incentives.
* Earn rewards from Hemi and its partners, with bonuses for early adopters and high-value deposits.
  {% endhint %}

***

## 🌐 Overview

[**Hemi Stake**](https://app.hemi.xyz/stake) provides a seamless way for users to earn rewards by locking up assets within the Hemi ecosystem. Unlike traditional Proof-of-Stake (PoS) mechanisms, staking on Hemi does **not** involve securing the network or slashing risks. Instead, it enables users to **deposit assets into specialized reward contracts** to participate in yield opportunities across partner protocols.

#### Key Benefits:

* **No Slashing Risk** – Assets are never used for network validation.
* **Flexible Deposits & Withdrawals** – No bonding periods; stake and unstake anytime.
* **Multi-Asset Support** – Stake Bitcoin, Ethereum, and stablecoins assets.
* **Ecosystem-Wide Rewards** – Earn incentives from Hemi and partner networks.

***

## 🔍 How It Works

Hemi’s staking contracts function differently from PoS staking by offering a **reward-based deposit model**:

* Users deposit assets into smart contracts designed for staking rewards.
* Rewards accumulate over time, distributed by Hemi and integrated partners.
* No lock-up requirements – Users can unstake at any time.

***

## ✅ Supported Assets

Hemi’s staking program supports a variety of assets across Bitcoin, Ethereum, and stablecoin categories.

#### **Bitcoin Assets:**

<table><thead><tr><th width="187">Asset</th><th width="172">Provider</th><th>Description</th></tr></thead><tbody><tr><td><strong><code>hemiBTC</code></strong></td><td>Hemi</td><td>Hemi’s native BTC representation.</td></tr><tr><td><strong><code>uBTC</code></strong></td><td>Unirouter</td><td>BTC staked on B2 Network.</td></tr><tr><td><strong><code>pumpBTC</code></strong></td><td>PumpBTC</td><td>BTCB &#x26; WBTC staked on Babylon.</td></tr><tr><td><strong><code>stBTC</code></strong></td><td>Lorenzo</td><td>BTC staked by Babylon.</td></tr><tr><td><strong><code>enzoBTC</code></strong></td><td>Lorenzo</td><td>Wrapped BTC token.</td></tr><tr><td><strong><code>iBTC</code></strong></td><td>exSat Network</td><td>BTC staked on exSat Network.</td></tr><tr><td><strong><code>M-BTC</code></strong></td><td>Merlin</td><td>BTC staked on Merlin.</td></tr><tr><td><strong><code>oBTC</code></strong></td><td>Obelisk</td><td>BTC staked on Obelisk.</td></tr><tr><td><strong><code>tBTC</code></strong></td><td>Threshold</td><td>BTC staked on Threshold.</td></tr><tr><td><strong><code>mBTC</code></strong></td><td>Magpie</td><td>BTC staked on Babylon.</td></tr><tr><td><strong><code>WBTC</code></strong></td><td>Wrapped BTC</td><td>Wrapped BTC token.</td></tr></tbody></table>

#### **Ethereum Assets:**

<table><thead><tr><th width="185">Asset</th><th width="184">Provider</th><th>Description</th></tr></thead><tbody><tr><td><strong><code>ETH</code></strong></td><td>Hemi</td><td>Native ETH token.</td></tr><tr><td><strong><code>WETH</code></strong></td><td>Hemi</td><td>Wrapped ETH token.</td></tr><tr><td><strong><code>rsETH</code></strong></td><td>Kelp</td><td>ETH staked on Kelp.</td></tr><tr><td><strong><code>egETH</code></strong></td><td>Eigenpie</td><td>ETH staked on Eigenlayer.</td></tr><tr><td><strong><code>VUSD</code></strong></td><td>Hemi</td><td>USD-pegged stablecoin from Hemi.</td></tr><tr><td><strong><code>USDT</code></strong></td><td>Tether</td><td>Tether's stablecoin.</td></tr><tr><td><strong><code>USDC</code></strong></td><td>Circle</td><td>Circle's stablecoin.</td></tr><tr><td><strong><code>DAI</code></strong></td><td>MakerDAO</td><td>MakerDAO's stablecoin.</td></tr></tbody></table>

***

## 🎁 Rewards

Hemi’s staking program offers rewards based on asset deposits and participation within the ecosystem:

* Earn ecosystem rewards across Hemi and partnered protocols.
* Points-based incentives may apply for early participants and high-value deposits.
* Earn additional benefits on highly-incentivized asset groups.


# How to Stake

{% hint style="info" %}

## 📜 **TL;DR:**

* Stake your BTC, ETH, and other assets using the Hemi Stake platform.
* An [EVM](/how-to-tutorials/using-hemi/wallet-setup/metamask-wallet-setup) wallet is required to stake assets on Hemi.
  {% endhint %}

***

## 🏁 Prerequisites

* [**EVM (MetaMask) Wallet Setup**](/how-to-tutorials/using-hemi/wallet-setup/metamask-wallet-setup) **-** Set up your EVM wallet and add Hemi Network.

***

## 📚 Tutorial

### 1. Visit the Hemi Stake platform&#x20;

Go to <https://app.hemi.xyz/stake> to access the Hemi Stake platform.

<figure><img src="/files/zOEmXZP8d8jLJKD2gs6c" alt=""><figcaption></figcaption></figure>

***

### 2. Connect wallet

Click `'Connect Wallets'` in the top-right corner of the Hemi Portal.

<figure><img src="/files/thfYiDijNPZ7LoClZSfw" alt=""><figcaption></figcaption></figure>

***

### 3. Connect your EVM wallet

Currently, MetaMask and Rabby are the only EVM wallets Hemi supports. Our team is working to add  support for additional wallets.

<figure><img src="/files/ptBE8ZS51GchUDUR1lGw" alt=""><figcaption></figcaption></figure>

***

### 4. Click "Stake"&#x20;

To begin staking, navigate to the "Stake" page of the staking platform.

***

### 5. Click "Stake"&#x20;

To begin staking, navigate to the "Stake" page of the staking platform.


# Developer Tooling


# Set Up a Safe Wallet

{% hint style="warning" %}
This documentation page is outdated and may not reflect current information.
{% endhint %}

{% hint style="info" %}

## 📜 **TL;DR:**

* Safe is a smart contract wallet that requires a minimum number of people to approve a transaction before it can occur (M-of-N).
* Earn and track Hemi [points](https://points.absinthe.network/hemi/start) for completing this tutorial!
  {% endhint %}

***

## 🏁 Prerequisites

1. [MetaMask Wallet Setup](/how-to-tutorials/using-hemi/wallet-setup/metamask-wallet-setup)

***

## 📚 Tutorial

## Video

{% embed url="<https://vimeo.com/1027100950?share=copy>" %}

### 1. Visit the Hemi Safe [website](https://safe.hemi.xyz/)

***

### 2. Connect your wallet

To get started, connect your wallet to the Safe site. For this tutorial, we will be using MetaMask.

<figure><img src="/files/Gvgzfm1IQgWNMq3of7zD" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/Dbn99CI5nc1KPcvX1L4F" alt=""><figcaption></figcaption></figure>

***

### 3. Name your Safe

After connecting your wallet, you will be prompted to name your Safe account.&#x20;

{% hint style="info" %}
**Doublecheck the wallet and network provided** in the right-hand screen. Confirm that the wallet connected is the wallet you would like to use to create your Safe wallet, and that the network is set to Hemi Sepolia.&#x20;
{% endhint %}

<figure><img src="/files/OSg7Z2PNoRXQn0uHtes1" alt=""><figcaption></figcaption></figure>

When you are ready to proceed, click `'Next'`.

***

### 4. Add signers and assign a threshold

A Safe Wallet can be set up as a multi-sig wallet, whitelisting addresses who may sign transactions on behalf of the wallet. You may assign a name to each address you intend to add to the wallet.  &#x20;

<figure><img src="/files/LF9SM6wQeHdIuVyHIt2n" alt=""><figcaption></figcaption></figure>

After adding additional signers, you may specify how many signers are required to sign any given transaction. This variable is referred to as the Threshold. <br>

<figure><img src="/files/G3YxtlecAC2cgDcgCVRd" alt=""><figcaption></figcaption></figure>

After finalizing the verified signers and threshold requirements, click `'Next'` to proceed.

***

### 5. Review and verify your Safe account

Review and verify the network, name, signers, threshold, and estimated network fee to create your Safe account.

<figure><img src="/files/VIGs0Akrx32hlmMHYxKL" alt=""><figcaption></figcaption></figure>

After confirming all given information, click `'Create'` to proceed.&#x20;

***

### 6. Confirm the transaction in your wallet

Confirm the recent transaction via your MetaMask wallet.

<figure><img src="/files/st2CcqgVSo6itKMospNp" alt=""><figcaption></figcaption></figure>

***

### 7. You have successfully created a Safe Wallet! 🎉

Your Safe Wallet is ready for use! You may add funds to your wallet and explore sending and receiving assets.

<figure><img src="/files/DENEGsZGMKzTVdixLKDH" alt=""><figcaption></figcaption></figure>


# Create a Capsule

{% hint style="info" %}

## 📜 **TL;DR:**

* Capsule is an asset transfer protocol that allows anyone to batch and transfer multiple assets in a single package on Hemi.
* Additionally, Capsule provides users and developers with advanced functionality like gasless transactions, re-routing/recalling, and configurable security.
* Earn and track Hemi [points](https://points.absinthe.network/hemi/start) for completing this tutorial!
  {% endhint %}

***

## 📖 Background

* Capsule is an asset transfer protocol that allows anyone to batch and transfer multiple assets in a single package on Hemi.
* Additionally, Capsule provides users and developers with advanced functionality like gasless transactions, re-routing/recalling, and configurable security.
* Visit [Capsule Labs](https://capsulelabs.xyz) to learn more about the Capsule protocol.

***

## 🏁 Prerequisites

1. [MetaMask Wallet Setup](/how-to-tutorials/using-hemi/wallet-setup/metamask-wallet-setup)
2. [Tunnel ETH to Hemi ](/how-to-tutorials/using-hemi/tunnel-from-ethereum/tunnel-eth-to-hemi)(or other Hemi assets)

***

## 📚 Tutorial

## Video

{% embed url="<https://vimeo.com/1030135231?share=copy>" %}

### 1. Visit the Hemi Capsule [website](https://app.capsulelabs.xyz/)

***

### 2. Connect your MetaMask wallet

Connect your MetaMask wallet by clicking the button in the top-right corner.&#x20;

{% hint style="warning" %}
**Capsule currently only supports the Hemi testnet network.** View our official [documentation](/discover/network-details) to add the Hemi testnet network to your wallet and ensure that you are connected to the Hemi network before proceeding.
{% endhint %}

***

### 3. Add assets to your Capsule

Click `'Add Asset'` to select the Hemi assets you would like to add to the Capsule. You may add any quantity and any combination of any Hemi assets as desired.&#x20;

<figure><img src="/files/TM0BO9AbCul4168A5NKY" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/Zafhvrb1FV6RyQfyDIK7" alt=""><figcaption></figcaption></figure>

*Optional*: You may change the name of the Capsule generated in the text box below the `'Add Asset'` button.

When finished, click  `'Continue'`.

***

### 4. Add features

Capsule comes with a variety of optional features, including:

* **Gasless Pickup:** The assets can be redeemed without pay gas costs.
* **Time Locked:** The assets cannot be redeemed until a specific time.
* **Password Protection:** A password is required to redeem the assets (a unique and random password is provided by Capsule).
* **Asset Key Verification:** The asset cannot be redeemed unless the recipient holds a designated NFT in their wallet (specific ID optional).

![](/files/mOUxWEfigKyFnwVOaIEZ)

After selecting and adjusting any preferred features, click  `'Continue'`.

***

### 5. Verify the transaction

Once you are satisfied with your Capsule, click the checkmark that says `'I've read and I agree to the terms listed in the Capsule Terms of Service and Privacy Policy.'`

When finished, click  `'Continue'`.

***

### 6. Approve the assets included in your Capsule

To finalize your Capsule, you must approve all the assets you included inside your MetaMask wallet.&#x20;

<figure><img src="/files/PX7MMwAni3bavTJL9asO" alt=""><figcaption></figcaption></figure>

When finished, click  `'Continue'`.

***

### 7. Confirm the transaction

Confirm your transaction in MetaMask.

<figure><img src="/files/vx8NrS3c2rzJysQOsaP5" alt=""><figcaption></figcaption></figure>

***

### 8. All done! 🎉

Copy your Capsule transfer link (and if included, your redemption password) and distribute your Capsule as desired!&#x20;

<figure><img src="/files/k8jGKjSb1arIObN2jPpw" alt=""><figcaption></figcaption></figure>


# PoP Mining


# CLI PoP Miner

{% hint style="warning" %}
This documentation page is outdated and may not reflect current information.
{% endhint %}

{% hint style="info" %}

#### 📜 **TL;DR:**

* This guide provides straightforward steps to download, set up, and run your PoP Miner, either by downloading **pre-built binaries** or by **building from source**.
* Ensure you have your development environment ready and follow the steps below to start PoP mining.
* Basic CLI skills are required.
  {% endhint %}

***

## 🏁 Prerequisites

* Basic CLI Knowledge
* **BTC** (See [#bitcoin-fee-vb](#bitcoin-fee-vb "mention") to understand how much BTC is required to PoP mine)

***

## 📚 Tutorial

## Video

{% embed url="<https://vimeo.com/1027100409?share=copy>" %}

### 1. Binaries

[Download a pre-built binary](https://github.com/hemilabs/heminetwork/releases) or [build from source using the README](https://github.com/hemilabs/heminetwork?tab=readme-ov-file#-building-from-source). Choose the release you want to use (*if unsure, choose the latest*), and click on `Assets` dropdown:

<figure><img src="/files/xoDY2uGFOuZdjJ2tdBPg" alt=""><figcaption><p>Note: The version numbers may be different</p></figcaption></figure>

The package you will need to download depends on your OS and architecture:

* **Windows (Intel/AMD CPU):** heminetwork\_v1.0.0\_windows\_amd64.zip
* **Mac (Intel CPU):** heminetwork\_v1.0.0\_darwin\_amd64.tar.gz
* **Mac (Apple Silicon "M" CPU):** heminetwork\_v1.0.0\_darwin\_arm64.tar.gz
* **Linux (Intel/AMD CPU):** heminetwork\_v1.0.0\_linux\_amd64.tar.gz
* **Linux (ARM CPU):** heminetwork\_v1.0.0\_linux\_arm64.tar.gz

***

### 2. Extract the files

After downloading the necessary files, you must extract them from their compressed format before you can use or access the software. On most operating systems, you can right-click on the downloaded archive and choose "Extract" or similar.

{% hint style="info" %}
**Linux/macOS tip**:

You can also use the command `tar xvf heminetwork_v1.0.0_linux_amd64.tar.gz`\
\
Run the `uname -a` command in the Terminal to view all system information, ensuring compatibility with the correct asset on GitHub.\
\
Depending on the output:\
"**x86\_64**" => Choose the "**amd64**" package corresponding to your OS\
"**arm64**" => Choose the "**arm64**" package corresponding to your OS
{% endhint %}

***

### 3. Open your CLI and navigate to the extracted folder

Launch your CLI:

{% hint style="info" %}
**For Windows:**

* Press `⊞ Win` + `R` together to open the "Run Program Or File" Window
* Type "cmd" and press `Enter`

**For macOS:**

* Press `⌘` + `Space` together to open Spotlight Search
* Type "terminal" and press Enter

\
**For Linux:**

* Depends on OS. On Ubuntu (Gnome): `Ctrl` + `Alt` + `T`
* For most other distros, you can press `Super` (Windows Key) and search for Terminal.
  {% endhint %}

Navigate to the folder you extracted by typing `cd` (**don't press `Enter` ye**t) and then drag the path of the extracted folder into your CLI, or type the path in manually and then press `Enter`.

* For example on Linux if you downloaded the package to your Downloads folder and extracted it through the GUI, you might run a command like:\
  \
  `cd '/home/<user>/Downloads/heminetwork_v1.0.0_linux_amd64'`

***

### 4. Confirm folder contents

List the files:

{% hint style="info" %}
**For Windows:**

* `dir` (and press `Enter`) Type "cmd" and press `Enter`

**For macOS:**

* `ls` (and press `Enter`)
  {% endhint %}

Your output should be:

* **Linux & macOS**

  ```none
  bfgd    bssd    extool    hemictl    keygen    popmd    tbcd
  ```
* **For Windows**

  ```none
  bfgd.exe    bssd.exe    extool.exe     hemictl.exe     keygen.exe     popmd.exe     tbcd.exe
  ```

***

### 5. Verify configuration success

To ensure you downloaded the correct binaries and are able to run them, execute the command below:

<table data-card-size="large" data-view="cards"><thead><tr><th></th><th></th><th></th></tr></thead><tbody><tr><td><strong>Linux &#x26; macOS</strong></td><td><p><mark style="color:purple;">⚠️ On Mac you will need to first remove the quarantine by running the following command in your Terminal:</mark></p><p><mark style="color:purple;"><code>xattr -d com.apple.quarantine ./popmd</code></mark><br><br><strong>Run</strong></p><p><code>./popmd --help</code></p></td><td></td></tr><tr><td><strong>Windows</strong></td><td><mark style="color:purple;">⚠️ <strong>Important Note for Windows Users</strong>: To successfully execute this command, you must use the Command Prompt (CMD), not PowerShell (which is the default terminal in environments like Visual Studio Code).</mark></td><td><p><strong>Run</strong></p><p><code>popmd.exe --help</code></p></td></tr></tbody></table>

This will display the help menu for `popmd`, indicating that it's installed and operational.

```none
Hemi Proof-of-Proof Miner v1.0.0+20630a55c (Hemi Labs, popmd, go1.23.7 linux/amd64)
Usage:
	help (this help)
Environment:
	POPM_BFG_REQUEST_TIMEOUT: request timeout for BFG (Bitcoin Finality Governor) (default: 15s)
	POPM_BFG_URL            : url for BFG (Bitcoin Finality Governor) (default: http://localhost:8383/v1/ws/public)
	POPM_BTC_CHAIN_NAME     : the name of the bitcoin chain to connect to (ex. "mainnet", "testnet3") (default: mainnet)
	POPM_BTC_PRIVKEY        : bitcoin private key (required) 
	POPM_LOG_LEVEL          : loglevel for various packages; INFO, DEBUG and TRACE (default: popmd=INFO;popm=INFO)
	POPM_PPROF_ADDRESS      : address and port popm pprof listens on (open <address>/debug/pprof to see available profiles) 
	POPM_PROMETHEUS_ADDRESS : address and port popm prometheus listens on 
	POPM_REMINE_THRESHOLD   : the number of L2 Keystones behind the latest seen that we are willing to remine, this is handy for re-orgs (default: 0)
	POPM_STATIC_FEE         : specify the number of sats/vB the PoP Miner will pay for fees (default: 1)
```

{% hint style="info" %}
**Note:** Starting with v1.0.0, the PoP miner defaults to mainnet. If you want to PoP mine on testnet, you must specify "testnet" in the `POPM_BTC_CHAIN_NAME`.
{% endhint %}

***

### 6a. Generate public key

{% hint style="warning" %}
**If you prefer to PoP mine using a preexisting private key, you may skip step 6a and 6b.** You may import a private key from either an EVM or BTC address. For your BTC wallet (Unisat for example), use the HEX private key and not the WIF private key.
{% endhint %}

{% hint style="info" %}
**Note:** The `net` flag in the **./keygen** command will default to "mainnet". If you are running a PoP miner in testnet, you must also add the flag `-net="testnet"`.
{% endhint %}

<table data-card-size="large" data-view="cards"><thead><tr><th></th><th></th><th></th></tr></thead><tbody><tr><td><strong>Linux &#x26; macOS</strong></td><td><p><mark style="color:purple;">⚠️ On Mac you will need to remove the quarantine by running:</mark></p><p><mark style="color:purple;"><code>xattr -d com.apple.quarantine ./keygen</code></mark></p></td><td><p><strong>Run the following command:</strong></p><pre data-overflow="wrap"><code>./keygen -secp256k1 -json  > ~/popm-address.json
</code></pre></td></tr><tr><td><strong>Windows</strong></td><td><p><mark style="color:purple;">⚠️ <strong>Important Note for Windows Users</strong>: To successfully execute this command, you must use the Command Prompt, not PowerShell (which is the default terminal in environments like Visual Studio Code). Follow these steps to open Command Prompt:</mark></p><ol><li><mark style="color:purple;">Click on the <strong>Start Menu</strong> button or press the <strong>Windows</strong> key on your keyboard.</mark></li><li><mark style="color:purple;">Type <strong><code>cmd</code></strong></mark> <mark style="color:purple;">into the search bar and open it.</mark></li><li>Type the following command and press Enter:</li></ol></td><td><pre><code><strong>keygen.exe -secp256k1 -json 
</strong><strong> > 
</strong><strong>%HOMEDRIVE%%HOMEPATH%\popm-address.json
</strong></code></pre><p><strong>Note:</strong> After running the command, you might not see any immediate feedback in the Command Prompt. This is expected behavior.</p><ol start="4"><li>Open the generated key file</li></ol><p>After generating the key file, you'll want to check its contents. To do this, use the following command in Command Prompt:</p><pre class="language-cmd" data-overflow="wrap"><code class="lang-cmd">%HOMEDRIVE%%HOMEPATH%\popm-address.json
</code></pre><p>This command opens the <code>popm-address.json</code> file in Notepad, allowing you to view or edit the generated key.</p></td></tr></tbody></table>

### 6b. Open the JSON

If you chose to generate a new private key in Step 6a, open your JSON to view your file contents.

{% hint style="info" %}
**On Windows:** See the above instructions for how to open the file in Notepad.

**On Linux/macOS:** Run the following command to print the contents of your key file to the Terminal:\
\
`cat ~/popm-address.json`
{% endhint %}

You should see a result like:

```none
{
  "ethereum_address": "0x12345FabcD298299b8250e16eEb7D6a7B81DfEdC",
  "network": "mainnet",
  "private_key": "123456789abcdef123456789abcdef123456789abcdef123456789abcdef1234",
  "public_key": "04123456789abcdef123456789abcdef123456789abcdef123456789abcdef12345678abcdef123456789abcdef123456789abcdef123456789abcdef1234",
  "pubkey_hash": "m12345678P2xVWwVCWxq7tHJLGcJz2h6XYZ"
}
```

***

### 7. Fund your address

Find your wallet address:

* **New Address:** If you generated a new public key in Step 6a, check the JSON file from Step 6b for your `pubkey_hash`.
* **Existing BTC Address:** If you are importing a private key from an existing BTC address, [change your wallet type](https://docs.unisat.io/unisat-services/unisat-wallet/unisat-wallet-address-type) to P2PKH (Legacy) and locate the pubkey hash.
* **Existing EVM Address:** If you are importing a private key from an existing EVM address, [import your private key into UniSat](/how-to-tutorials/using-hemi/wallet-setup/btc-wallet-setup) and select P2PKH (Legacy) as your wallet type.

{% hint style="danger" %}
**Best Practices for BTC Allocation**

We advise against sending large amounts of Bitcoin to the private key connected to your PoP miner. To run the miner, `~0.002 BTC` is required per day assuming a Bitcoin fee rate of 2-3 sat/vB. As a safety practice, consider sending only enough BTC for a week or a month at a time and refilling periodically.\
\
To determine how much BTC to send to your wallet, review [#bitcoin-fee-vb](#bitcoin-fee-vb "mention").
{% endhint %}

{% hint style="info" %}
**Testnet Mining**

If you want to test out PoP mining on testnet, you can get tBTC from faucets [like this one](https://coinfaucet.eu/en/btc-testnet/).
{% endhint %}

***

### 8. Run the Miner

In your console, execute the following commands while:

1. replacing `<private_key>` with either the value from your JSON file in Step 5 **OR** your preexisting EVM/BTC private key,
2. replacing `<fee_per_vB_integer>` with the fee in sat/vB you want to pay.

{% hint style="info" %}
Read the [**"Bitcoin fee/vB"**](#bitcoin-fee-vb) section below if you need help determining what value to set here.
{% endhint %}

{% hint style="info" %}
**Note:** The following commands connect to a Hemi Labs-owned BFG. This BFG can get busy and requests will often time out due to a high load and serving the large number of connected users. If you'd like to run your own, you can do so by following [the instructions](https://github.com/hemilabs/heminetwork?tab=readme-ov-file#%EF%B8%8F-running-bfgd) then you may connect to that with by changing the `POPM_BFG_URL` value to be your own BFG.\
\
*To run a PoP miner connected to a custom BFG endpoint, provide the additional line of code to the run commands listed below:*\
\
**Linux & macOS:**

`export POPM_BFG_URL=<YOUR_BFG_URL>`\
\
**Windows:**\
`set POPM_BFG_URL=<YOUR_BFG_URL>`
{% endhint %}

**Linux & macOS**

```
export POPM_BTC_PRIVKEY=<private_key>
export POPM_STATIC_FEE=<fee_per_vB_integer>
export POPM_BFG_URL=wss://pop.hemi.network/v1/ws/public
export POPM_BTC_CHAIN_NAME=mainnet
./popmd
```

**Windows**

```
set POPM_BTC_PRIVKEY=<private_key>
set POPM_STATIC_FEE=<fee_per_vB_integer>
set POPM_BFG_URL=wss://pop.hemi.network/v1/ws/public 
set POPM_BTC_CHAIN_NAME=mainnet
popmd.exe
```

***

### 9. Expected Console Output

```none
2025-03-12 14:24:21 INFO popmd popmd.go:123 Hemi Proof-of-Proof Miner v1.0.0+20630a55c (Hemi Labs, popmd, go1.23.7 linux/amd64)
2025-03-12 14:24:21 INFO popmd popmd.go:127 POPM_BFG_REQUEST_TIMEOUT: 15s
2025-03-12 14:24:21 INFO popmd popmd.go:127 POPM_BFG_URL            : wss://pop.hemi.network/v1/ws/public
2025-03-12 14:24:21 INFO popmd popmd.go:127 POPM_BTC_CHAIN_NAME     : mainnet
2025-03-12 14:24:21 INFO popmd popmd.go:127 POPM_BTC_PRIVKEY        : ********
2025-03-12 14:24:21 INFO popmd popmd.go:127 POPM_LOG_LEVEL          : DEBUG
2025-03-12 14:24:21 INFO popmd popmd.go:127 POPM_PPROF_ADDRESS      : 
2025-03-12 14:24:21 INFO popmd popmd.go:127 POPM_PROMETHEUS_ADDRESS : 
2025-03-12 14:24:21 INFO popmd popmd.go:127 POPM_REMINE_THRESHOLD   : 0
2025-03-12 14:24:21 INFO popmd popmd.go:127 POPM_STATIC_FEE         : 5
2025-03-12 14:24:21 INFO popm popm.go:933 Starting PoP miner with BTC address 1Gz6cq1pR777GoVeDBcA7UbpnwTygGdknc (public key 02df4b526c0a81c90308cd88af993022782e167e7b25d69006b4649f8a47d545e1)
2025-03-12 14:24:22 DEBUG popm popm.go:855 Connected to BFG: wss://pop.hemi.network/v1/ws/public
2025-03-12 14:24:34 DEBUG popm popm.go:609 Received new keystone with block height 1326775
2025-03-12 14:24:34 DEBUG popm popm.go:602 Checking keystone received with height 1326800 against last keystone 1326775
2025-03-12 14:24:34 DEBUG popm popm.go:609 Received new keystone with block height 1326800
2025-03-12 14:24:34 DEBUG popm popm.go:602 Checking keystone received with height 1326825 against last keystone 1326800
2025-03-12 14:24:34 DEBUG popm popm.go:609 Received new keystone with block height 1326825
2025-03-12 14:24:34 DEBUG popm popm.go:543 Received keystone for mining with height 1326825...
```

***

### 10. 🎉 Congrats! You are now a Hemi PoP Miner!

{% hint style="info" %}
Let us know how this process was for you via [Discord](https://discord.gg/hemixyz). We are constantly looking for ways to improve our documentation.
{% endhint %}

***

#### **Bitcoin fee/vB**

The Bitcoin transaction (normally represented in satoshis per virtual byte or sats/vB) is a fee paid to the Bitcoin miners to include a transaction in a Bitcoin block. It varies with network congestion, typically rising during periods of high transaction volume and decreasing when there is less activity.

* The PoP Miner consumes BTC to pay the Bitcoin miners to include PoP transactions in Bitcoin blocks.
* In order to ensure PoP transactions from your PoP miner are included in Bitcoin blocks, ensure the configured fee is set to an appropriate value. The PoP miner can be configured to use a certain fee in sats/vB by changing the `POPM_STATIC_FEE` environment variable when running the PoP miner. In a future version, the PoP miner will automatically calculate the current network fee to guarantee PoP transactions are included in Bitcoin blocks.
* The lower you set the fee, the less BTC you will pay per PoP transaction. If your fees are too low, Bitcoin miners may not include your transaction quickly enough for you to successfully PoP mine.

**Bitcoin fee determination:**

* Check Current Fee Levels: Visit [mempool.space](https://mempool.space/testnet) to see the current fee levels. Look at the "sat/vB" numbers for the different transaction fee priorities. It is recommended to set the value to the "High Priority" value or slightly higher.
* Set the Static Fee: Re-run the command to set the `POPM_STATIC_FEE` environment variable from above (`export` on Linux/macOS, `set` on Windows) each time you want to change the fee, and restart the PoP Miner afterwards.


# (Testnet) Add tHEMI to MetaMask

{% hint style="info" %}
📜 **TL;DR:**

* **tHEMI** is the governance token for the Hemi Network's testnet phase.
* tHEMI tokens are used for **payouts to PoP miners** as a means of acknowledging their contribution to the network's security and functionality. In the future, these incentives will expand to individuals running Sequencers, Publishers, and Challengers.
* View your tHEMI balance and transactions directly in MetaMask.
* The tHEMI token contract address is `0x4200000000000000000000000000000000000042.`
  {% endhint %}

***

## 🌐Overview

tHEMI is the testnet governance token for the Hemi Network. Initially, tHEMI tokens are used for payouts to PoP miners to acknowledge their contribution to the network's security and functionality.

Looking ahead, **tHEMI will play a broader role in rewarding other network participants**, including Sequencers, Publishers, and Challengers, who contribute to the network's resilience and growth. tHEMI is set to become the preferred gas token on the network, offering fee discounts and enhancing user transaction efficiency.

***

## 📚 Tutorial

## Video

{% embed url="<https://vimeo.com/1030116566?share=copy>" %}

### 1. Open MetaMask

![](/files/Fatbdj3i2aMeaaXbN4pB)

***

### 2. Access Token Selection

* Navigate to `Tokens`
* `Import Tokens`

<img src="/files/L4QZ0oOanRrpJAS86MCR" alt="" width="357">

***

### 3. **Enter the Contract Address**

* Type in the tHEMI token contract address `0x4200000000000000000000000000000000000042` into the `Token Contract Address` field.

<figure><img src="/files/2aAFyp4vImTxWjhpwaVH" alt="" width="352"><figcaption></figcaption></figure>

* If the address is recognized, MetaMask will automatically populate the `Token Symbol` and `Decimals of Precision` fields.

***

### 4. Import

* Confirm the accuracy of the provided information, click on `Add Custom Token`, and then select `Import Tokens`.

Your tHEMI tokens should now be visible in your MetaMask wallet. You can view your balance and conduct transactions directly within the wallet interface.


# (Mainnet) Add PoPPoints to Metamask

{% hint style="info" %}
📜 **TL;DR:**

* **Prior to TGE, PoP miners on mainnet will receive PoPPoints tokens.**
* These points are entirely  separate from the Incentivized Testnet / Mainnet seasons.
* View your tHEMI balance and transactions directly in MetaMask.
* The tHEMI token contract address is `0xC5D2E164601c59c2cD760669e849BFe498003e21`.
  {% endhint %}

***

## 🌐Overview

Prior to TGE, users who engage in securing Hemi (mainnet) to Bitcoin will receive PoPPoints tokens, which are distributed based on how many other users are actively PoP Mining.\
\
These PoPPoints tokens are initially non-transferrable. During the initial mainnet release, all miners who get a PoP publication for a keystone into Bitcoin within \~1.6 hours will share 100 PoPPoints for that keystone round.

As mainnet evolves, this payout algorithm will be adjusted.

***

## 📚 Tutorial

## Video

{% embed url="<https://vimeo.com/1030116566?share=copy>" %}

### 1. Open MetaMask

![](/files/Fatbdj3i2aMeaaXbN4pB)

***

### 2. Access Token Selection

* Navigate to `Tokens`&#x20;
* Click on the three vertical dots on the right of the token menu
* `Import tokens`

![](/files/zxxS789gNIcyxJlWkXMC)

***

### 3. **Enter the Contract Address**

* Type in the tHEMI token contract address `0xC5D2E164601c59c2cD760669e849BFe498003e21` into the `Token Contract Address` field.

<figure><img src="/files/7GWourPlDd287oziS5Y0" alt=""><figcaption></figcaption></figure>

* If the address is recognized, MetaMask will automatically populate the `Token Symbol` and `Token Decimal` fields. For PoPPoints, you should see a symbol `POP`and 18 decimals.

### 4. Import

* Confirm the accuracy of the provided information, and then click on `Next`.
* If successful, you should see your PoPPoints tokens in your wallet's token list:

<figure><img src="/files/SLHl0Q5rTHOCFlU6gB3L" alt=""><figcaption></figcaption></figure>

For now, these tokens are non-transferrable.


# Web PoP Miner (deprecated)

{% hint style="warning" %}
**Support for the Web PoP Miner has since been deprecated.** \
\
To learn more about how we implemented the application, feel free to view our codebase here: <https://github.com/hemilabs/web-pop-miner>\
\
Follow our [CLI PoP Miner guide](/how-to-tutorials/using-hemi/pop-mining/setup-part-1) to run a PoP Miner.
{% endhint %}

***

## 🌐 Overview

* The web PoP miner was designed for ease of use, allowing users of any experience level to test and run their own PoP miner.&#x20;
* Due to its lightweight nature, it required no specific hardware, making it accessible from any standard computer.&#x20;
* While it was not intended for long-term mining operations, it served as an excellent entry point for users interested in transitioning to the more durable CLI version, providing an introduction to Hemi's architecture and its unique integration with the Bitcoin network.

***

## 🔐 Security Note

{% hint style="warning" %}

* The web miner uses the same secure code as the CLI miner. However, it also relies on your web browser, which introduces additional security risks.&#x20;
* When transitioning to the CLI PoP Miner, **it is recommended to generate a new public key.** Private key information obtained via the web PoP Miner, although encrypted, is not fully secure and is not meant for extended mining operations.&#x20;
  {% endhint %}


# Developing on Hemi

Follow along with some of the tutorials to help you get a head start when building your first Hemi project.&#x20;

{% hint style="info" %}
**Note:** You may be eligible to earn Hemi [points](https://points.absinthe.network/hemi/start) by completing tutorials. Visit our [dashboard](https://points.absinthe.network/hemi/start) for more information on active quests.
{% endhint %}

***

### General

<table><thead><tr><th width="194">Tutorial</th><th width="397">Description</th><th>Difficulty</th></tr></thead><tbody><tr><td><a href="/pages/tRpj0QAzEBgAYvWki6bp">HelloWorld.sol</a></td><td>Learn how to develop and deploy a HelloWorld smart contract on Hemi using <a href="https://remix.ethereum.org/">Remix IDE</a>.</td><td>🟢 Easy</td></tr><tr><td><a href="/pages/TVRPYVeWsJA1usrcW8It">Deploy an ERC-20</a></td><td>Learn how to deploy an ERC-20 token on Hemi using <a href="https://hardhat.org/">Hardhat</a>.</td><td>🟢 Easy</td></tr><tr><td><a href="/pages/eTzP1rUyB4QtIgCEZzl9">Verify a Smart Contract</a></td><td>Verify a smart contract on Hemi using Hardhat, Foundry, or the Blockscout Explorer UI.</td><td>🟢 Easy</td></tr></tbody></table>

***

### hVM & hBK

<table><thead><tr><th width="194">Tutorial</th><th width="397">Description</th><th>Difficulty</th></tr></thead><tbody><tr><td><a href="/pages/r5Pa0qMAi0jYLNTzOqec">Use the hBK Demo App</a></td><td>Learn about the <a href="/pages/gLocHsdR1BL4lYVbR0eX">Hemi Bitcoin Kit</a> and interact with our precompiles.</td><td>🟢 Easy</td></tr><tr><td><a href="/pages/TsLbfp2WmO8RVauWRRY3">Get Bitcoin Balance with Remix</a></td><td>Deploy a small contract in<a href="https://remix.ethereum.org"> Remix IDE</a> with a single method which calls the Bitcoin Balance precompile and returns the balance.</td><td>🟢 Easy</td></tr></tbody></table>


# General


# HelloWorld.sol

🟩 This is a beginner track.

{% hint style="info" %}

#### 📜 **TL;DR:**

* In this tutorial, we will utilize [Remix IDE](https://remix.ethereum.org/), a versatile, open-source web-based platform, to develop and deploy our smart contract onto Hemi testnet.
* This guide is tested to work with Solidity version **0.8.26.** If you experience any issues, try setting this version explicitly in the Solidity Compiler tab on Remix.
* Earn and track Hemi [points](https://points.absinthe.network/hemi/start) for completing this tutorial!
  {% endhint %}

***

## 🏁 Prerequisites

1. [MetaMask Wallet Setup](/how-to-tutorials/using-hemi/wallet-setup/metamask-wallet-setup)
2. [Tunnel ETH to Hemi](/how-to-tutorials/using-hemi/tunnel-from-ethereum/tunnel-eth-to-hemi)

***

## 📚 Tutorial

### 1. Go to [Remix IDE](https://remix.ethereum.org/)

Remix IDE is a powerful, open-source web application for developing, compiling, and deploying Ethereum smart contracts with ease.

***

### 2. **Add the Smart Contract**

In Remix IDE, start by creating a new file named `HelloWorld.sol`.

![](/files/J6Lfu4zNXvaw6pZQA95c)

* The following contract is a basic example designed for interaction. Copy the code below and paste it into the file `HelloWorld.sol`.

```solidity
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

contract HelloWorld {
    string public greeting = "Hello, World!";

    function getGreeting() public view returns (string memory) {
        return greeting;
    }

    function setGreeting(string memory _greeting) public {
        greeting = _greeting;
    }
}
```

***

### **3. Compile the Contract**

Select `Compile HelloWorld.sol` button to use the Remix IDE's Solidity compiler. Check for any compilation errors and fix them.

![](/files/EYFmiekjq2BszPeoh4JL)

***

### 4. Connect Remix To MetaMask

{% hint style="warning" %}
The address you choose to connect **MUST** have some ETH (recommended at least 0.01 ETH) to pay for contract deployment fees. Refer back to earlier documentation to [fund your Hemi address](/how-to-tutorials/using-hemi/tunnel-from-ethereum/tunnel-eth-to-hemi) with ETH.
{% endhint %}

Choose `Injected Provider - MetaMask` under "Environment".

![](/files/w6g5hKa1uieSkGY9jzRc)

***

### 5. Confirm the Connection

* A pop-up from MetaMask will appear to confirm the connection. Select `Next`.

![](/files/umbIYTYKmyb5kzeKi9sv)

* Select `Connect`

![](/files/NoLQlZys2YRVYKvDjpUy)

***

### 6. Link to Hemi Account

* Link to the relevant Hemi account in the "Account" drop-down.

![](/files/zFIPG6v3NugkpJ28sD2W)

***

### 7. Deploy

Execute the deployment of your smart contract to the Hemi network directly from Remix IDE.

{% hint style="warning" %}
Uncheck `Publish to IPFS.`Note: if you get a warning about Gas Limit, you may ignore it and proceed.
{% endhint %}

* Select `Deploy`

![](/files/1Xri5KWpQJo5X4gz35Hy)

* Your MetaMask will pop-up to confirm the deployment of your smart contract. Select `Confirm`

![](/files/TCAPYfRS715pOPrsLByy)

🥳 Wohoooo! If successful you should see a ✅ in the console.

⚠️ If it fails, double check that the Solidity version in the compiler is the correct version.

![](/files/DJBN0DSt6KWMze1PDnWu)


# Deploy an ERC-20 Token

{% hint style="info" %}

## 📜 **TL;DR:**

* This tutorial guides you through deploying an ERC-20 token using [Hardhat](https://hardhat.org/), a comprehensive Ethereum development environment. Hardhat is recommended for its powerful features, but you can also use other Ethereum development tools like [Foundry](https://book.getfoundry.sh/).
* Ensure Node.js, Hardhat, and Solidity are set up correctly for effective ERC-20 token development and deployment.
* Earn and track Hemi [points](https://points.absinthe.network/hemi/start) for completing this tutorial!
  {% endhint %}

***

## 🏁 Prerequisites

1. Download [VSCode ](https://code.visualstudio.com/download)(or any other IDE)
2. Install [Node.js](https://nodejs.org/en/download/) or update it to [current version](https://blog.hubspot.com/website/update-node-js)
3. [MetaMask Wallet Setup](/how-to-tutorials/using-hemi/wallet-setup/metamask-wallet-setup)
4. [Tunnel ETH to Hemi](/how-to-tutorials/using-hemi/tunnel-from-ethereum/tunnel-eth-to-hemi)

***

## 📚 Tutorial

## Video

{% embed url="<https://vimeo.com/1027100635?share=copy>" %}

### 1. Create A Project Directory

* Create a folder on your computer and name it `TestToken`.
* This folder will serve as your project directory, containing all the elements and code needed to deploy your ERC-20 token.

***

### 2. Initialize Your NPM Project

* In your `TestToken` project directory, open a terminal window and initialize a Node.js project

```shell
npm init -y
```

***

### 3. Install Hardhat & Ethers.js Plugin

* Install Hardhat along with the Ether.js plugin, and the OpenZeppelin contracts library.

```shell
npm install --save-dev hardhat @nomiclabs/hardhat-ethers ethers @openzeppelin/contracts
```

***

### 4. Create a HardHat Project

a) Inside your Node.js project, start a Hardhat project

```shell
npx hardhat init
```

b) Select `Create an empty hardhat.config.js`

<img src="/files/JOjuquBkUAbvXX3ZtNgn" alt="" width="563">

***

### 5. Add Folder

In the root directory of your project, create `contracts` and `scripts` folders:

```shell
mkdir contracts && mkdir scripts
```

***

### 6. Write Your Contract

<img src="/files/e9NsKOmdKefawnl9k1ma" alt="" width="358">

* In the `contracts` folder, create a file named `MyToken.sol` . This will be your ERC-20 token contract. Here's a basic example:

```solidity
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";

contract MyToken is ERC20 {
    constructor(uint256 initialSupply) ERC20("MyToken", "MTK") {
        _mint(msg.sender, initialSupply);
    }
}
```

* This code defines a simple ERC-20 token with an initial supply and basic ERC-20 functionalities.

***

### 7. Compile Your Contract

```shell
npx hardhat compile 
```

***

### 8. Secure Your Private Key for Deployment

{% hint style="danger" %}
Your private key provides access to your wallet and your funds. **Never share your private key with anyone.** Ensure this file is never shared or committed to version control.
{% endhint %}

a) Export your private key from MetaMask:

* Open MetaMask, select your account icon, and go to `Account Details`

<img src="/files/zlzS7aERLhhQH2IMpY7M" alt="" width="353">

* Select `Show private key`
* Enter your password.
* Select `Confirm`
* Select the unlock button to reveal your password.

b) Install `dotenv` package

```shell
npm install dotenv
```

c) Run the command `touch .env` to create an `.env` file in the root directory of your project.&#x20;

```
touch .env
```

d) Run the command `nano .env` to open the CLI editor&#x20;

```none
nano .env
```

e) Add your private key to the `.env` file.

```none
PRIVATE_KEY=your_exported_private_key
```

***

### 9. Configure Hardhat for the Testnet

a) Open `hardhat.config.js` in your project.

b) Configure Hemi Network

* Add the required modules at the top of the config file
* Add the Hemi Network settings in`module.exports`. Ensure you include the network's URL, Chain ID, and the accounts array with your private key (stored in an environment variable for security).

Here's an example configuration:

```javascript
/** @type import('hardhat/config').HardhatUserConfig */
require('dotenv').config()
require("@nomiclabs/hardhat-ethers");

module.exports = {
  solidity: "0.8.20",
  networks: {
    hemi: {
      url: "https://rpc.hemi.network/rpc",
      chainId: 43111,
      accounts: [`0x${process.env.PRIVATE_KEY}`],
    },
  }
};
```

***

### 10. Write a Deployment Script

<img src="/files/PKF2ECc2lY7nSCazwqSn" alt="" width="358">

In the `scripts` folder, create a file named `deploy.js` to write a script for deploying your contract.

```javascript
const { ethers } = require("hardhat");

async function main() {
    const [deployer] = await ethers.getSigners();
    const initialSupply = ethers.utils.parseUnits("1000", "ether");

    const Token = await ethers.getContractFactory("MyToken");
    const token = await Token.deploy(initialSupply);

    console.log("Token deployed to:", token.address);
}

main().catch((error) => {
    console.error(error);
    process.exit(1);
});
```

This script is deploying `MyToken` with an initial supply (customize the supply as needed).

***

### 11. Deploy the Contract

```shell
npx hardhat run scripts/deploy.js --network hemi
```

{% hint style="info" %}
If the deployment is successful, you will see messages indicating the token was deployed to

`Token deployed to: 0x5fc5c2265E4f77E63e82f7F10FE803d04Cc53D82`
{% endhint %}

To view the details of your deployed contract, enter the contract address from your success message into the [Hemi Testnet explorer](https://testnet.explorer.hemi.xyz). This will provide you with information about the contract's transactions and state.

Contract details we just deployed:

![](/files/EukBLuKjExqQKvfryoKd)


# hVM & hBK


# Using the hBK Demo App

{% hint style="info" %}

## 📜 **TL;DR:**

* The [Hemi Bitcoin Kit (hBK) Demo App](https://bitcoin-kit.hemi.xyz/code-editor) enables seamless interaction with Bitcoin data in an Ethereum-compatible environment.
* Key features include:
  * Query [Bitcoin address balances](#id-1.-get-address-balance).
  * Retrieve the [latest block header](#id-2.-get-latest-block-header) or specific [block headers by height](#id-3.-get-block-header-by-height).
  * Fetch [Bitcoin transaction details](#id-4.-get-transaction-details) and [confirmation counts.](#id-5.-get-transaction-confirmations)
  * [List UTXOs](#id-6.-list-address-utxos) (Unspent Transaction Outputs) for a Bitcoin address.
* Developers can easily integrate Bitcoin data into dApps without external services, simplifying Bitcoin-aware application development.
  {% endhint %}

***

## 🌐 Overview

* The [Hemi Bitcoin Kit (hBK) Demo App](https://bitcoin-kit.hemi.xyz/code-editor) is a tool designed for developers to interact with Bitcoin blockchain data directly from an Ethereum-compatible environment.&#x20;
* 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.&#x20;
* 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.

<figure><img src="/files/2i0YQ9eXoEoPfmr2582w" alt=""><figcaption></figcaption></figure>

```
// Sample output
514853116
```

**Verifying our Output**

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

<figure><img src="/files/Zn9PY67UtoZTGPcrk0l3" alt=""><figcaption></figcaption></figure>

***

## 2. Get Latest Block Header

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

<figure><img src="/files/5DzKlBf4IGHJnQt9FtiI" alt=""><figcaption></figcaption></figure>

```
// 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.

<figure><img src="/files/P8Q295uQgQpoIzAKBaaz" alt=""><figcaption></figcaption></figure>

***

## 3. Get Block Header by Height

Fetches the block header for a specific block height.

<figure><img src="/files/7JnXnN1GzQQqnN90ObDk" alt=""><figcaption></figcaption></figure>

```
// 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.

<figure><img src="/files/XkKEoqkaLkohoDIedgQk" alt=""><figcaption></figcaption></figure>

***

## 4. Get Transaction Details

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

<figure><img src="/files/MhdVkFnrS0jRYobyqiyc" alt=""><figcaption></figcaption></figure>

```
// 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.

<figure><img src="/files/PI0r4Y6cmjV6tbhe1fJz" alt=""><figcaption></figcaption></figure>

```
// 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.

<figure><img src="/files/JqaQwusE8HCQoK4eZB27" alt=""><figcaption></figcaption></figure>

```
// 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.


# Get Bitcoin Balance with Remix

{% hint style="info" %}

## 📜 **TL;DR:**

* In this section, we’ll deploy a small contract in[ Remix IDE](https://remix.ethereum.org) with a single method which calls the Bitcoin Balance precompile and returns the balance as a uint256.&#x20;
* We recommend you use Solidity version **0.8.25 or later**, but previous versions are also expected to work.
  {% endhint %}

***

## 🏁 Prerequisites

To follow along, you’ll need:

* **Metamask** (or another Remix-supported web wallet) connected to Hemi testnet as a custom network;
* **A nonzero ETH balance** tunneled over to a Hemi address in your wallet you want to deploy the demo contract with to pay deployment gas fees.

***

## 📚 Tutorial

### 1. Create Contract

* To start, open Remix, delete any existing contracts in the “contracts” folder,.
* Create a new contract file, which for our example we’ll call “BitcoinBalDemo.sol”.
* Paste in the following code:

```solidity
pragma solidity ^0.8.25;

contract BitcoinBalDemo {
    function getBitcoinAddressBalance(string calldata btcAddress) public view returns (uint256 balance) {
    bytes memory converted = bytes(btcAddress);
    (bool ok, bytes memory out) = address(0x40).staticcall(converted);
    require(ok, "Failed to Call Bitcoin Balance hVM Precompile (0x40)");
    
    return uint64(bytes8(out));
  }
}
```

\
You can now compile and deploy this contract, and try out calling it with a Bitcoin address string to see the address's balance (in satoshis) returned by hVM.


# Introduction

{% hint style="info" %}

### 📜 **TL;DR:**

* The **Hemi Virtual Machine (hVM)** and **Hemi Bitcoin Kit (hBK)** power Hemi’s Bitcoin interoperability.
* **hVM** is an indexed Bitcoin full node directly accessible inside the EVM.
* **hBK** is a smart contract library running on Hemi that utilizes hVM and makes Hemi’s Bitcoin awareness easier to use.
* hVM’s precompile calls and hBK's functions are subject to change in future versions of the Hemi testnet.
* **Latest hBK release on Hemi:** [0x7007dd1C09527B92AEcd8Ae6570B73d09E0B8F12](https://explorer.hemi.xyz/address/0x7007dd1C09527B92AEcd8Ae6570B73d09E0B8F12)
* **Latest hBK release on Hemi testnet:** [0xeC9fa5daC1118963933e1A675a4EEA0009b7f215](https://testnet.explorer.hemi.xyz/address/0xeC9fa5daC1118963933e1A675a4EEA0009b7f215)
  {% endhint %}

***

## 🌐 Overview

* The **Hemi Virtual Machine (hVM)** and **Hemi Bitcoin Kit (hBK)** power Hemi’s Bitcoin Interoperability, empowering dApp developers to build novel Bitcoin dApps and robust interoperability infrastructure in a trustless, secure, and gas-efficient manner.
  * **hVM:** An indexed Bitcoin full node directly accessible inside the EVM, exposing data including transactions, address balances, UTXOs, and chain metadata to smart contracts on Hemi via custom precompiles.
  * **hBK:** A smart contract library running on Hemi that utilizes hVM and makes Hemi’s Bitcoin awareness easier to use by exposing higher-level functions that perform the precompile calls and handle the data marshaling, returning simple data structures developers can use in their dApps.

***

{% hint style="warning" %}

#### 👷‍♂️ In Development:

* hVM and Bitcoin Kit are in development and experimental.
* hVM’s precompile calls and Bitcoin Kit’s functions are subject to change in future versions of the Hemi Testnet.
* Prior to mainnet launch, the protocols will ossify and future upgrades will only add new hVM precompiles and Bitcoin Kit functions, ensuring full backwards compatibility.
  {% endhint %}

***

### 📋 Latest Version

* Because new versions of hBK are being developed and tested, this document will always contain the latest “stable” contract available on Hemi’s testnet.
* In Mainnet, Bitcoin Kit contracts will be deployed as predeploys with special addresses like 0x8400000000000000000000000000000000000001, with new versions offering additional features being deployed at incremented addresses.

> **Latest Bitcoin Kit release on Hemi Testnet:**
>
> [0xeC9fa5daC1118963933e1A675a4EEA0009b7f215](https://testnet.explorer.hemi.xyz/address/0xeC9fa5daC1118963933e1A675a4EEA0009b7f215) (Updated October 11th, 2024)


# Hemi Virtual Machine (hVM)

{% hint style="warning" %}
This documentation page is outdated and may not reflect current information.
{% endhint %}

{% hint style="info" %}

## 📜 **TL;DR:**

* Hemi’s hVM is an **EVM upgraded with Bitcoin awareness.**
* The Hemi network maintains an EVM-visible Bitcoin node using Hemi’s custom **“Tiny Bitcoin” (TBC)** daemon.&#x20;
* A **“Processed Bitcoin View”** synchronizes all Hemi nodes as part of the EVM state transition.
  {% endhint %}

***

## 🌐 Overview

* Hemi’s hVM is an **EVM upgraded with Bitcoin awareness** via new precompile contracts that smart contracts can call to get data from the Bitcoin node embedded in the EVM.

***

## 🔍 Tiny Bitcoin Daemon (TBC)

* The Hemi network maintains an EVM-visible Bitcoin node using Hemi’s custom **“Tiny Bitcoin” (TBC)** daemon. TBC syncs with the regular Bitcoin network over P2P and **indexes Bitcoin blocks** up to the height specified by the protocol.&#x20;
* When a Hemi Sequencer creates a block, they can optionally include an additional “Bitcoin Attributes Deposited” transaction communicating one or more new Bitcoin headers to the Hemi protocol.&#x20;

***

## 🎚️ Processed Bitcoin View

* When these transactions occur, all nodes on the Hemi network process these Bitcoin blocks at the same Hemi block height creating a **“Processed Bitcoin View”** synchronized across all Hemi nodes as part of the EVM state transition.&#x20;
* This synchronization ensures execution of all Bitcoin-aware smart contracts are **deterministic** across all nodes.

***

> To expose Bitcoin data to smart contracts, hVM introduces a number of new precompile contracts accessible in the EVM which fetch the latest data from the Processed Bitcoin View maintained by the embedded TBC node at the time the request is made.

***

<figure><img src="/files/Kxj2O29G8tGgUCLJsA9r" alt=""><figcaption></figcaption></figure>


# Motivation

{% hint style="warning" %}
This documentation page is outdated and may not reflect current information.
{% endhint %}

{% hint style="info" %}

## 📜 **TL;DR:**

* Current Bitcoin interoperability systems like BTC header relays exist, but come with significant limitations.
* By embedding a full indexed Bitcoin node directly inside the EVM, hVM allows **anyone** to access Bitcoin's processed state efficiently and without introducing any trust assumptions.
* dApp developers can now build all kinds of Bitcoin-aware dApps and custom Bitcoin interoperability infrastructure directly on hVM.
  {% endhint %}

***

## 🚧 Limitations of Existing Approaches

Various Bitcoin header relay systems have been available on Ethereum as a primitive Bitcoin interoperability technology for nearly a decade. This approach has third-party relayers communicate new Bitcoin headers to a smart contract which maintains a lightweight view of Bitcoin consensus. Smart contracts can then verify a Merkle proof to verify that a specific Bitcoin transaction exists in the canonical Bitcoin chain.

However, this approach has significant limitations:

* Relies on third-party relayers
* Requires large inclusion proofs with expensive validation
* Can only prove a transaction exists in Bitcoin (no UTXO set proofs, no balance proofs, etc.)

Recently, other protocols have designed alternate Bitcoin interoperability primitives like 3-way noncustodial escrow systems validated with zk proofs, or smart-contract-controlled wallets run by the network validator set where network Sequencers facilitate UTXO queries.

However, these other approaches are only designed to serve specific use cases, and still don't provide smart contracts with a complete view of Bitcoin's state. Developers building on these primitives are also forced to accept the governance/security models that these one-off primitives provide, such as trusting a Sequencer doesn't withhold data from a UTXO query.

***

> 💡 With hVM, we set out to create something much more powerful and flexible that enabled anyone to build custom Bitcoin interoperability infrastructure directly in the EVM with complete access to Bitcoin state.

***

## 🔍 How?

By embedding a full indexed Bitcoin node directly inside the EVM, hVM:

* Does not involve any relayer system or trust assumption
* Does not require validation of any expensive proofs
* Supports secure queries for Bitcoin information that requires processing the entire chain like UTXOs, balances, and eventually popular Bitcoin metaprotocols

***

## 🏗️ Use Cases

hVM enables dApp developers to build all kinds of Bitcoin-aware dApps and custom Bitcoin interoperability infrastructure which was previously infeasible or outright impossible on other networks.

**Some use cases of hVM include:**

* Non-custodial BTC<->ETH asset exchanges
* Bitcoin MEV marketplaces
* Bitcoin lending markets
* Bitcoin staking systems
* Custom smart-wallets with configurable validator sets and signing technology
* Custom Bitcoin tunnels (Hemi’s own standard Bitcoin tunnel is being built entirely on hVM)


# Feature Summary

{% hint style="warning" %}
This documentation page is outdated and may not reflect current information.
{% endhint %}

{% hint style="info" %}

## 📜 **TL;DR:**

* Smart contracts on Hemi can access Bitcoin data by calling the hVM precompile contract.
* Future protocol upgrades will add additional precompile calls to provide additional information.
  {% endhint %}

***

## 🌐 Overview

* Smart contracts on Hemi can access Bitcoin data by calling the hVM precompile contract addresses, which query the deterministic TBC node running inside the EVM.&#x20;
* Future protocol upgrades will add additional precompile calls to provide additional information like Bitcoin fee levels, Bitcoin block construction information, and popular metaprotocols like Ordinals, BRC-20s, and Runes.

***

## ℹ️ "Phase 0" Precompile Summary <a href="#hvm-precompile-addresses" id="hvm-precompile-addresses"></a>

<table><thead><tr><th>Name</th><th width="125">Address</th><th>Description</th></tr></thead><tbody><tr><td>BtcBalAddr</td><td>0x40</td><td>Gets the balance of an address in satoshis. Supports all address formats: P2PKH, P2SH, P2WPKH, P2WSH, P2TR.</td></tr><tr><td>BtcUtxosAddrList</td><td>0x41</td><td>Gets the list of Unspent Transaction Outputs (UTXOs) for an address. Supports pagination.</td></tr><tr><td>BtcTxByTxid</td><td>0x42</td><td>Gets parts of a Bitcoin transaction by its TxID. The caller can specify which part(s) of the transaction to return using packed bitflags to increase gas efficiency by dropping unnecessary data.</td></tr><tr><td>BtxTxConfirmations</td><td>0x43</td><td>Gets the number of confirmations a specified transaction by TxID has.</td></tr><tr><td>BtcLastHeader</td><td>0x44</td><td>Gets the most recent Bitcoin header known by hVM.</td></tr><tr><td>BtcHeaderN</td><td>0x45</td><td>Gets the canonical Bitcoin header at height N.</td></tr><tr><td>BtcAddrToScript</td><td>0x46</td><td>Converts a Bitcoin address to its corresponding script representation. Supports all address formats: P2PKH, P2SH, P2WPKH, P2WSH, P2TR.</td></tr></tbody></table>


# Deploy on hVM

{% hint style="warning" %}
This documentation page is outdated and may not reflect current information.
{% endhint %}

{% hint style="info" %}

## 📜 **TL;DR:**

* To use hVM directly, you will have to call the appropriate precompile address with the appropriate serialized bytes to pass parameters to the function.&#x20;
* Most dApp developers will use the Hemi Bitcoin Kit (hBK) **rather** than hVM directly.&#x20;
  {% endhint %}

***

## 🌐 Overview

* To use hVM directly, you will have to call the appropriate precompile address with the appropriate serialized bytes to pass parameters to the function.&#x20;
* Each successful precompile call will return serialized bytes according to the precompile’s return data specification.

***

## 🟨 Developer Tip

> **Most dApp developers will use the Hemi Bitcoin Kit (hBK) rather than hVM directly.**&#x20;

* If you’re looking for an easy way to get started developing Bitcoin-aware dApps on Hemi, check out the “Hemi Bitcoin Kit (hBK)” section. Understanding how Bitcoin Kit uses hVM under-the-hood may be helpful, and dApp developers looking to maximize gas efficiency may benefit from using hVM directly to avoid paying overhead for unmarshalling data they don’t need for a specific use case.

###


# Hemi Bitcoin Kit (hBK)

{% hint style="warning" %}
This documentation page is outdated and may not reflect current information.
{% endhint %}

{% hint style="info" %}

#### 📜 **TL;DR:**

* The Hemi Bitcoin Kit (hBK) is a library of smart contracts for developers to use to build Bitcoin-aware smart contracts.
* The hBK abstracts away the complications of interacting directly with the hVM Precompiles; parsing query results into data structures that are easy to understand and use.
* **Latest hBK release on Hemi:** [0x7007dd1C09527B92AEcd8Ae6570B73d09E0B8F12](https://explorer.hemi.xyz/address/0x7007dd1C09527B92AEcd8Ae6570B73d09E0B8F12)
* **Latest hBK release on Hemi testnet:** [0xeC9fa5daC1118963933e1A675a4EEA0009b7f215](https://testnet.explorer.hemi.xyz/address/0xeC9fa5daC1118963933e1A675a4EEA0009b7f215)
* **Bitcoin Kit Demo/Editor app :** <https://bitcoin-kit.hemi.xyz/code-editor>
  {% endhint %}

***

## 🌐 Overview

* The Hemi Bitcoin Kit (hBK) is a set of smart contracts designed to bridge the Ethereum and Bitcoin blockchains, enabling developers to build Bitcoin-aware dApps on an EVM with full access to Ethereum assets and the cross-chain data calls that ETH L2s provide.
* The hBK abstracts away the complexities of dealing directly with hVM's low-level precompile contracts.

***

## 🧑‍💻 How is hBK Unique?

* The hVM is based on the Ethereum Virtual Machine (EVM) and comes stocked with built-in precompiles to interact with the embedded Bitcoin full node.
* Unlike other Bitcoin interoperability solutions, Bitcoin-aware smart contracts built using hBK don't rely on any external relayers, require gas-intensive proof validation, or suffer from limited views of Bitcoin's state.
* Performing a query for Bitcoin data is just as easy as reading the state of other contracts in the EVM. No need to design complex smart contracts that register requests to handle after the requested data is relayed.
* Pre-validated data directly available in the EVM significantly reduces both the complexity and cost of developing and maintaining Bitcoin-related applications

{% hint style="success" %}
The Hemi Bitcoin Kit brings five benefits to developers:

* **Easier development:** Access to a wide range of Bitcoin data is just one smart contract call away.
* **Rich data:** Access Bitcoin state like UTXOs and balances that is impractical or outright impossible to get with other solutions.
* **Security and reliability:** dApps get immediate information about any relevant events on the Bitcoin blockchain without having to rely on third-party relayers or trusted oracles.
* **Composability:** Anyone can design new layers of Bitcoin DeFi infrastructure for others on which to build.
* **Cost-effectiveness:** The hVM uses far less gas than other approaches and there's no need to incentivize third-party bots to watch for and relay events.
  {% endhint %}

***

## 🏗️ Use Cases

Some examples of unique applications that the Hemi Bitcoin Kit enables:

* **Custom Bitcoin tunnels:** Connect chains to the Bitcoin network using customized security, cost, and speed settings.
* **Trustless BTC staking and re-staking protocols:** 99% of BTC is unbridged and/or unproductive. With Hemi, BTC can be used to secure networks and earn yield.
* **Bitcoin-authenticated AI-model marketplaces:** As an example of an AI use case, model owners can publish Bitcoin-secure hashes of their model weights, timestamping them to the Bitcoin blockchain.
* **Multichain DAOs:** Hemi DAOs operate across both Bitcoin and Ethereum, making decisions based on the collective input of stakeholders from both communities.

***

## 🛠️ Bitcoin Kit Demo

The [Hemi Bitcoin Kit Demo](https://bitcoin-kit.hemi.xyz/code-editor) provides developers with an interactive code editor and execution environment featuring six essential Bitcoin blockchain functions. Users can do the following:&#x20;

* Retrieve address balances,
* Access the latest block headers,&#x20;
* Query block headers by specific height,&#x20;
* Get detailed transaction information,&#x20;
* Check transaction confirmations,&#x20;
* List unspent transaction outputs (UTXOs) for any address.&#x20;

Each function comes with pre-written, well-documented code that demonstrates how to interact with Bitcoin's blockchain through smart contract calls, making it easy for developers to understand and implement Bitcoin functionality in their own applications. The demo serves as both a learning tool and a practical reference for app development, allowing users to execute real Bitcoin queries and see immediate results without needing to set up their own development environment.


# Overview

{% hint style="warning" %}
This documentation page is outdated and may not reflect current information.
{% endhint %}

{% hint style="info" %}

### 📜 **TL;DR:**

* The Hemi Bitcoin Kit (hBK) enables direct interaction with Bitcoin blockchain data within Ethereum’s environment.
* hBK utilizes Hemi Virtual Machine (hVM) to embed a fully indexed Bitcoin node inside the Ethereum Virtual Machine (EVM).
* hBK allows Ethereum smart contracts to query Bitcoin data using precompiled calls, ensuring efficient, trustless data access.
  {% endhint %}

***

## ⚙️ How It Works

#### Hemi Virtual Machine (hVM)

The hVM is the backbone of the hBK’s interoperability features, embedding a Bitcoin node within the EVM. This setup allows Ethereum smart contracts to directly query Bitcoin data without relying on external bridges or third-party oracles, ensuring trustless, efficient, and secure access to Bitcoin data.

* Direct Access: Smart contracts can communicate with Bitcoin data embedded in the EVM, enabling them to make queries and receive data via precompiled calls.
* Indexed Data: The fully indexed Bitcoin node maintains transaction history, UTXOs, and meta-protocols like Ordinals and BRC-20 tokens.

#### Developer Interface: Simplified Interaction with Bitcoin

The hBK abstracts technical complexities, offering developers straightforward methods for accessing Bitcoin data, allowing them to:

1. Directly Pass Data to Precompiled Calls: Simple data serialization/deserialization processes provide a transparent gateway to precompiled Bitcoin calls.
2. Enhanced Query Functions (Upcoming): hBK is set to introduce enhanced functions, combining multiple precompile calls and additional processing steps for advanced operations.

This dual approach ensures developers can create Bitcoin-aware applications without managing low-level integration details, focusing instead on innovation and functionality.

***

## 🔑 Key Features

* **Embedded Node Access:** hBK integrates a fully indexed Bitcoin node within Hemi’s EVM environment, exposing robust Bitcoin data for smart contract use.
* **Precompiled Calls for Direct Data Retrieval:** Passthrough functions facilitate Bitcoin data queries with direct calls, automatically handling the data structures.
* **Enhanced Functions for Advanced Queries:** Future upgrades will introduce enhanced functions, combining multiple calls and added processing to support more complex queries and data requirements.


# hBK Smart Contract

{% hint style="warning" %}
This documentation page is outdated and may not reflect current information.
{% endhint %}

## 🌐 Overview

* The Hemi Bitcoin Kit smart contract provides utilities for interacting with Bitcoin data on the Hemi blockchain.
* It includes methods to retrieve Bitcoin address balances, UTXOs, transaction details, and block headers.
* The contract leverages hVM's new precompiles to perform Bitcoin-related queries.
* **Latest hBK release on Hemi:** [0x7007dd1C09527B92AEcd8Ae6570B73d09E0B8F12](https://explorer.hemi.xyz/address/0x7007dd1C09527B92AEcd8Ae6570B73d09E0B8F12)
* **Latest hBK release on Hemi testnet:** [0xeC9fa5daC1118963933e1A675a4EEA0009b7f215](https://testnet.explorer.hemi.xyz/address/0xeC9fa5daC1118963933e1A675a4EEA0009b7f215)

***

## 🚧 Phase 0 - Essentials

This initial phase is focused on core Bitcoin protocol data:

* Script/Address Balances
* UTXO Set
* Full Transactions w/ Output Availability
* Transaction Confirmations
* BTC Headers (Last and N)

***

## 🏗️ Struct Definitions

#### UTXO

Represents an unspent transaction output (UTXO).

```
struct UTXO {
  bytes32 txId;          // Transaction ID
  uint256 index;         // Index of the UTXO
  uint256 value;         // Value in satoshis
  bytes scriptPubKey;    // Script public key
}
```

***

#### Transaction

Represents a Bitcoin transaction.

```
struct Transaction {
  bytes32 containingBlockHash;   // Hash of the containing block
  uint256 transactionVersion;    // Transaction version
  uint256 size;                  // Transaction size
  uint256 vSize;                 // Virtual size of the transaction
  uint256 lockTime;              // Lock time
  Input[] inputs;                // Array of inputs
  Output[] outputs;              // Array of outputs
  uint256 totalInputs;           // Total number of inputs in the original transaction
  uint256 totalOutputs;          // Total number of outputs in the original transaction
  bool containsAllInputs;        // Indicates if all inputs are contained
  bool containsAllOutputs;       // Indicates if all outputs are contained
}
```

***

#### Input

Represents a Bitcoin transaction input.

```
struct Input {
  uint256 inValue;               // Value spent by the input in satoshis
  bytes32 inputTxId;             // Transaction ID of the input source
  uint256 sourceIndex;           // Index of the input in its transaction
  bytes scriptSig;               // Script signature
  uint256 sequence;              // Sequence number
  uint256 fullScriptSigLength;   // Full length of the script signature
  bool containsFullScriptSig;    // Indicates if the full script signature is contained
}
```

***

#### Output

Represents a Bitcoin transaction output.

```
struct Output {
  uint256 outValue;              // Value of the output in satoshis
  bytes script;                  // Output script
  string outputAddress;          // Output address
  bool isOpReturn;               // Indicates if the output is an OP_RETURN output
  bytes opReturnData;            // Data contained in the OP_RETURN output
  bool isSpent;                  // Indicates if the output is spent
  uint256 fullScriptLength;      // Full length of the output script
  bool containsFullScript;       // Indicates if the full output script is contained
  SpentDetail spentDetail;       // Details of the spent output
}
```

***

#### SpentDetail

Represents details of a spent output.

```
struct SpentDetail {
  bytes32 spendingTxId;          // Transaction ID of the spending transaction
  uint256 inputIndex;            // Index of the input in the spending transaction
}
```

***

#### BitcoinHeader

Represents a Bitcoin block header.

```
struct BitcoinHeader {
  uint32 height;                 // Block height
  bytes32 blockHash;             // Block hash
  uint32 version;                // Version
  bytes32 previousBlockHash;     // Previous block hash
  bytes32 merkleRoot;            // Merkle root
  uint32 timestamp;              // Timestamp
  uint32 bits;                   // Bits
  uint32 nonce;                  // Nonce
}
```

***

## 🧑‍💻 IBitcoinKit Interface

The `IBitcoinKit` interface defines the methods available for interacting with the BitcoinKit contract.

```
interface IBitcoinKit {
  function getUTXOsForBitcoinAddress(string calldata btcAddress, uint256 pageNumber, uint256 pageSize) external view returns (UTXO[] memory);
  function getTxConfirmations(bytes32 txId) external view returns (uint32 confirmations);
  function getBitcoinAddressBalance(string calldata btcAddress) external view returns (uint256 balance);
  function getTransactionByTxId(bytes32 txId) external view returns (Transaction memory);
  function getTransactionInputsByTxId(bytes32 txId) external view returns (Input[] memory);
  function getTransactionOutputsByTxId(bytes32 txId) external view returns (Output[] memory);
  function getLastHeader() external view returns (BitcoinHeader memory);
  function getHeaderN(uint32 height) external view returns (BitcoinHeader memory);
}
```

***

#### getBitcoinAddressBalance

Retrieves the balance of a given Bitcoin address.

Precompile Address: 0x40

```
function getBitcoinAddressBalance(string calldata btcAddress) public view returns (uint256 balance)
```

***

#### getUTXOsForBitcoinAddress

Precompile Address: 0x41

Retrieves UTXOs for a given Bitcoin address, page number, and page size.

```
function getUTXOsForBitcoinAddress(string calldata btcAddress, uint256 pageNumber, uint256 pageSize) public view returns (UTXO[] memory)
```

***

#### getTransactionByTxId

Retrieves UTXOs for a given Bitcoin address, page number, and page size.

Precompile Address: 0x42

```
function getTransactionByTxId(bytes32 txId) external view returns (Transaction memory);
```

***

#### getTxConfirmations

Retrieves the number of confirmations for a given transaction ID.

Precompile Address: 0x43

```
function getTxConfirmations(bytes32 txId) public view returns (uint32 confirmations)
```

***

#### getLastHeader

Retrieves the latest Bitcoin block header.

Precompile Address: 0x44

```
function getLastHeader() public view returns (BitcoinHeader memory)
```

***

#### getHeaderN

Precompile Address: 0x45

Retrieves the Bitcoin block header at a specific height.

```
function getHeaderN(uint32 height) public view returns (BitcoinHeader memory)
```

***


# viem

## 🌐 **Overview**

[viem ](https://viem.sh/)extension for [Hemi](https://hemi.xyz/).&#x20;

It includes:&#x20;

* Chain definitions!
* [Bitcoin finality](https://docs.hemi.xyz/foundational-topics/pop-consensus-and-bitcoin-finality) helper!
* [Bitcoin Kit](https://github.com/hemilabs/research/blob/main/research/Bitcoin-kit.md) wrappers!

***

## 📚 Tutorial

1. [Installation ](https://github.com/hemilabs/hemi-viem#installation)
2. [Example](https://github.com/hemilabs/hemi-viem#example)


# Contract Addresses

{% hint style="info" %}

### 📜 **TL;DR:**

* In this article, you’ll find useful contract addresses for Hemi Mainnet, Hemi Sepolia, and commonly used protocols.
  {% endhint %}

***

## Hemi Mainnet

### L1 Hemi Contracts

Core Hemi contracts deployed on **Ethereum Mainnet**.

<table><thead><tr><th width="324">Contract Name</th><th>Contract Address</th></tr></thead><tbody><tr><td><code>AddressManager</code></td><td><code>0xA5F37791378c55941a52B4dCb70Be4D8D09f5e43</code></td></tr><tr><td><code>AnchorStateRegistryProxy</code></td><td><code>0xF44007EAF2faFdD8bA8d3551F23CD2b879F54677</code></td></tr><tr><td><code>DelayedWETHProxy</code></td><td><code>0xc5627348Dbc9179cFb5a24C8199635770Ea575A3</code></td></tr><tr><td><code>DisputeGameFactoryProxy</code></td><td><code>0x5442d0ddB33B396879D2d016A9ad09ad122562C3</code></td></tr><tr><td><code>L1CrossDomainMessengerProxy</code></td><td><code>0xF005dFb08377faD44588Af68d0884D272A6fb050</code></td></tr><tr><td><code>L1ERC721BridgeProxy</code></td><td><code>0xa446331bD28cbe0186A983a27C528f566B6bedE0</code></td></tr><tr><td><code>L1StandardBridgeProxy</code></td><td><code>0x5eaa10F99e7e6D177eF9F74E519E319aa49f191e</code></td></tr><tr><td><code>L2OutputOracleProxy</code></td><td><code>0x6daF3a3497D8abdFE12915aDD9829f83A79C0d51</code></td></tr><tr><td><code>Mips</code></td><td><code>0x42Ff661af011939f699D67bd021d237eBcBA9c2A</code></td></tr><tr><td><code>OptimismMintableERC20FactoryProxy</code></td><td><code>0x0262fEDC4A98f94dDB90CeF0E058644d8409342C</code></td></tr><tr><td><code>OptimismPortalProxy</code></td><td><code>0x39a0005415256B9863aFE2d55Edcf75ECc3A4D7e</code></td></tr><tr><td><code>OptimismPortal2</code></td><td><code>0x04dcfE50e43823A1D8f6e3Fbb8af10BfB7Ebb634</code></td></tr><tr><td><code>PreimageOracle</code></td><td><code>0x613F36BE58Ba712B37474F4B82484D680D24ed20</code></td></tr><tr><td><code>ProtocolVersionsProxy</code></td><td><code>0x13Cb1B6e69Ec8fF6a5C8823d1e8dc78CCCf3Ce48</code></td></tr><tr><td><code>ProxyAdmin</code></td><td><code>0xbE81A9D662422f667F634f3Fc301e2E360FeFB30</code></td></tr><tr><td><code>SafeProxyFactory</code></td><td><code>0xa6B71E26C5e0845f74c812102Ca7114b6a896AB2</code></td></tr><tr><td><code>SafeSingleton</code></td><td><code>0xd9Db270c1B5E3Bd161E8c8503c55cEABeE709552</code></td></tr><tr><td><code>SuperchainConfigProxy</code></td><td><code>0x15144FB8621cB3c4ED3DB223c173ffb58C8D2aB8</code></td></tr><tr><td><code>SystemConfigProxy</code></td><td><code>0x5ae68684D9179A8053883f1Df599Ea7Fb35303c3</code></td></tr><tr><td><code>SystemOwnerSafe</code></td><td><code>0x8434dc705e4B729405Dd66C94DfC62bc3825Ea69</code></td></tr></tbody></table>

***

### L2 Hemi Contracts

Core Hemi contracts deployed on **Hemi**.

<table><thead><tr><th width="285">Contract Name</th><th>Contract Address</th></tr></thead><tbody><tr><td><code>WETH9</code></td><td><a href="https://explorer.hemi.xyz/token/0x4200000000000000000000000000000000000006"><code>0x4200000000000000000000000000000000000006</code></a></td></tr><tr><td><code>OptimismMintableERC20Factory</code></td><td><a href="https://explorer.hemi.xyz/address/0x4200000000000000000000000000000000000012"><code>0x4200000000000000000000000000000000000012</code></a></td></tr><tr><td><code>OptimismMintableERC721Factory</code></td><td><a href="https://explorer.hemi.xyz/address/0x4200000000000000000000000000000000000017"><code>0x4200000000000000000000000000000000000017</code></a></td></tr><tr><td><code>L2StandardBridge</code></td><td><a href="https://explorer.hemi.xyz/address/0x4200000000000000000000000000000000000010"><code>0x4200000000000000000000000000000000000010</code></a></td></tr><tr><td><code>L2ERC721Bridge</code></td><td><code>0x4200000000000000000000000000000000000014</code></td></tr></tbody></table>

***

### Utilities Contracts

Commonly used utility contracts deployed on **Hemi**.

<table><thead><tr><th width="247">Contract Name</th><th>Contract Address</th></tr></thead><tbody><tr><td><code>BitcoinKit v1</code></td><td>0x7007dd1C09527B92AEcd8Ae6570B73d09E0B8F12</td></tr></tbody></table>

***

### hVM Precompiles

For hVM precompile contract addresses, visit the [hVM Feature Summary](/building-bitcoin-apps/hemi-virtual-machine-hvm/feature-summary).

***

### Token Contracts

For a list of all token contract addresses deployed on **Hemi,** visit [`hemilabs/token-list`](https://github.com/hemilabs/token-list/blob/master/src/hemi.tokenlist.json) .

***

## Hemi Sepolia

### L1 Hemi Contracts

Core Hemi contracts deployed on **Sepolia**.

<table><thead><tr><th width="289">Contract Name</th><th>Contract Address</th></tr></thead><tbody><tr><td><code>AddressManager</code></td><td><a href="https://sepolia.etherscan.io/address/0x23f0022354241fdb721dc43e7897d7af662a2995"><code>0x23f0022354241FDb721Dc43E7897d7Af662A2995</code></a></td></tr><tr><td><code>L1CrossDomainMessengerProxy</code></td><td><a href="https://sepolia.etherscan.io/address/0x9bcccf1d222539c4c47e4c6f5749e4d5fa33215c"><code>0x9bCCCf1d222539c4C47E4C6f5749e4d5fA33215c</code></a></td></tr><tr><td><code>L2OutputOracleProxy</code></td><td><a href="https://sepolia.etherscan.io/address/0x032d1e1dd960a4b027a9a35ff8b2b672e333bc27"><code>0x032d1e1dd960A4B027a9a35FF8B2b672E333Bc27</code></a></td></tr><tr><td><code>OptimismPortalProxy</code></td><td><a href="https://sepolia.etherscan.io/address/0xB6f9579980aE46f61217A99145645341E49E2516"><code>0xB6f9579980aE46f61217A99145645341E49E2516</code></a></td></tr><tr><td><code>ProtocolVersionsProxy</code></td><td><a href="https://sepolia.etherscan.io/address/0xBD869d97B85C450d396215c5E1a81bbFA4545e23"><code>0xBD869d97B85C450d396215c5E1a81bbFA4545e23</code></a></td></tr><tr><td><code>DisputeGameFactoryProxy</code></td><td><a href="https://sepolia.etherscan.io/address/0x4cb8fdc8E1A8Ad01369F9a159C67c8be794a98FA"><code>0x4cb8fdc8E1A8Ad01369F9a159C67c8be794a98FA</code></a></td></tr><tr><td><code>L1StandardBridgeProxy</code></td><td><a href="https://sepolia.etherscan.io/address/0xc94b1bee63a3e101fe5f71c80f912b4f4b055925"><code>0xc94b1BEe63A3e101FE5F71C80F912b4F4b055925</code></a></td></tr><tr><td><code>OptimismMintableERC20FactoryProxy</code></td><td><a href="https://sepolia.etherscan.io/address/0xb4bCe3efD3282Da4eEC69429966a85f92298799B"><code>0xb4bCe3efD3282Da4eEC69429966a85f92298799B</code></a></td></tr><tr><td><code>ProxyAdmin</code></td><td><a href="https://sepolia.etherscan.io/address/0xc43ED1E8D70d0e5801514833fAD3D93Ba16Da4Aa"><code>0xc43ED1E8D70d0e5801514833fAD3D93Ba16Da4Aa</code></a></td></tr><tr><td><code>L1StandardBridgeProxy</code></td><td><a href="https://sepolia.etherscan.io/address/0xc94b1BEe63A3e101FE5F71C80F912b4F4b055925"><code>0xc94b1BEe63A3e101FE5F71C80F912b4F4b055925</code></a></td></tr><tr><td><code>L1ERC721BridgeProxy</code></td><td><a href="https://sepolia.etherscan.io/address/0xa5ba2558b41f34f0b5cc4ed389386201a3d31aec"><code>0xa5ba2558B41F34f0B5Cc4eD389386201a3D31AEc</code></a></td></tr><tr><td><code>SystemConfigProxy</code></td><td><a href="https://sepolia.etherscan.io/address/0xfa73580F4D72294Ae9EE3DAaC36D8bF111B37Ce9"><code>0xfa73580F4D72294Ae9EE3DAaC36D8bF111B37Ce9</code></a></td></tr></tbody></table>

***

### L2 Hemi Contracts

Core Hemi contracts deployed on **Hemi Sepolia**.

<table><thead><tr><th width="301">Contract Name</th><th>Contract Address</th></tr></thead><tbody><tr><td><code>L2ToL1MessagePasser</code></td><td><a href="https://optimistic.etherscan.io/address/0x4200000000000000000000000000000000000016"><code>0x4200000000000000000000000000000000000016</code></a></td></tr><tr><td><code>L2CrossDomainMessenger</code></td><td><a href="https://optimistic.etherscan.io/address/0x4200000000000000000000000000000000000007"><code>0x4200000000000000000000000000000000000007</code></a></td></tr><tr><td><code>L2StandardBridge</code></td><td><a href="https://optimistic.etherscan.io/address/0x4200000000000000000000000000000000000010"><code>0x4200000000000000000000000000000000000010</code></a></td></tr><tr><td><code>L2ERC721Bridge</code></td><td><a href="https://optimistic.etherscan.io/address/0x4200000000000000000000000000000000000014"><code>0x4200000000000000000000000000000000000014</code></a></td></tr><tr><td><code>SequencerFeeVault</code></td><td><a href="https://optimistic.etherscan.io/address/0x4200000000000000000000000000000000000011"><code>0x4200000000000000000000000000000000000011</code></a></td></tr><tr><td><code>OptimismMintableERC20Factory</code></td><td><a href="https://optimistic.etherscan.io/address/0x4200000000000000000000000000000000000012"><code>0x4200000000000000000000000000000000000012</code></a></td></tr><tr><td><code>OptimismMintableERC721Factory</code></td><td><a href="https://optimistic.etherscan.io/address/0x4200000000000000000000000000000000000017"><code>0x4200000000000000000000000000000000000017</code></a></td></tr><tr><td><code>L1Block</code></td><td><a href="https://optimistic.etherscan.io/address/0x4200000000000000000000000000000000000015"><code>0x4200000000000000000000000000000000000015</code></a></td></tr><tr><td><code>GasPriceOracle</code></td><td><a href="https://optimistic.etherscan.io/address/0x420000000000000000000000000000000000000F"><code>0x420000000000000000000000000000000000000F</code></a></td></tr><tr><td><code>ProxyAdmin</code></td><td><a href="https://optimistic.etherscan.io/address/0x4200000000000000000000000000000000000018"><code>0x4200000000000000000000000000000000000018</code></a></td></tr><tr><td><code>BaseFeeVault</code></td><td><a href="https://optimistic.etherscan.io/address/0x4200000000000000000000000000000000000019"><code>0x4200000000000000000000000000000000000019</code></a></td></tr><tr><td><code>L1FeeVault</code></td><td><a href="https://optimistic.etherscan.io/address/0x420000000000000000000000000000000000001A"><code>0x420000000000000000000000000000000000001A</code></a></td></tr><tr><td><code>GovernanceToken</code></td><td><a href="https://optimistic.etherscan.io/address/0x4200000000000000000000000000000000000042"><code>0x4200000000000000000000000000000000000042</code></a></td></tr><tr><td><code>SchemaRegistry</code></td><td><a href="https://optimistic.etherscan.io/address/0x4200000000000000000000000000000000000020"><code>0x4200000000000000000000000000000000000020</code></a></td></tr><tr><td><code>EAS</code></td><td><a href="https://optimistic.etherscan.io/address/0x4200000000000000000000000000000000000021"><code>0x4200000000000000000000000000000000000021</code></a></td></tr></tbody></table>

***

### Utilities Contracts

Commonly used utility contracts deployed on **Hemi Sepolia**.

<table><thead><tr><th width="247">Contract Name</th><th>Contract Address</th></tr></thead><tbody><tr><td><code>BitcoinKit v0</code></td><td><a href="https://testnet.explorer.hemi.xyz/address/0xeC9fa5daC1118963933e1A675a4EEA0009b7f215?tab=read_contract"><code>0xeC9fa5daC1118963933e1A675a4EEA0009b7f215</code></a></td></tr></tbody></table>

***

### hVM Precompiles

For hVM precompile contract addresses, visit the [hVM Feature Summary](/building-bitcoin-apps/hemi-virtual-machine-hvm/feature-summary).

***

### Token Contracts

For a list of all token contract addresses deployed on **Hemi Sepolia,** visit [`hemilabs/token-list`](https://github.com/hemilabs/token-list/blob/master/src/hemi.tokenlist.json) .


# Contract Verification

{% hint style="info" %}

## 📜 **TL;DR:**

This guide explains how to verify smart contracts deployed on the Hemi blockchain using two methods:

1. Manual UI-based verification via Blockscout.
2. API-based verification using Hardhat.
   {% endhint %}

***

## 🏁 Prerequisites

* Hemi RPC URL and deployed contract address.
* Contract source code available (flattened only if verifying manually via the Hemi Blockscout UI).

***

## 🖥️ Blockscout UI Verification&#x20;

{% hint style="info" %}
Manual verification is performed directly through the Blockscout UI. This method requires flattening the contract source code and uploading it manually.
{% endhint %}

#### 1. Flatten the contract

Flattening a contract is necessary when verifying through the UI.&#x20;

**For Hardhat:**

```
npx hardhat flatten contracts/MyContract.sol > MyContractFlattened.sol
```

**For Foundry:**

```
forge flatten src/MyContract.sol > MyContractFlattened.sol
```

***

#### 2. Access Hemi Blockscout

Go to Hemi Blockscout Explorer and navigate to the [Verify & Publish Contract](https://testnet.explorer.hemi.xyz/contract-verification) page.

***

#### 3. Input contract information

* `Smart contract / Address`:  Paste the address that your smart contract was deployed to.
* `Contract license`:  Select 'No License' unless otherwise specified.
* `Verification method`: Choose Solidity (Flattened source code).
* `Is Yul contract`: Leave unchecked unless your contract is written in Yul.
* `Include nightly builds`: Select only if required.
* `Compiler`: Choose the exact version specified in `pragma solidity X.X.X` in your code.
* `EVM Version`: Set to default unless you used a specific EVM version.
* `Optimization enabled`: Deselect optimization.

Copy and paste the entire flattened contract code into the Contract code field and click 'Verify & publish'.

<figure><img src="/files/JBIBt8vu0T8TeRFPdb3H" alt=""><figcaption></figcaption></figure>

***

#### 4. Submit for verification 🎉

Once all required details are entered, submit the form. BlockScout will compare the uploaded source code with the deployed bytecode. If they match, your contract will be verified.

{% hint style="success" %}
To confirm verification, search for your contract address on BlockScout. A green check mark next to your contract indicates successful verification.
{% endhint %}

<figure><img src="/files/wl8DKv37hEzjia9MqD4K" alt="" width="375"><figcaption></figcaption></figure>

***

## 🚧 Hardhat Verification

#### 1. Install dependencies

If you haven't already installed Hardhat and the verification plugin (adapted for Blockscout), run the following:

```
npm install --save-dev hardhat @nomiclabs/hardhat-etherscan @nomicfoundation/hardhat-verify
```

***

#### 2. Configure Hardhat for Hemi

In your \``hardhat.config.js`\`, set up the Hemi network and include Blockscout API information for contract verification:

```javascript
require('dotenv').config()
require("@nomiclabs/hardhat-ethers");
require("@nomicfoundation/hardhat-verify");

module.exports = {
  solidity: "0.8.20",
  networks: {
    hemi: {
      url: "https://rpc.hemi.network/rpc",
      chainId: 43111,
      accounts: [`0x${process.env.PRIVATE_KEY}`],
    },
  },
  etherscan: {
    apiKey: {
      // Is not required by blockscout. Can be any non-empty string
      'hemi-mainnet': "abc"
    },
    customChains: [
      {
        network: "hemi-mainnet",
        chainId: 43111,
        urls: {
          apiURL: "https://explorer.hemi.xyz/api",
          browserURL: "https://explorer.hemi.xyz",
        }
      }
    ]
  },
  sourcify: {
    enabled: false
  }
};
```

***

#### 3. Verify the contract

Once deployed, you can verify the contract using Hardhat’s \``verify`\` command. Make sure to include any constructor arguments if necessary:

```
npx hardhat verify --network hemi <DEPLOYED_CONTRACT_ADDRESS> "Constructor Argument 1" "Constructor Argument 2"
```

***

#### 4. Verification successful! 🎉

{% hint style="warning" %}
If you encounter the following error, visit the [Hemi Block Explorer](https://testnet.explorer.hemi.xyz) and search your contract address to confirm verification:
{% endhint %}

```
hardhat-verify found one or more errors during the verification process:

Etherscan:
The block explorer's API responded that the contract contracts/MyToken.sol:MyToken at <CONTRACT ADDRESS> is already verified.
This can happen if you used the '--force' flag. However, re-verification of contracts might not be supported
by the explorer (e.g., Etherscan), or the contract may have already been verified with a full match.
```


# Data Indexing

Getting historical data on a smart contract can be frustrating when you’re building a dapp. [The Graph](https://thegraph.com/) provides a decentralized option to query smart contract data through APIs known as subgraphs, which utilize GraphQL.  The Graph’s infrastructure relies on a decentralized network of indexers, enabling your dapp to become truly decentralized.

## Quick Start

These subgraphs only take a few minutes to set up and get running. To get started, follow these three steps:

1. Initialize your subgraph project
2. Deploy & Publish
3. Query from your dapp

Pricing: **All developers receive 100K free queries per month on the decentralized network**. After these free queries, you only pay based on usage at $2 for every 100K queries.

Here’s a step by step walk through:

## 1. Initialize your subgraph project

### Create a subgraph on Subgraph Studio⁠

Go to the [Subgraph Studio](https://thegraph.com/studio/) and connect your wallet. Once your wallet is connected, you can begin by clicking “Create a Subgraph”. It is recommended to use Title Case: “Subgraph Name Chain Name.”

![Create a Subgraph](https://lh7-us.googleusercontent.com/docsz/AD_4nXf8OTdwMxlKQGKzIF_kYR7NPKeh9TmWnZBYxb7ft_YbdOdx_VVtbp6PslN7N1KGUzNpIDCmaXppdrllM1cw_J4L8Na03BXOWzJTK1POCve0nkRjQYgWJ60QHAdtQ4Niy83SMM8m0F0f-N-AJj4PDqDPlA5M?key=fnI6SyFgXU9SZRNX5C5vPQ)

You will then land on your subgraph’s page. All the CLI commands you need will be visible on the right side of the page:

![CLI commands](https://lh7-us.googleusercontent.com/docsz/AD_4nXe3YvCxiOH_LupSWe8zh9AmP-VrV4PlOq3f7Ix6hNlBUYcANUFuLuVIWR74OGiBs0nrugTyT0v3o6RPmTsgHONdv_ZJNWtcDWEkRntXPHlQGFcqmEBa-D6j4aoIPzUKYdOJMVUPu8O3fwjdZ4IaXXZoTzY?key=fnI6SyFgXU9SZRNX5C5vPQ)

### Install the Graph CLI⁠

On your local machine run the following:

```
npm install -g @graphprotocol/graph-cli
```

### Initialize your Subgraph⁠

You can copy this directly from your subgraph page to include your specific subgraph slug:

```
graph init <SUBGRAPH_SLUG>
```

You’ll be prompted to provide some info on your subgraph like this:

![cli sample](https://lh7-us.googleusercontent.com/docsz/AD_4nXdTAUsUb5vbs3GtCrhKhuXM1xYoqqooYTxw6lfJfYtLJNP8GKVOhTPmjxlM1b6Qpx-pXNVOzRuc8BL12wZXqy4MIj8ja0tp15znfuJD_Mg84SSNj3JpQ4d31lNTxPYnpba4UOzZx8pmgOIsbI7vCz70v9gC?key=fnI6SyFgXU9SZRNX5C5vPQ)

Simply have your contract verified on the block explorer and the CLI will automatically obtain the ABI and set up your subgraph. The default settings will generate an entity for each event.

## 2. Deploy & Publish

### Deploy to Subgraph Studio⁠

First run these commands:

```bash
$ graph codegen
$ graph build
```

Then run these to authenticate and deploy your subgraph. You can copy these commands directly from your subgraph’s page in Studio to include your specific deploy key and subgraph slug:

```bash
$ graph auth <DEPLOY_KEY>
$ graph deploy <SUBGRAPH_SLUG>
```

You will be asked for a version label. You can enter something like v0.0.1, but you’re free to choose the format.

### Test your subgraph⁠

You can test your subgraph by making a sample query in the playground section. The Details tab will show you an API endpoint. You can use that endpoint to test from your dapp.

![Playground](https://lh7-us.googleusercontent.com/docsz/AD_4nXf3afwSins8_eO7BceGPN79VvwolDxmFNUnkPk0zAJCaUA-3-UAAjVvrMzwr7q9vNYWdrEUNgm2De2VfQpWauiT87RkFc-cVfoPSsQbYSgsmwhyY1-tpPdv2J1H4JAMq70nfWBhb8PszZBFjsbDAaJ5eto?key=fnI6SyFgXU9SZRNX5C5vPQ)

### Publish Your Subgraph to The Graph’s Decentralized Network

Once your subgraph is ready to be put into production, you can publish it to the decentralized network. On your subgraph’s page in Subgraph Studio, click on the Publish button:

![publish button](https://edgeandnode.notion.site/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2Fa7d6afae-8784-4b15-a90e-ee8f6ee007ba%2F2f9c4526-123d-4164-8ea8-39959c8babbf%2FUntitled.png?table=block\&id=37005371-76b4-4780-b044-040a570e3af6\&spaceId=a7d6afae-8784-4b15-a90e-ee8f6ee007ba\&width=1420\&userId=\&cache=v2)

Before you can query your subgraph, Indexers need to begin serving queries on it. In order to streamline this process, you can curate your own subgraph using GRT.

When publishing, you’ll see the option to curate your subgraph. As of May 2024, it is recommended that you curate your own subgraph with at least 3,000 GRT to ensure that it is indexed and available for querying as soon as possible.

![Publish screen](https://lh7-us.googleusercontent.com/docsz/AD_4nXerUr-IgWjwBZvp9Idvz5hTq8AFB0n_VlXCzyDtUxKaCTANT4gkk-2O77oW-a0ZWOh3hnqQsY7zcSaLeCQin9XU1NTX1RVYOLFX9MuVxBEqcMryqgnGQKx-MbDnOWKuMoLBhgyVWQereg3cdWtCPcTQKFU?key=fnI6SyFgXU9SZRNX5C5vPQ)

## 3. Query your Subgraph

Congratulations! You can now query your subgraph on the decentralized network!

For any subgraph on the decentralized network, you can start querying it by passing a GraphQL query into the subgraph’s query URL which can be found at the top of its Explorer page.

Here’s an example from the [CryptoPunks Ethereum subgraph](https://thegraph.com/explorer/subgraphs/HdVdERFUe8h61vm2fDyycHgxjsde5PbB832NHgJfZNqK) by Messari:

![Query URL](https://lh7-us.googleusercontent.com/docsz/AD_4nXebivsPOUjPHAa3UVtvxoYTFXaGBao9pQOAJvFK0S7Uv0scfL6TcTVjmNCzT4DgsIloAQyrPTCqHjFPtmjyrzoKkfSeV28FjS32F9-aJJm0ILAHey2gqMr7Seu4IqPz2d__QotsWG3OKv2dEghiD74eypzs?key=fnI6SyFgXU9SZRNX5C5vPQ)

The query URL for this subgraph is:

<https://gateway-arbitrum.network.thegraph.com/api/**\\[api-key]**/subgraphs/id/HdVdERFUe8h61vm2fDyycHgxjsde5PbB832NHgJfZNqK>

Now, you simply need to  fill in your own API Key to start sending GraphQL queries to this endpoint.

### Getting your own API Key

![API keys](https://lh7-us.googleusercontent.com/docsz/AD_4nXdz7H8hSRf2XqrU0jN3p3KbmuptHvQJbhRHOJh67nBfwh8RVnhTsCFDGA_JQUFizyMn7psQO0Vgk6Vy7cKYH47OyTq5PqycB0xxLyF4kSPsT7hYdMv2MEzAo433sJT6VlQbUAzgPnSxKI9a5Tn3ShSzaxI?key=fnI6SyFgXU9SZRNX5C5vPQ)

In Subgraph Studio, you’ll see the “API Keys” menu at the top of the page. Here you can create API Keys.

## Appendix

### Sample Query

This query shows the most expensive CryptoPunks sold.

```graphql
{
  trades(orderBy: priceETH, orderDirection: desc) {
    priceETH
    tokenId
  }
}

```

Passing this into the query URL returns this result:

```
{
  "data": {
    "trades": [
      {
        "priceETH": "124457.067524886018255505",
        "tokenId": "9998"
      },
      {
        "priceETH": "8000",
        "tokenId": "5822"
      },
//      ...
```

💡 Trivia: Looking at the top sales on \[CryptoPunks website]\(<https://cryptopunks.app/cryptopunks/topsales>) it looks like the top sale is Punk #5822, not #9998. Why? Because they censor the flash-loan sale that happened.

### Sample code

```jsx
const axios = require('axios');

const graphqlQuery = `{
  trades(orderBy: priceETH, orderDirection: desc) {
    priceETH
    tokenId
  }
}`;
const queryUrl = 'https://gateway-arbitrum.network.thegraph.com/api/[api-key]/subgraphs/id/HdVdERFUe8h61vm2fDyycHgxjsde5PbB832NHgJfZNqK'

const graphQLRequest = {
  method: 'post',
  url: queryUrl,
  data: {
    query: graphqlQuery,
  },
};

// Send the GraphQL query
axios(graphQLRequest)
  .then((response) => {
    // Handle the response here
    const data = response.data.data
    console.log(data)

  })
  .catch((error) => {
    // Handle any errors
    console.error(error);
  });
```

### Additional resources:

* To explore all the ways you can optimize & customize your subgraph for a better performance, read more about [creating a subgraph here](https://thegraph.com/docs/en/developing/creating-a-subgraph/).
* For more information about querying data from your subgraph, read more [here](https://thegraph.com/docs/en/querying/querying-the-graph/).


# Oracles

🌐 Overview

Oracles play a critical role in bridging the gap between blockchain and the external world, enabling smart contracts on Hemi to access trustworthy off-chain data necessary for various use cases.&#x20;

The most common applications of oracles include:

* Providing up-to-date token prices for different pairs, which is essential for DeFi protocols and financial products.
* Enabling dynamic NFTs that can change their properties based on real-world events, adding a layer of interactivity and uniqueness.

***

## ⎑ Push vs Pull

Oracles operate using two primary models:

* **Push Model:** In this traditional approach, the oracle regularly pushes data to an on-chain contract, which dApps can access as needed.
* **Pull Model:** This newer model involves oracles signing data and keeping it on an external network. When dApps need updated data, users pull the signed data and submit it on-chain with their transaction.

***

### Pyth <a href="#redstone" id="redstone"></a>

Pyth offers push-based price feeds for Hemi.&#x20;

#### **Supported Networks:**

* Hemi Mainnet
* Hemi Sepolia

{% embed url="<https://insights.pyth.network/price-feeds?search=hemi>" %}

***

### Redstone <a href="#redstone" id="redstone"></a>

Redstone offers push-based price feeds for Hemi.&#x20;

#### Supported Networks:

* Hemi Mainnet
* Hemi Sepolia

{% embed url="<https://app.redstone.finance/app/feeds/?networks=743111,43111&page=1&sortBy=popularity&sortDesc=false&perPage=32>" %}

***

### Stork <a href="#redstone" id="redstone"></a>

Stork offers pull-based price feeds for Hemi.&#x20;

#### Supported Networks:

* Hemi Mainnet

{% embed url="<https://docs.stork.network/resources/contract-addresses/evm#hemi>" %}

***

### eOracle <a href="#redstone" id="redstone"></a>

eOracle offers pull-based price feeds for Hemi.&#x20;

#### Supported Networks:

* Hemi Mainnet

{% embed url="<https://docs.eo.app/docs/eprice/feed-addresses/hemi>" %}


# Incentives

## 🌐 **Overview**

| [🎯 **Points Program**](/incentives/points)                   | Participants earn points through various activities.                                   | To maintain an active community by rewarding participation and promoting sustained engagement.                           |
| ------------------------------------------------------------- | -------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------ |
| 💰 [**Grants**](/incentives/grants)                           | Bespoke agreements provide incentives to projects aligned with Hemi's strategic goals. | To drive innovation and growth by financially supporting projects that have significant potential impact on the network. |
| [🔄 **Retroactive Funding**](/incentives/retroactive-funding) | Compensation for builders for previously completed impactful work.                     | To acknowledge and reward valuable past contributions, encouraging ongoing commitment.                                   |
| [⚡One-Off Spends](/incentives/one-off-spends)                 | Funds allocated for unique opportunities like hackathons and specific projects.        | To promote innovation and meet immediate strategic needs by creating unique opportunities.                               |

***


# Points

### 🌐 Season 1: Testnet <a href="#pdf-page-jfwnwievmil2x2lghizb-season-1-testnet" id="pdf-page-jfwnwievmil2x2lghizb-season-1-testnet"></a>

**🎯 Goal**: To lay a solid foundation for the Hemi Network by engaging and incentivizing users, developers, and creators during the testnet phase.

#### **Incentive Structure** <a href="#pdf-page-jfwnwievmil2x2lghizb-incentive-structure" id="pdf-page-jfwnwievmil2x2lghizb-incentive-structure"></a>

* **🔗 On-chain Engagement**: Points are allocated for transactions and other on-chain activities.
* **💬 Off-chain Participation**: Points are also given for contributions to social platforms and community engagement that support network growth.

#### **Rewards Focus** <a href="#pdf-page-jfwnwievmil2x2lghizb-rewards-focus" id="pdf-page-jfwnwievmil2x2lghizb-rewards-focus"></a>

* **Network Utilization and User Onboarding**: Prioritizing actions that enhance network usage and integrate new participants effectively.
* **Active Community Contributions**: Recognizing significant community involvement and impactful contributions off-chain.

#### **Strategic Initiatives** <a href="#pdf-page-jfwnwievmil2x2lghizb-strategic-initiatives" id="pdf-page-jfwnwievmil2x2lghizb-strategic-initiatives"></a>

* **Customized Financial Support**: Crafting grants and investments specifically designed to align with strategic objectives of Hemi's ecosystem.
* **Open Application for Innovation**: Streamlining the process for developers to propose and deploy on-chain solutions, encouraging broad participation, and lowering barriers to entry.

***

### 🌐 Season 2: Mainnet + Token Generation Event (TGE) <a href="#pdf-page-jfwnwievmil2x2lghizb-season-2-mainnet-token-generation-event-tge" id="pdf-page-jfwnwievmil2x2lghizb-season-2-mainnet-token-generation-event-tge"></a>

**🎯 Goal**: To amplify network activity and ecosystem growth on the mainnet during the critical period following the TGE.

#### **Incentive Structure** <a href="#pdf-page-jfwnwievmil2x2lghizb-incentive-structure-1" id="pdf-page-jfwnwievmil2x2lghizb-incentive-structure-1"></a>

* 🔗 **On-chain Engagement**: Intensive rewards for activities that demonstrate substantial economic value, such as **Total Value Locked (TVL)** and transaction volume.
  * Drive substantial TVL growth through strategic protocol integrations.
  * Establish sustainable transaction volume via supported LSTs/LRTs on Hemi.
  * Create network effects through interconnected DeFi activities.
* 💬 **Off-chain Participation**: Incentives for community engagement and activities that boost the ecosystem’s visibility.

#### **Rewards Focus** <a href="#pdf-page-jfwnwievmil2x2lghizb-rewards-focus-1" id="pdf-page-jfwnwievmil2x2lghizb-rewards-focus-1"></a>

* **Economic Contributions**: Maximize network activity through strategic liquidity provision and trading.
* **Ecosystem Growth**: Onboard protocols to enhance the network activity targeting user base expansion.

#### **Strategic Initiatives** <a href="#pdf-page-jfwnwievmil2x2lghizb-strategic-initiatives-1" id="pdf-page-jfwnwievmil2x2lghizb-strategic-initiatives-1"></a>

* **Push for Hemi-native Ecosystem**: Promoting the development and integration of native applications though Hemi grants program.
* **Support for Strategic Projects**: Providing tailored support to projects that significantly contribute to network growth.
* **Community-Driven Activities**: Encouraging the community to participate in governance and decision-making processes.

***

### 🌐 Season 3 - N: Mainnet, Post-TGE <a href="#pdf-page-jfwnwievmil2x2lghizb-season-3-n-mainnet-post-tge" id="pdf-page-jfwnwievmil2x2lghizb-season-3-n-mainnet-post-tge"></a>

🎯 **Objective**: Consolidate network growth, enhance economic stability, and transition to decentralized governance on mainnet.

#### **Incentive Structure** <a href="#pdf-page-jfwnwievmil2x2lghizb-incentive-structure-2" id="pdf-page-jfwnwievmil2x2lghizb-incentive-structure-2"></a>

* 🔗 **On-chain Engagement**: Prioritizing liquidity provision, DEX trading volume, and supporting projects that significantly contribute to the network’s economic activity, such as AMM liquidity and Bitcoin DEX trading.
* 💬 **Off-chain Participation**: Maintaining engagement through community-building initiatives and continued support for established projects.

#### **Rewards Focus** <a href="#pdf-page-jfwnwievmil2x2lghizb-rewards-focus-2" id="pdf-page-jfwnwievmil2x2lghizb-rewards-focus-2"></a>

* **Transition to Liquidity Mining**: Points accumulated in Seasons 1 and 2 are carried over to the next season.  Points will be rewarded for strategically interacting with the network.

#### **Strategic Initiatives** <a href="#pdf-page-jfwnwievmil2x2lghizb-strategic-initiatives-2" id="pdf-page-jfwnwievmil2x2lghizb-strategic-initiatives-2"></a>

* **Retroactive Funding Implementation**: Beginning to reward builders retroactively for their impactful contributions made in previous seasons.
* **Continuation of Grant and Investment Programs**: Focusing solely on bespoke agreements, moving away from open applications to more curated and strategic engagements that are aligned with network goals.
* **New Inflationary $HEMI for Security**: Introducing new $HEMI tokens specifically allocated to enhance network security and operational robustness.
* **Governance Transition**: Phasing out direct grant applications and transitioning to a decentralized governance model (DeGov) to manage future grants and investments.

> ***Note:** Points awarded by the Hemi Network are intended to encourage user activities that are beneficial to the network. Points are awarded solely to incentivize beneficial network activities and carry no monetary value, or financial rights. The exchange or conversion of points to rewards, if any, will be undertaken at the sole discretion of Hemi.*


# Grants

## 🏁 Getting Started

Are you building the next killer Hemi application (hApp) or a service that adds value to Hemi's ecosystem? Fill out the form below to let us know what you're building and apply for a grant!

Want some inspiration? Check out the lists below for some of the projects we're most excited about.&#x20;

If you don't see your idea on this list, we'd still love to hear what you're interested in building!&#x20;

***

## 🤖 Bitcoin-Aware hApps (Using hVM or hBK)

These are hApps that directly take advantage of Hemi's EVM-level Bitcoin awareness.

* Non-Custodial BTC / BTC Asset DEXes
  * A decentralized exchange to trade Bitcoin or Bitcoin-based assets without requiring users to give up custody of their funds.&#x20;
* Non-Custodial Bitcoin Lending
  * A dApp to enable Bitcoin-based lending (either borrowing Bitcoin itself or using Bitcoin as collateral for other loans) without users giving up custody of their funds.&#x20;
* Bitcoin "smart wallets" with custom key manager sets
  * Users/smart contracts create Bitcoin wallets controlled by configurable validator sets and managed on Hemi; smart wallet owners can specify transactions that should be performed on Bitcoin from their wallet, and validators work together to sign and propagate on Bitcoin
* Bitcoin "transaction forwarding"
  * A dApp where users/smart contracts can send tunneled BTC on Hemi to a liquidity provider, who then sends tunneled BTC to the sender’s specified destination.
* Bitcoin MEV Marketplace / Tx Accelerator
  * A dApp where users can submit raw Bitcoin transactions or their hashes along with an attached reward (in $HEMI, $ETH, etc.), which will be paid out to the Bitcoin miner that includes their specified Bitcoin transaction in a block
* Ordinals/Inscriptions "minting-as-a-service"
  * A service that facilitates the creation of Ordinals.&#x20;
* Any other novel Bitcoin dApp that benefits from introspection into Bitcoin data

***

## ✨ AI hApps

These are hApps that utilize AI directly or provide services that AI developers want to use.

* ZK-Verified MLaaS (ML as a Service)
  * Model owners authenticate their private models to Bitcoin via Hemi by publishing a hash of the model weights. Consumers select a model and send data to perform inference on, and the model owner computes the requested inference and returns the result along with a zero-knowledge proof demonstrating correct execution against the specified model.
* Private FHE-based MLaaS
  * Similar to zk-verified MLaaS, but the model consumers send fully homomorphically encrypted input data, meaning the model owner can't see the consumer's data they are performing inference with.
* Training Data Marketplace
  * Marketplace for users to buy and sell the rights to use different data sets for model training, producing a proof of data licensing authenticated to Bitcoin via Hemi. Optionally, ZK-verified training proofs could be employed to cryptographically prove that a model was only trained on licensed data.
* Decentralized Machine Learning
  * Peer-to-peer marketplaces for buying computing power. Could either be generic compute purchasing, or AI-specific distributed training/inference protocols.
* Portfolio Management Agents and DAOs
  * Autonomous AI agents that trade assets or perform other on-chain actions on Hemi for a user or group of users.
* Crowd-Sourced Data Classification
  * Humans perform data classification/labeling on data so it can be used for machine learning, and are paid a reward if their classification is aligned with the majority of other users.&#x20;

***

## 💡 Other hApp Ideas

* DEXes
* Lending Markets
* Payment Channels
* Bridges
* Yield Aggregators
* Algorithmic Stablecoins
* On-chain Games
* NFT Projects&#x20;
* NFT Marketplaces
* Real World Assets

***

## Other Projects

* Custom PoP miners
* PoP mining embedded in a widely-used Bitcoin wallet
* Hemi metrics/explorers/chain analytics
* Improvements to existing services (explorer, portal, demo hApps, etc.)
* Bitcoin timestamping services via Hemi
* Oracles

***

## Apply Here

{% embed url="<https://docs.google.com/forms/d/e/1FAIpQLSeefTf4PVZFX2yekus_eCRwWk_LCa9gfEdCPcF7mYVX3wBINg/viewform>" %}


# Retroactive Funding

*Coming Soon (Join* [*Discord*](https://discord.com/invite/hemixyz) *to See Updates)*


# One-Off Spends

*Coming Soon (Join* [*Discord*](https://discord.com/invite/hemixyz) *to See Updates)*


# Partners

## Review Process

Once your submission is received, our team will review it within 2 business days. We take every inquiry seriously and evaluate each on its merits.&#x20;

* **If You Don't Hear From Us:** Should 2 business days pass without a response, it might indicate that your proposal isn't the right fit for us at the moment. This doesn't reflect your proposal's value; rather, it might not align with our current needs or focus areas.
* **Encouragement to Reapply**: We understand circumstances and offerings evolve. If you're still interested, please consider reapplying in 2-4 weeks. Your future proposals might align better with our changing needs.&#x20;
* **If Your Inquiry Matches Our Needs:** For inquiries that align with our goals and capabilities, expect to hear from us within the specified review period. We're excited about partnering with entities that complement our mission and enhance our offerings.&#x20;

***

## Inquire Here

{% embed url="<https://docs.google.com/forms/d/e/1FAIpQLSc5WXLwVr2BJSXp-78e-zvDoXGHDGtCx0Q_Kgu1ssCAa35kmg/viewform>" %}


# FAQ

## General

<details>

<summary>Where can I learn more about Hemi?</summary>

You can learn more about Hemi by reading our documentation, visiting our website, reading the whitepaper, or joining the community on Discord.

</details>

<details>

<summary>How do I earn points, and how does incentivized testnet work?</summary>

Check out [Incentives](/incentives/incentives) for the most recent info.

</details>

## Smart Contract Deployments

<details>

<summary><strong>Why is my smart contract deployment failing on the testnet even though the contract seems to be created?</strong></summary>

**🌐 Overview**

* Deployment issues on testnet can stem from using features or opcodes not yet supported by the testnet's version of the EVM.
* Check the `Raw trace` tab

  <figure><img src="/files/vKbtIWQIlE6Di2ilfzjt" alt=""><figcaption></figcaption></figure>

**👀 Common Culprits**

* <mark style="color:blue;">One frequent cause is the use of the</mark> <mark style="color:blue;">`PUSH0`</mark><mark style="color:blue;">opcode, which was introduced in</mark> <mark style="color:blue;">**EIP-3855**</mark> <mark style="color:blue;">with the</mark> *<mark style="color:blue;">**Shanghai upgrade**</mark>*<mark style="color:blue;">.</mark>

**✅ Solutions**

* To avoid such issues, it's best to wait until testnet officially supports these new features before attempting to deploy contracts that rely on them.
* 📜 We will make an announcement when we update this soon!

</details>

<details>

<summary>Gas Usage (e.g. are you at 100%?)</summary>

**🌐 Overview**

* Deployment failures can often be traced back to insufficient gas allocation.
* When a transaction consumes all allocated gas without completing, the network rejects it to avoid executing transactions that could run indefinitely.

**👀 Common Culprits**

* **100% Gas Consumption:** If a transaction fails and the gas usage is 100%, it suggests the gas limit set for the contract's deployment was too low to cover the computation required.
  * Check `Gas usage & limit by txn`

**✅ Solutions**

* **Increase Gas Limit:** Adjust the gas limit upwards based on the complexity of your contract and the estimations provided by gas estimation tools.
* **Optimize Contract Code:** Review and optimize your smart contract code to reduce gas consumption. This can involve simplifying functions, removing unnecessary operations, or leveraging patterns that consume less gas.
* **Test Thoroughly**

</details>

<details>

<summary>Did you verify your Smart Contract?</summary>

**🌐 Overview**

Preparing your smart contract for deployment involves a critical step: <mark style="background-color:green;">verification</mark>. This process not only helps in catching potential issues early but also enhances the contract's integrity before it goes live.

**🔍 Verification is Key**

Verifying your smart contract is paramount to ensure its readiness for deployment. This crucial step provides valuable insights into any potential errors or vulnerabilities that could compromise its performance or security.

**🛠 Steps to Verify:**

* **Navigate to Contract Details:** Access your contract's details within your development environment or via a testnet blockchain explorer where your contract will be deployed.
* Look for the `Verify and Publish` option. **Selecting this begins the verification process, which is essential for assessing whether your contract operates as intended and is ready for interaction with users.**

[Read more](https://docs.blockscout.com/for-users/verifying-a-smart-contract) about verifying smart contracts deployed on Hemi.

</details>

## Navigating the Hemi Portal

<details>

<summary>What tokens are currently supported?</summary>

You can use our platform to access a variety of tokens, including ETH, USDT, USDC, and DAI.

</details>

<details>

<summary>What is tunneling? What is a tunnel?</summary>

The Hemi Tunnel is designed for seamless cross-chain transactions.

Hemi’s Bitcoin and Ethereum Tunnels improve security while decentralizing asset portability. They do this by leveraging the Hemi Virtual Machine, which gives the network direct awareness of Bitcoin’s and Ethereum’s states.

</details>

## Capsules

<details>

<summary>What is Capsule?</summary>

Capsule is an asset transfer protocol that allows anyone to batch and transfer multiple assets in a single package on Hemi. Additionally, it provides users and developers with advanced functionality like gasless transactions, re-routing/recalling, and configurable security. Learn more about Capsule Labs by visiting the Capsule [site](https://capsulelabs.xyz).

</details>

## Grants

<details>

<summary>How do I apply for a grant?</summary>

*wip*

</details>

<details>

<summary>How do we review grants?</summary>

*wip*

</details>

## Getting Involved

<details>

<summary>How do I partner with Hemi?</summary>

You can find the partnership inquiry form [here](https://discord.com/channels/1202677849887080508/1219364577939030220/1219364577939030220).

</details>

<details>

<summary>How do we review partnership inquiries?</summary>

Read our review process in [Partners](/additional-resources/partners).

</details>

Have more questions or concerns? E-mail **<support@hemi.xyz>** or [**join our Discord.**](https://discord.gg/hemixyz)


# Official Links

Links to everything Hemi.

| Website       | <https://hemi.xyz/>                      |
| ------------- | ---------------------------------------- |
| Whitepaper    | <https://static.hemi.xyz/whitepaper.pdf> |
| Blog          | <https://hemi.xyz/blog/>                 |
| Documentation | <https://docs.hemi.xyz/>                 |
| Store         | <https://hemi.store/>                    |
| Status        | <https://hemistatus.com/>                |

### Apps

|                        |                                                   |
| ---------------------- | ------------------------------------------------- |
| Hemi Portal            | <https://app.hemi.xyz/>                           |
| Hemi Tunnel            | <https://app.hemi.xyz/tunnel/>                    |
| Hemi Staking           | <https://app.hemi.xyz/staking-dashboard/>         |
| Mainnet Block Explorer | <https://explorer.hemi.xyz/>                      |
| Testnet Block Explorer | <https://testnet.explorer.hemi.xyz/>              |
| Pure Finance           | [https://pure.finance/](https://pure.finance/en/) |

### Social Media

| Discord     | <https://discord.gg/hemixyz>                    |
| ----------- | ----------------------------------------------- |
| Farcaster   | <https://warpcast.com/hemi-xyz>                 |
| GitHub      | <https://github.com/hemilabs>                   |
| LinkedIn    | <https://linkedin.com/company/hemi-labs>        |
| Luma        | <https://luma.com/calendar/cal-tg3QUCo7fvXUnle> |
| X (Twitter) | <https://x.com/hemi_xyz>                        |
| YouTube     | <https://youtube.com/@HemiLabs>                 |

### Official Domains

{% hint style="danger" %}
Below is a list of our official domains. Any domains not listed here are third-party and **are not operated, owned, or affiliated with Hemi Labs.** **Beware of malicious sites claiming to represent Hemi.**
{% endhint %}

| `hemi.xyz`       | Hemi websites and applications |
| ---------------- | ------------------------------ |
| `hemi.network`   | API and RPC nodes              |
| `hemistatus.com` | Hemi status page               |


# Brand Kit

This page features the official Hemi logos, symbols, and colors for media use.

Visit <https://hemi.xyz/brand-kit> to view the full Hemi Brand Kit.

***

## Visual Style Guide

Hemi's Visual Style Guide provides guidelines and a standard for the visual of the Hemi brand. We recommend using this document as a starting point for the Hemi brand.

{% file src="/files/vK621xArZlHkTben9XuC" %}

***

## Token logos

{% file src="/files/XwSAuhL06rjbP3HQXjZM" %}

{% file src="/files/OPOYsRgKcfgAyhSPQpKF" %}

{% file src="/files/2Piu2wApPcf5EMowrKp3" %}

{% file src="/files/fw15j3SFfw0l6V3taNm6" %}


# Support and Bug Reports

How to get help, report bugs, and disclose security vulnerabilities to Hemi.

### Getting Help

| Issue                                             | Where to report                                                                                                                                                                       |
| ------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| General support                                   | <p><a href="https://discord.gg/hemixyz">Hemi Discord</a> — <code>#support</code> or <code>#create-ticket</code><br>Email <a href="mailto:support@hemi.xyz"><support@hemi.xyz></a></p> |
| Partnership inquiries                             | Email <partners@hemi.xyz>                                                                                                                                                             |
| Bugs in Hemi services (app, explorer, etc.)       | [Hemi Discord](https://discord.gg/hemixyz) — `#create-ticket`                                                                                                                         |
| Bugs or feature requests for open-source software | Open a [GitHub Issue](https://github.com/hemilabs) on the relevant repository                                                                                                         |
| Security vulnerabilities                          | [See below](#security-vulnerabilities)                                                                                                                                                |

### Security Vulnerabilities

If you've found a security vulnerability in Hemi, we want to hear about it.

{% hint style="danger" %}
**Do not** test against production systems, disclose vulnerabilities publicly, or report them in GitHub issues. Doing so puts users at risk, may violate applicable law, and will disqualify you from rewards.\
\
Denial-of-service testing, social engineering, and volumetric attacks are explicitly out of scope and prohibited. **All security research must be conducted in accordance with the policies outlined in our** [**Bugcrowd program**](https://bugcrowd.com/engagements/hemi)**.**
{% endhint %}

#### How to Report

All vulnerability reports **must** be submitted through our official [Vulnerability Disclosure Program on Bugcrowd](https://bugcrowd.com/engagements/hemi). We do not accept vulnerability reports via email, Discord, social media, or any other channel. Reports submitted outside of Bugcrowd will not be reviewed or eligible for rewards.

When reporting, the more information you can provide, the faster we can triage and confirm the vulnerability. Reports with clear reproduction steps and screenshots are highly valued.

#### Bug Bounty Program

Hemi also operates a private Bug Bounty program on Bugcrowd with paid rewards. Researchers who submit high-quality reports through our Vulnerability Disclosure Program may be invited to participate at Hemi's discretion.

#### Responsible Disclosure

Please do not discuss any vulnerabilities outside our Bugcrowd program without express consent from Hemi Labs. Follow our [program disclosure policy](https://bugcrowd.com/engagements/hemi) for full details.

Hemi provides Safe Harbor for security research conducted in good faith under our program policy. See the full Safe Harbor terms on our [Bugcrowd program page](https://bugcrowd.com/engagements/hemi).

{% hint style="info" %}
For other security-related questions or concerns, please contact <security@hemi.xyz>.
{% endhint %}


# Welcome

Welcome to the Hemi Developer documentation! We're still working on this pages, so check back soon!


# Introduction

Welcome to the Hemi Community documentation! Here you will find everything related to the Hemi Community.


# Community 2.0

Below is all announced changes to the Hemi Community on April 29th, 2026. Big changes coming soon!

## The Hemi Guild

**Launching to Beta Testers, Builders, and Creatives very soon!**

{% hint style="info" %}
*Unfortunately due to some unforeseen issues with Guild, we have had to delay the initial beta launch until they're able to resolve a couple of bugs. We'll be providing an updated timeline as soon as possible!*
{% endhint %}

**We are pleased to officially announce the launch of the Hemi Guild!** You've heard us mention it before, but here's the official details.

The Hemi Guild is an ever-growing collection of tasks rewarding activity on and around Hemi. With specialised roles for Builders, Creatives, and on-chain activity, you can choose your own path and complete tasks to earn rewards!

Each month, we will release new tasks, including some exclusive limited-time tasks. To earn the most points, you must complete as many tasks as possible. The harder the task, the more rewards!

At the end of each month, the top 25 Hemigos on the leaderboard will share a monthly prize pool. More details on the reward system coming soon!

During the early access period, we will be taking feedback and using it to ensure everything is balanced and properly tested ahead of public release. Unless serious bugs are encountered, we expect to launch publicly in the following weeks.

[***More documentation coming soon here!***](/community/guild/introduction)

## Teach Rick Crypto

**Launching May 14th, 2026.**

We recognise that people come into crypto from many different backgrounds and at a variety of different levels. There are no shortage of tutorials out there, but very few of them truly take this into account and approach learning from a fun and beginner-friendly angle.

With our new **Teach Rick Crypto** series, we will take that problem head on by starting from the very beginning and covering the important concepts in crypto and around Hemi, in what we hope is a fun and approachable format. And Rick learns Crypto. Win-win.

This series will be launched on the new **Hemigo TV** channel starting May 14th, with new episodes released monthly.

## Hemigo TV

**Starting May 14th, 2026.** [Preview the channel here!](https://www.youtube.com/@HemigoTV)

**Introducing Hemigo TV**, our new community-focused YouTube channel, which will be the new ground for new community-focused content.

Hemigo TV will host community focused and created content, such as guides, tutorials, promotional videos, and all things Hemigos. **We encourage all Hemi creators to participate so this channel becomes BY the community FOR the community.**

If you want to contribute a video to Hemigo TV, contact us on Discord!

{% hint style="info" %}
All community-created videos will undergo a review process by our Community Moderation team, as well as members of the Hemi Community team. Only high quality educational content will be published.
{% endhint %}

## Discord Activities 2.0

**Starting May 4th, 2026.**

As much as we love Smash Karts and GeoGuesser, we realise these activities don't promote growth around the Hemi Network. Going forward, we will be shifting all activities to SOLELY focus on games and activities built on Hemi.

At launch, we will be including the following community-built games:

* [Hemi Heads by Gladiy](https://www.hemiheads.xyz/)
* [HAIR Games by Alix and Alpha](https://game.hairtoken.xyz/)

**Compete with fellow Hemigos and win your share of a veHEMI prize pool and some cool swag!**

We encourage all builders to create the next great game or activity on the Hemi Network, and if loved by the Hemi community, it may be included in future activities!

## Protocol Engineering Office Hours

**Starting May 6th at** [**11:00 EDT (15:00 UTC)**](https://sharetime.zone/UTC/1500)**.**

**Weekly on Wednesday, alternating between Morning and Afternoon each week:**

* Morning office hours at [**11:00 EDT / 15:00 UTC**](https://sharetime.zone/UTC/1500) (click to view in your timezone).
* Afternoon office hours at [**12:00 EDT / 16:00 UTC**](https://sharetime.zone/UTC/1600) (click to view in your timezone).

To help encourage building on Hemi, we plan on having a hour-long weekly office hours event, with at least one team member from Hemi's Protocol Engineering team, to answer Builder's technical questions, discuss ideas, or anything else that would help Builders and Creators bring their work to Hemi. Open to anyone to participate!

Engineering participants will vary week-to-week depending on availability. We will be accepting questions ahead of time, as well as having live discussions between team members and the community. The stage will be open if anyone wants to share their ideas for building on Hemi!

## Midweek with Max

**Every Tuesday at** [**11:00 ET /** **15:00 UTC**](https://sharetime.zone/EDT/1100)**.**

While Discord has always been home to our community, and the central place for all things Hemi, we have made the discussion to move Midweek with Max to YouTube, X, and LinkedIn starting **May 5th, 2026.** This will allow us to further grow the event and bring more new people and ideas to Hemi.

Midweek with Max originally started as "Hemi Weekly" on **October 8th, 2024!** We wanted a way to keep the community up-to-date with what the team was doing, and it worked!

Since then, we have done **128 Midweek with Max events** and answered more questions than we can count from hundreds of participants.

As we move to YouTube, X, and LinkedIn, the format of Midweek with Max will stay the same. We will share updates from the Hemi team, and answer your questions, make jokes, and have a good time. The new platform allows us to utilise new abilities, including cameras, screen sharing, and a new soundboard for Rick to use as he pleases.

**Watch May 5th's Midweek with Max here:**

* X (previously Twitter): <https://x.com/hemi_xyz>
* YouTube: <https://www.youtube.com/watch?v=XU4HXI6Tvq0>

## Zorkified

**Coming Q2/Q3 2026.**

This year, we're kicking off a new community project called Zorkified.

At its core, Zorkified is a modern take on a classic: a Zork-style text adventure game — exploration, puzzles, rooms, items, progression — built from the ground up in Python.

In this series, we will be building a modular, extensible game engine step-by-step, in a way that is understandable, testable, and actually usable beyond a single demo.

And yes, this will extend on to the Hemi blockchain.

We will be starting with the game itself, getting the foundation right, and then layering in blockchain functionality in a deliberate, engineered way. We're building a real engine and taking no shortcuts, so if you're hoping for `print("hello world")`, you will be disappointed.

### How will this work?

Zorkified will be created as a live, multi-month course, with a recorded companion version available for anyone who wants to follow along or go deeper at their own pace.

Each session will build directly on the last and is a continuous progression where, by the end, you will have a working game composed of multiple interacting subsystems.

We expect a mixed audience of:

* Beginners, who want to learn by building something
* Intermediate developers looking to strength fundamental skills
* Experienced engineers who want to experiment and build something fun

This course is designed to support all three without slowing to a crawl or flying over people's heads, and will not expect deep Python experience.

***More detailed information coming June 2026.***


# Introduction

Coming soon!


