Satz
  • πŸ‘‹Welcome
  • 🀝Introduction
    • What is SatsChain?
    • How is SatsChain different from L2s?
    • What is the security paradigm for SatsChain?
  • πŸ“‡Use Cases
    • Cerebrum (Retail use cases)
    • Institutional use cases
    • Anchoring L2s on BTC
  • πŸ–₯️For Developers
  • πŸ“Smart Contracts
    • What is smart contract?
    • Build a Contract
    • Leverage Compass Library for contracts
    • What type of contracts can be supported?
  • πŸ”Contract Deployment
    • Deploy smart contract on SatsChain
  • ⛓️Core Principles
    • What are Inscriptions?
    • Taproot/native-segwit user addresses
    • What is EVM?
    • What is Solidity?
    • How BTC connects with EVM?
  • πŸ› οΈSats Infrastructure
    • Leveraging OP_RETURN
    • Sats Intel
    • Sats Nuclei
    • Sats Reverse Processor (SRP)
    • Sats connector
    • Compass (EVM <> BTC)
      • Compass Solidity Library
      • Compass Logic
      • Rainbow table
  • βš™οΈConfigurations
    • Testnet
    • Mainnet
  • πŸ“šDeveloper Guide
    • Deploy contract
    • Anchoring of L2s
    • How to interact with Smart Contract?
    • Fetching current state via JSON RPC integration
    • How to integrate compass library in solidity code
  • Website
  • WhitePaper
  • Twitter
Powered by GitBook
On this page
  • 1. Run Bitcoin node with inscriptions/Ordinals
  • Creating Inscriptions
  • 2. Deploy Sats Intel and Sats Nuclei
  • 3. Develop L2 Rollup contracts
  • 4. Leverage Compass library for Bitcoin compatibility
  • 5. Deploy rollup contract on Bitcoin
  • 6. Periodic updates on rollup contract
  1. Developer Guide

Anchoring of L2s

PreviousDeploy contractNextHow to interact with Smart Contract?

Last updated 10 months ago

This document provides a comprehensive guide for developers to start their journey with the SatsChain ecosystem, focusing on how to anchor your Layer 2 (L2) solutions on SatsChain. We'll cover everything from setting up your environment to deploying and managing L2 rollups.

The guide includes

  1. Run Bitcoin node with inscriptions/Ordinals

  2. Deploy Sats Intel and Sats Nuclei

  3. Develop L2 Rollup contracts

  4. Leverage Compass library for Bitcoin compatibility

  5. Deploy rollup contract on Bitcoin

  6. Periodic updates on rollup contract

1. Run Bitcoin node with inscriptions/Ordinals

Inscriptions allow individual sats to be embedded with content, turning them into Bitcoin-native digital artifacts. These inscriptions are as durable, immutable, secure, and decentralized as Bitcoin. To manage inscriptions, a Bitcoin full node and a specialized ord wallet are required.

Installing Bitcoin Core

Bitcoin Core is available from on the.

Making inscriptions requires Bitcoin Core 24 or newer.

This guide does not cover installing Bitcoin Core in detail. Once Bitcoin Core is installed, you should be able to run bitcoind -version successfully from the command line. Do NOT use bitcoin-qt.

Configuring Bitcoin Core

ord requires Bitcoin Core's transaction index and rest interface.

To configure your Bitcoin Core node to maintain a transaction index, add the following to your bitcoin.conf:

txindex=1

Or, run bitcoind with -txindex:

bitcoind -txindex

Syncing the Bitcoin Blockchain

To sync the chain, run:

bitcoind -txindex

…and leave it running until getblockcount:

bitcoin-cli getblockcount

Installing ord

You can install the latest pre-built binary from the command line with:

curl --proto '=https' --tlsv1.2 -fsLS https://ordinals.com/install.sh | bash -s

Once ord is installed, you should be able to run:

ord --version

Which prints out ord's version number.

Creating a Wallet

bitcoind -txindex

and

ord server

To create a wallet named ord, the default, for use with ord wallet, run:

ord wallet create

This will print out your seed phrase mnemonic, store it somewhere safe.

{
  "mnemonic": "dignity buddy actor toast talk crisp city annual tourist orient similar federal",
  "passphrase": ""
}

If you want to specify a different name or use an ord server running on a non-default URL you can set these options:

ord wallet --name foo --server-url http://127.0.0.1:8080 create

Creating Inscriptions

To create an inscription with the contents of FILE, run:

ord wallet inscribe --fee-rate FEE_RATE --file FILE

Ord will output two transactions IDs, one for the commit transaction, and one for the reveal transaction, and the inscription ID. Inscription IDs are of the form TXIDiN, where TXID is the transaction ID of the reveal transaction, and N is the index of the inscription in the reveal transaction.

The commit transaction commits to a tapscript containing the content of the inscription, and the reveal transaction spends from that tapscript, revealing the content on chain and inscribing it on the first sat of the input that contains the corresponding tapscript.

Once the reveal transaction has been mined, the inscription ID should be printed when you run:

ord wallet inscriptions

Sending Inscriptions

Ask the recipient to generate a new address by running:

ord wallet receive

Send the inscription by running:

ord wallet send --fee-rate <FEE_RATE> <ADDRESS> <INSCRIPTION_ID>

See the pending transaction with:

ord wallet transactions

Once the send transaction is confirmed, the recipient can confirm receipt by running:

ord wallet inscriptions

2. Deploy Sats Intel and Sats Nuclei

Sats Intel and Sats Nuclei are the two core modules that are required to compute the latest state by interpreting Bitcoin transactions. These modules need not be part of any ring or consensus participation. These can be run independently to compute the state of transactions on its own.

Sats Intel

Sats Intel is the core intelligence module within the SatsChain ecosystem. It is responsible for converting signed SatsChain transactions into EVM transactions and executing them on Sats Nuclei. The module ensures the seamless integration and operation of smart contracts on the Bitcoin blockchain. It also includes an internal compass module which converts all the native segwit/taproot/inscription architecture to hex address for EVM to understand and run the transactions.

Sats Nuclei

Stas Nuclei is a customized EVM node for the ecosystem. It provides the Ethereum Virtual Machine (EVM) execution environment and state storage for the Bitcoin blockchain. It ensures that all smart contract transactions from Sats Intel are executed properly. Sats Nuclei leverages a custom Besu node with several modifications and customization to suit SatsChain's needs.

It becomes mandatory to run both the Sats Intel and Sat Nuclei nodes connected together to avail Smart contract functionalities on Bitcoin.

3. Develop L2 Rollup contracts

Implement an L2 Contract on SatsChain; Your contract type and functionality will differ based on the kind of RollUp you aim to build.

Optimistic Rollups

  1. Batch Transactions: Group multiple transactions into a single batch.

  2. Post State Roots: Submit the state root of the batch to SatsChain.

  3. Implement Fraud Proofs: Ensure a system for generating and verifying fraud proofs.

Zero-Knowledge (ZK) Rollups

  1. Develop Zero-Knowledge Proof Mechanisms: Create cryptographic proofs for batched transactions.

  2. Batch Transactions: Group transactions and generate zero-knowledge proofs.

  3. Post Proofs to SatsChain: Submit proofs to validate the transactions.

4. Leverage Compass library for Bitcoin compatibility

As we know BTC has segwit and taproot addresses, while EVM addresses are 160-bit hexadecimal numbers. Both of which are ideally incompatible with each other, so we required an address conversion module that would allow, EVM (Sats Nuclei) to understand the addresses referenced in the Smart contract and Sats Intel to receive transactions and send results back with corresponding EVM addresses converted back to BTC addresses.

The Compass Module within the SatsChain ecosystem is designed to bridge this gap between Bitcoin's native infrastructure and the Ethereum Virtual Machine (Sats Nuclei), enabling seamless interoperability and smart contract functionality on the Bitcoin blockchain.

The compass library (a part of the Compass module) is essentially a Solidity contract, that allows users to perform address conversions at runtime inside their EVM Smart Contracts. You should leverage this library to convert BTC addresses in your solidity contract to EVM addresses at runtime, before using them.

5. Deploy rollup contract on Bitcoin

If your smart contract requires constructor parameters, input these values in the designated fields. Initialize gas_price and gas_limit for your contract, and ensure that you are paying enough fee rate in BTC on your inscription.

With all these formalities out of the way, you are good to deploy.

6. Periodic updates on rollup contract

To periodically write updates on the batch contract, you need to prepare the L1 transaction in the format required by SatsChain execution layer. You can either leverage SatsChain DApp UI to help you facilitate that OR you can get in touch with SatsChain team over mail or twitter to help you out with the steps to construct these transactions. We even support Blob-type transactions for L2s to push their large batches on Bitcoin.

Once a transaction is created with the relevant format, it needs to be sent to BTC network as an inscription with the necessary attributes. After the transaction gets mined on Bitcoin, it will be picked by Sats Intel & Sats Nuclei modules and will update the state of your rollup contract. You can also see the changes, due to your transaction, in effect on SatsChain Explorer.

Details on creating or modifying your bitcoin.conf file can be found.

agrees with the block count on a block explorer like. ord interacts with bitcoind, so you should leave bitcoind running in the background when you're using ord.

The ord utility is written in Rust and can be built from. Pre-built binaries are available on the.

ord uses bitcoind to manage private keys, sign transactions, and broadcast transactions to the Bitcoin network. Additionally the ord wallet requires running in the background. Make sure these programs are running:

Wait for the reveal transaction to be mined. You can check the status of the commit and reveal transactions using.

Content:

Our team is doing incremental rollout of the codebase of SatsIntel and SatsNuclei which will eventually be open-sourced. Kindly contact the team at in case you need to run these modules for your usecase. Alternatively, you can get API keys from the team by requesting over the mail for quick integration and reduced TAT for running your DApps.

Arbitrum is one of the Optimistic rollups on Ethereum, you may like to learn more about it . Similarly, an example of a Zero-Knowledge rollup is ZKSync, learn more about it .

For your L2, there can be a bunch of contracts with each contract catering to a particular usecase. The exact codebase will depend on the nature of the rollup and the architecture you have designed for your L2. You may get in touch with SatsChain team at to help you out in designing the contracts for anchoring.

Begin by ensuring that your cryptocurrency wallet is set to the correct network. Since SatsChain is presently operational only on the testnet, switch your wallet's network setting to testnet. Connect your wallet to the SatsChain and authorize the connection.

Navigate to the SatsChain and find the "Deploy Smart Contract" option. In the deployment interface, paste your flattened Solidity contract.

Once deployed, your L2 contract on SatsChain can be visualized and interacted with using the SatsChain’s . This tool allows you to monitor your contract's transactions and activities in real-time.

For further help, do reach us out at

πŸ“š
bitcoincore.org
download page
here
the mempool.space block explorer
source
releases page
ord server
the mempool.space block explorer
https://docs.ordinals.com/guides/wallet.html
query@SatsChain.xyz
here
here
query@SatsChain.xyz
DApp
DApp
Explorer
query@SatsChain.xyz