BSV SDK for Elixir

A feature-complete Bitcoin SV SDK for Elixir, ported from the Rust BSV SDK.

Features

Installation

Add to your mix.exs:

def deps do
  [{:bsv_sdk, "~> 0.1.0"}]
end

Quick Start

# Generate a key pair
key = BSV.PrivateKey.generate()
pubkey = BSV.PrivateKey.to_public_key(key)
address = BSV.PublicKey.to_address(pubkey)

# Build a transaction
alias BSV.Transaction.{Builder, P2PKH}

tx = Builder.new()
|> Builder.add_input(txid, vout, satoshis, locking_script, P2PKH.unlock(key))
|> Builder.add_p2pkh_output(recipient_address, amount)
|> Builder.sign()

# Broadcast via ARC
client = BSV.ARC.Client.new(%BSV.ARC.Config{api_key: "your-key"})
{:ok, response} = BSV.ARC.Client.broadcast(client, tx)

# BRC-78 encrypted message
{:ok, ciphertext} = BSV.Message.Encrypted.encrypt(plaintext, sender_key, recipient_pubkey)
{:ok, plaintext} = BSV.Message.Encrypted.decrypt(ciphertext, recipient_key, sender_pubkey)

# STAS token issuance
alias BSV.Tokens.Factory.Stas
{:ok, tx} = Stas.build_issue_tx(config)

Architecture

Layered design with zero framework dependencies:

Test Suite

mix test           # 594 tests
mix test --cover   # ~91% coverage
mix dialyzer       # typespec verification

Production Deployment

License

MIT