Counterparty Development 101

Dan Anderson
2 min readApr 4, 2018

--

Counterparty is NOT a blockchain.

What is Counterparty?

Counterparty is a protocol and network of nodes that reads and writes data to the Bitcoin blockchain using bitcoin txs and a standardized message format. Off-chain, Counterparty nodes validate this embedded data and compute the current state of the network, with each new block.

Embedded Consensus

Counterparty nodes maintain identical ledgers without using a P2P network specific to Counterparty because they are running the same Counterparty software to enforce protocol rules and piggy-backing on Bitcoin’s Proof-of-Work for tx ordering and propogation. This is known as embedded consensus.

Federated Nodes

A Federated Counterparty Node is a Bitcoin Full Node that uses AddrIndex and runs counterparty-lib software. Counterparty is coded primarily in Python using a SQLite database. Counterparty tracks balances using bitcoin addresses as “accounts” and credits and debits account balances when executing valid protocol messages.

Node Interfaces

Counterparty Node Operators have two interface options: CLI and API. The CLI and JSON-RPC API are both well documented. And it’s not necessary to know Python to interface with either of these options.

Smart Contracts

You can think of each Counterparty message as a standardized input to a hard-coded smart contract which differentiates Counterparty from other platforms, like Ethereum, where users write their own smart contract code. Rather than users rolling their own code and using different approaches for common actions, Counterparty standardizes common actions as features.

Improvements

Counterparty can be upgraded to include new smart contracts, if they gain enough consensus and are deemed to be an improvement through the CIP process. This usually requires a hard-forking upgrade where every node must upgrade to the new software version to maintain the same network state.

Getting Started

The easiest way to get started is to read the API documentation and play around with the Public Development API hosted by Coindaddy.io (link below). The counterparty-lib code is also extremely readable with each smart contract having a standard format: database schema, validation, parsing, etc.

Background

Here are two videos from two of the Founders of Counterparty that give both a conceptual and a technical overview of the project.

Resources

CODE

Github:
https://github.com/CounterpartyXCP
Reference Implementation: https://github.com/CounterpartyXCP/counterparty-lib

CONTRIBUTING

Contributing:
https://counterparty.io/docs/contributing/
CIP Process:
https://github.com/CounterpartyXCP/cips
Bug Bounties:
https://counterparty.io/docs/bounties/

DOCS

Setup a Federated Node:
https://counterparty.io/docs/federated_node/
Counterparty CLI:
https://counterparty.io/docs/cli/
Counterparty API:
https://counterparty.io/docs/api/
Counterblock API:
https://counterparty.io/docs/counterblock_api/

RESOURCES

Platform Architecture:
https://counterparty.io/docs/platform_architecture/
Public Federated Node API:
https://coindaddy.io/public-development-servers
Counterparty Explorer (Mainnet):
https://xchain.io/
Counterparty Explorer (Testnet):
https://testnet.xchain.io/

COMMUNITY

Telegram:
https://t.me/Counterparty_XCP
Slack:
https://counterparty.slack.com/
Discord:
https://discord.gg/TjHu2xH
Counterparty Talk Forum:
https://counterpartytalk.org/

FAQ

AddrIndex:
https://counterpartytalk.org/t/what-is-addrindex-and-why-is-it-necessary/1202
How to Start:
https://counterpartytalk.org/t/how-do-i-get-started-developing-on-counterparty/1198
Insufficient BTC:
https://counterpartytalk.org/t/what-does-insufficient-btc-at-address-x-need-approximately-y-btc-mean/2442

--

--