Installation
cairn is available for five languages. Pick yours and follow the steps below.
Prerequisites
| Language | Version | Package Manager | Install Command |
|---|---|---|---|
| Rust | 1.75+ | Cargo | cargo add cairn-p2p |
| TypeScript | Node 18+ | npm | npm install cairn-p2p |
| Go | 1.24+ | Go modules | go get github.com/moukrea/cairn/packages/go/cairn-p2p |
| Python | 3.11+ | pip | pip install cairn-p2p |
| PHP | 8.2+ | Composer | composer require moukrea/cairn-p2p |
Install
- Rust
- TypeScript
- Go
- Python
- PHP
cargo add cairn-p2p
npm install cairn-p2p
go get github.com/moukrea/cairn/packages/go/cairn-p2p
pip install cairn-p2p
composer require moukrea/cairn-p2p
Verify Your Installation
Create a node and print your peer ID to confirm everything is working:
- Rust
- TypeScript
- Go
- Python
- PHP
use cairn_p2p::{Node, CairnConfig, create};
let node = create(CairnConfig::default())?;
node.start().await?;
println!("Peer ID: {}", node.peer_id());
import { Node } from 'cairn-p2p';
const node = await Node.create();
console.log(`Peer ID: ${node.peerId}`);
import cairn "github.com/moukrea/cairn/packages/go/cairn-p2p"
node, err := cairn.Create()
if err != nil { log.Fatal(err) }
fmt.Println("Peer ID:", node.PeerID())
from cairn import create
node = await create()
print(f"Peer ID: {node.peer_id}")
use Cairn\Node;
$node = Node::create();
echo "Peer ID: " . $node->peerId() . "\n";
Common Issues
- Rust
- TypeScript
- Go
- Python
- PHP
- Minimum edition: cairn requires Rust edition 2021 or later. Make sure your
Cargo.tomlhasedition = "2021"or newer. - Async runtime: cairn uses Tokio. Ensure you have
tokioas a dependency with thefullfeature enabled.
- Node version: cairn requires Node.js 18 or later. Run
node --versionto check. - ESM vs CJS: cairn ships as ESM. If your project uses CommonJS, you may need to adjust your
tsconfig.jsonor use dynamicimport().
- Module proxy: If
go getfails, try settingGOPROXY=https://proxy.golang.org,direct. - Go version: cairn requires Go 1.24+. Run
go versionto check.
- Async required: cairn uses
async/await. You need Python 3.11+ and an async runtime likeasyncio. - Virtual environment: It is recommended to install cairn inside a virtual environment (
python -m venv .venv).
- PHP version: cairn requires PHP 8.2+. Run
php --versionto check. - FFI extension: cairn uses PHP FFI to call the native Rust core. Make sure the
ffiextension is enabled in yourphp.ini.