Skip to content

scalarorg/scalar-contracts

Repository files navigation

Scalar Contracts

Smart contracts for the Scalar Protocol, enabling cross-chain Bitcoin bridging using Axelar's General Message Passing (GMP).

Overview

The Scalar Protocol consists of the following main components:

  • ScalarToken: An ERC20 token representing bridged Bitcoin
  • Protocol: Core contract handling cross-chain messaging and token minting/burning
  • Axelar Integration: Uses Axelar's GMP for secure cross-chain communication

Prerequisites

Installation

  1. Clone the repository:
git clone https://github.com/scalar-network/scalar-contracts.git
cd scalar-contracts
  1. Install dependencies:
bun install

Environment Setup

Create a .env file in the root directory with the following variables:

PRIVATE_KEY=
ANVIL_RPC_URL=
SEPOLIA_RPC_URL=
API_KEY_ETHERSCAN=

Testing

Run all tests:

make test-all

Run specific test:

make test <test-file>

How to deploy

  1. Default deployment:
make deploy
TOKEN_NAME TOKEN_SYMBOL REDEPLOY_AXELAR
Scalar BTC sBTC true
  1. Custom deployment:
make deploy TOKEN_NAME="Pool BTC" TOKEN_SYMBOL="pBTC" REDEPLOY_AXELAR=false

The deployment script will automatically detect if you're using a local network (Anvil) on http://localhost:8545 or a testnet (Sepolia) and deploy accordingly.

Local Development

Start a local Anvil node:

make anvil

More details Makefile.

Contract Architecture

ScalarToken

  • ERC20 token with minting and burning capabilities
  • Controlled by owner and protocol contract
  • Used to represent bridged Bitcoin

Protocol Contract

  • Handles cross-chain message passing via Axelar
  • Manages token minting and burning
  • Processes Bitcoin PSBT (Partially Signed Bitcoin Transactions)

License

This project is licensed under the MIT License - see the LICENSE.md file for details.