Deploy contract

Here are the steps for the developers to start their journey with the SatsChain ecosystem. We will cover everything from setting bitcoin nodes to send/receive transactions (inscriptions) and showing the latest state to the user via DApp.

The guide includes

  1. Run Bitcoin node with inscriptions/Ordinals

  2. Sats Intel and Sats Nuclei

  3. Build your smart contract logic

  4. Leverage Compass library for Bitcoin compatibility

  5. Deploy smart contract on Bitcoin

  6. Build your DApp and interact with contract

  7. Visualize the latest state of your contract

1. Run Bitcoin node with inscriptions/Ordinals

Inscriptions allow individual sats to be embedded with arbitrary data, turning them into Bitcoin-native digital artifacts. These inscriptions are fully durable, immutable, secure, and decentralized. To manage inscriptions, a Bitcoin full node and an ord wallet is required. The steps mentioned below are referred from Casey’s Ordinal theory and mentioned within the scope of SatsChain utility.

Installing Bitcoin Core

Bitcoin Core is available from bitcoincore.org on the download page.

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

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

Syncing the Bitcoin Blockchain

To sync the chain, run: bitcoind -txindex

Leave it running until getblockcount: bitcoin-cli getblockcount agrees with the block count on a block explorer like the mempool.space block explorer. ord interacts with bitcoind, so you should leave bitcoind running in the background when you're using ord.

Installing ord

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

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

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

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.

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

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

Content: https://docs.ordinals.com/guides/wallet.html

2. 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 environment 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 modules together to avail Smart contract functionalities on Bitcoin.

Our team is doing incremental rollout of the codebase of SatsIntel and SatsNuclei which will eventually be open-sourced. Kindly contact the team at query@satz.one 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.

3. Build your smart contract logic

Download or Implement a Contract; Implement your own contract OR obtain a contract from a reliable source. The main motive of using Solidity as programming language is to make it easy for developers to take inspiration from existing innovation on EVM compatible blockchains.

Once the code is developed, ensure the contract is flattened into a single file. Flattening combines all the code dependencies into one file, simplifying the deployment process.

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 smart contract on Bitcoin

Begin by ensuring that your unisat wallet is set to the correct network and using either of taproot/native segwit addresses. Since SatsChain is presently operational only on the testnet, switch your wallet's network setting to testnet. Connect your wallet to the SatsChain DApp and authorize the connection.

Navigate to the SatsChain DApp and find the "Deploy Smart Contract" option. As the next step, follow the instructions mentioned below:

  1. Copy paste your code in the dialog box

  1. Click on Compile

  1. Choose the contract you want to deploy from the code

    1. 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.

Click on next to sign the data with your wallet key

  1. Choose the gas fees

  1. Click on inscribe

Note: Kindly ensure to use unisat wallet with taproot or native segwit wallet address to deploy the contract. Also, make sure to have appropriate gas fees.

6. Build your DApp

As you delve deeper into utilizing SatsChain, you'll find it essential to listen to events to monitor and track transactions on your contract or even to build your own decentralized application (DApp). You can take inspiration from existing opensource DApp source codes or build your own from scratch. It requires expertise in frontend technologies (react js etc) and JSON RPC integration. Kindly get in touch with SatsChain team over twitter in case any help is required.

7. Visualize the latest state on Explorer or your DApp

Once deployed, your contract can be visualized and interacted with using the SatsChain’s Explorer or your own DApp. SatsChain Explorer allows you to monitor your contract's transactions and activities in real-time.

To utilize SatsChain Explorer, install a compatible wallet such as Unisat. Connect your wallet to the SatsChain Explorer by selecting the appropriate network (currently testnet). Then, use the search bar on the explorer to enter the contract address or name. Access the contract details page to view information such as contract address, creator, creation date, and transactions associated with the contract.

If you have verified your source code on SatsChain Explorer, then you can read and write the contract directly from SatsChain Explorer as well. Locate read and write functions on the contract details page. Call read functions to retrieve data from the blockchain without any gas fees. Call write functions to change the state of the blockchain, requiring gas fees.

Confirm transactions via your wallet and monitor their status through the explorer. Once your transactions are confirmed, you can view transaction details, including block number, gas used, and status (pending, confirmed, or failed), and check event logs for detailed information about contract activity and transaction outcomes.

Alternatively, you can utilize your DApp and integrate JSON RPC of the Sats Intel/nuclei module to fetch the latest state and utilize the BTC inscription node to send the transactions.

Last updated