Run and Build a Runes Bridge to Bitcoin: Developer Guide
![](https://blog.rootstock.io/wp-content/uploads/2024/03/Frame-6.png)
This article is part of the “Bitcoin Developer Journey” series exploring different steps and guides for developers who want to dip their toes in the Rootstock ecosystem and start building DeFi on Bitcoin.
RootstockLabs, a key contributor to the growth of the Rootstock ecosystem, has recently announced the development of a new Runes Toy Bridge on Rootstock. This new Runes bridge allows devs to build their own Runes-focused applications on Rootstock with 3 proposed solutions to build atop (bridge, marketplace, giveaway engine).
In this article, we dive into the technical details of how to start building and running a bridge to Bitcoin using the new Runes Toy Bridge.
What are Runes you say?
Simply put, Runes is a new protocol standard simplifying the creation of fungible tokens on the Bitcoin blockchain. This provides Bitcoin with an additional token-issuance mechanism, bringing with it a set of new use cases.
Read the details in this in-depth article.
And now…
Runes Mock Bridge
This project is an open-source proof of concept implementing a Runes Mock Bridge. The primary goal is to allow users to etch (and eventually mint) Runes on the Bitcoin network and create a 1:1 representation of these Runes as ERC1155 tokens (Non-fungible initially) on the Rootstock network, manage the runes in the Rootstock network and then take it back to BTC.
Overview
The Runes Mock Bridge consists of various processes:
- Etching Runes on Bitcoin: Users can etch Runes containing data entered through a form. A signer instantiated on Rootstock signs the transaction, creating the Rune without the user needing to sign any transactions directly.
- Creating ERC1155 Representation on Rootstock: Once a Rune is etched on Bitcoin, the system calls an ERC1155 function to mint the Rune on the Rootstock network. The token’s information is based on the user’s input for the Rune. The user receives the specified amount of tokens in a “pre-mine” specified during the Rune creation.
- Transfer, manage, and interact with Rootstock runes representation: Users can transfer, manage, and interact with the ERC1155 representation of the Rune on the Rootstock network.
- Redeeming Runes: Users can redeem the ERC1155 tokens on Rootstock to etch the Rune back on Bitcoin. The system freezes the ERC1155 tokens and sends the Rune back to the user’s Bitcoin address.
Project Structure
Technologies Used
- Bc-runes-js: Bc-runes-js Package
- Hardhat: Hardhat Documentation
- OpenZeppelin Standards: OpenZeppelin
- ShadCN: ShadCN Documentation
- Ethers.js: Ethers.js Documentation
Installation
To clone and run this project locally, follow these steps:
-
Clone the repository:
git clone https://github.com/rsksmart/rsk-runes.git cd rsk-runes
-
Install dependencies:
yarn or npm install
-
Configure environment variables: Create a
.env
file in the root directory and add necessary environment variables. Example:RSK_PROVIDER_URL="https://mainnet.infura.io/v3/YOUR_INFURA_PROJECT_ID" PRIVATE_KEY="your-private-key" NEXT_PUBLIC_APP_PK='your-private-key' NEXT_PUBLIC_RPC_URL='your rsk rpc url' NEXT_PUBLIC_EXPLORER_URL=https://blockstream.info/testnet/tx NEXT_PUBLIC_RSK_EXPLORER_URL=https://explorer.testnet.rootstock.io/tx NEXT_PUBLIC_CONTRACT_ADDRESS='your erc1155 contract address' NEXT_PUBLIC_TAPROOT_ADDRESS='your taproot address' NEXT_PUBLIC_WIF='your wif key'
-
Run the development server:
yarn dev or npm run dev
Usage
- Access the application: Open http://localhost:3000 in your browser.
- Etch a Rune: Navigate to the Etch tab, fill out the form, and submit to etch a Rune on Bitcoin.
- View ERC20 Representation: After etching, view the ERC1155 token details on the Last Etch tab.
Future Development
- Minting Runes: The minting functionality is under development and will be available in future releases.
- Fungible Tokens on Rootstock: The project will support the creation of fungible tokens on the Rootstock network.
Contributing
The core Rootstock team welcomes contributions from the community. Please fork the repository and submit pull requests with your changes. Ensure your code adheres to the project’s main objective.
Disclaimer
The software provided in the GitHub repository is offered “as is,” without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose, and non-infringement.
- Testing: The software has not undergone testing of any kind, and its functionality, accuracy, reliability, and suitability for any purpose are not guaranteed.
- Use at Your Own Risk: The user assumes all risks associated with the use of this software. The author(s) of this software shall not be held liable for any damages, including but not limited to direct, indirect, incidental, special, consequential, or punitive damages arising out of the use of or inability to use this software, even if advised of the possibility of such damages.
- No Liability: The author(s) of this software are not liable for any loss or damage, including without limitation, any loss of profits, business interruption, loss of information or data, or other pecuniary loss arising out of the use of or inability to use this software.
- Sole Responsibility: The user acknowledges that they are solely responsible for the outcome of the use of this software, including any decisions made or actions taken based on the software’s output or functionality.
- No Endorsement: Mention of any specific product, service, or organization does not constitute or imply endorsement by the author(s) of this software.
- Modification and Distribution: This software may be modified and distributed under the terms of the license provided with the software. By modifying or distributing this software, you agree to be bound by the terms of the license.
- Assumption of Risk: By using this software, the user acknowledges and agrees that they have read, understood, and accepted the terms of this disclaimer and assumes all risks associated with the use of this software.
Building on Bitcoin?
Rootstock is the first and longest-lasting Bitcoin sidechain, making it an optimal ground to start building anything on Bitcoin. If this is where you are, you’ll enjoy these developer guides too:
- Have a dApp on Ethereum? Port your EVM dApp to Rootstock with this step-by-step guide.
- You’ll also need RBTC, Rootstock’s native token. Don’t have RBTC? There are numerous ways to get it, read this comprehensive article.
- Learning how to automate workflows? Check out this step-by-step guide to getting started with Gelato’s web3 functions.
Enjoying the content for developers? Head to the Rootstock dev portal for comprehensive guides.