Getting Started

This guide will help you set up your environment and start building with our Ethereum Layer 2 solution that integrates Bitcoin functionality. You'll be up and running in no time!

Prerequisites

Before you begin, make sure you have the following installed:

  • Rust and Cargo (latest stable version)

  • A Bitcoin node (regtest)

Step 1: Install Corsa

  1. Clone the Corsa repository:

    1. git clone COMING SOON!!
      cd corsa
  2. Build the project:

    1. cargo build --release

Step 2: Configure Your Environment

  1. Set up your Bitcoin node (if not already running).

    1. Use the Corsa demo node at <https://regtest.oncorsa.com:18334>. This is a full regtest node any developer can use.

      1. Username: rpcusername

      2. Password: rpcpassword

    2. btc-dev-utils is a quick way to spin up a dev environment.

      1. Install dependancies with just install-deps

      2. Build with Cargo just build

      3. Create a configuration file settings.toml in the btc-dev-utils project root:

        1. network = "regtest" # use "testnet" for testnet3 and "mainnet" for Bitcoin mainnet
          network_url = "http://127.0.0.1"
          bitcoin_rpc_username = "your_rpc_username"
          bitcoin_rpc_password = "your_rpc_password"
          create_wallets = true
      4. Run a local Bitcoin Regtest chain with just start-bitcoind

Step 3: Run Corsa Node

Start your Corsa node using the following command:

cd corsa
just run-chain --btc-network "regtest" --network-url "http://127.0.0.1" --btc-rpc-username "your_rpc_username" --btc-rpc-password "your_rpc_password"

Your node should now be running and connecting to the specified Bitcoin network. You can test the connection by getting the current block height.

cd corsa
just get-block-height

Step 4: Interact with Corsa

You can interact with Corsa using web3.js or ethers.js libraries. Here's a quick example using ethers.js:

const { ethers } = require("ethers");

const provider = new ethers.providers.JsonRpcProvider("http://localhost:8545");
const signer = provider.getSigner();

// Example: Calling a Bitcoin precompile
const BITCOIN_PRECOMPILE_ADDRESS = "0x0000000000000000000000000000000000000999";

async function getBitcoinBlockCount() {
  const data = "0x00000001";  // Method selector for get_block_count
  const result = await signer.call({
    to: BITCOIN_PRECOMPILE_ADDRESS,
    data: data
  });
  return ethers.BigNumber.from(result).toNumber();
}

getBitcoinBlockCount().then(console.log);

Next Steps

Now that you have Corsa up and running, you can:

Explore our API documentation to learn about all available Bitcoin precompiles. Deploy your own smart contracts that interact with Bitcoin functionality. Join our community forums to connect with other developers and get support.

Happy building with Corsa!

Last updated