This skill should be used when the user asks about "BSV smart contract", "Bitcoin smart contract", "write a smart contract", "create a BSV contract", "use sCrypt", "use Runar", "compile to Bitcoin Script", "stateful contract", "covenant", "OP_PUSH_TX", "escrow contract", "auction contract", "token contract", "deploy smart contract", "test smart contract", or needs to author, compile, test, or deploy Bitcoin SV smart contracts using high-level languages.
From bsv-skillsnpx claudepluginhub b-open-io/claude-plugins --plugin bsv-skillsThis skill is limited to using the following tools:
references/contract-patterns.mdreferences/runar-guide.mdreferences/scrypt-guide.mdGuides Next.js Cache Components and Partial Prerendering (PPR) with cacheComponents enabled. Implements 'use cache', cacheLife(), cacheTag(), revalidateTag(), static/dynamic optimization, and cache debugging.
Migrates code, prompts, and API calls from Claude Sonnet 4.0/4.5 or Opus 4.1 to Opus 4.5, updating model strings on Anthropic, AWS, GCP, Azure platforms.
Optimizes cloud costs on AWS, Azure, GCP via rightsizing, tagging strategies, reserved instances, spot usage, and spending analysis. Use for expense reduction and governance.
Write, compile, test, and deploy Bitcoin SV smart contracts using high-level languages that compile to Bitcoin Script.
For raw @bsv/sdk ScriptTemplate work (BitCom protocol templates like AIP, MAP, SIGMA), use the create-script-template skill instead. This skill is for contract logic — spending conditions, covenants, and stateful on-chain programs.
Two frameworks compile high-level languages to Bitcoin Script:
| Runar | sCrypt | |
|---|---|---|
| Languages | TypeScript, Go, Rust, Python, Solidity, Move | TypeScript (eDSL) |
| Model | Multi-compiler with conformance suite | Single compiler |
| Stateful | StatefulSmartContract + OP_PUSH_TX | SmartContract with @prop(true) |
| Testing | TestContract API with Script VM | Built-in test framework |
| Deployment | runar-sdk providers + signers | scrypt-ts deploy API |
| IDE | Full IDE support (valid TS/Go/Rust) | VS Code extension |
| Playground | https://runar.run | https://playground.scrypt.io |
| Install | pnpm add runar-lang runar-compiler runar-cli | npx scrypt-cli project my-app |
| Builtins | 53+ functions (crypto, math, EC, post-quantum, BLAKE3) | Standard Bitcoin Script ops |
| Codegen | SDK wrappers in TS, Go, Rust, Python from one compile | N/A |
| Maturity | v0.3.0 (23 examples, 28 conformance tests) | Production |
| Source | https://github.com/icellan/runar | https://github.com/sCrypt-Inc/scrypt-ts |
Decision guide:
All properties are immutable. The contract is satisfied in a single transaction. Both frameworks compile P2PKH to the same Bitcoin Script: OP_DUP OP_HASH160 <hash> OP_EQUALVERIFY OP_CHECKSIG.
Mutable properties persist across transactions via OP_PUSH_TX. Runar handles preimage verification automatically in StatefulSmartContract. sCrypt requires explicit buildStateOutput + hashOutputs verification in each public method.
In Runar, this.addOutput(satoshis, ...mutableFields) creates continuation outputs — pass only MUTABLE state values (readonly props are embedded in the script). Access this.txPreimage for BIP-143 preimage data (e.g., substr(this.txPreimage, 68n, 32n) for the outpoint txid). The compiler auto-adds _changePKH, _changeAmount, and txPreimage params to the ABI.
| Feature | Runar | sCrypt |
|---|---|---|
| Immutable prop | readonly keyword | @prop() decorator |
| Mutable prop | No keyword | @prop(true) decorator |
| Public method | public keyword | @method() decorator |
| Constructor super | super(prop1, prop2) | super(...arguments) |
| Sig check | checkSig(sig, pk) | this.checkSig(sig, pk) |
| State persistence | Automatic | Manual buildStateOutput |
| File extension | .runar.ts | .ts |
See references/contract-patterns.md for complete side-by-side code examples of P2PKH, Escrow, Counter, Covenant, and more.
| Pattern | Use Case | Stateful |
|---|---|---|
| P2PKH | Standard payments | No |
| Escrow | Multi-party authorization | No |
| Counter | On-chain state machine | Yes |
| Auction | Bidding with deadline | Yes |
| Covenant Vault | Spending constraints | No |
| Fungible Token | Split/merge token supply | Yes |
| NFT | Transfer/burn ownership | Yes |
| Oracle Price Feed | Rabin signature verification | No |
| Hash Time Lock | Atomic swaps | No |
| Multi-Sig (M-of-N) | Corporate treasury, shared custody | No |
| BLAKE3 Hash Lock | Modern hash verification | No |
| Post-Quantum Wallet | WOTS+, SLH-DSA signatures | No |
| TicTacToe | On-chain game logic | Yes |
See references/runar-guide.md and references/scrypt-guide.md for complete examples of each pattern.
Create a contract file:
MyContract.runar.ts (or .runar.go, .runar.rs, .runar.py)MyContract.ts with @method() decorators# Runar
npx runar compile MyContract.runar.ts
# sCrypt
npx scrypt-cli compile
// Runar — TestContract API with pre-generated test keys
import { TestContract, ALICE, BOB } from 'runar-testing';
// Addr type = 20-byte hex pubKeyHash, NOT Base58Check address
const contract = TestContract.fromSource(source, { pubKeyHash: ALICE.pubKeyHash });
// Test keys have: privKey, pubKey, pubKeyHash (hex), address (base58), wif, testSig
const result = contract.call('unlock', { sig: ALICE.testSig, pubKey: ALICE.pubKey });
expect(result.success).toBe(true);
// sCrypt — built-in testing
const instance = new P2PKH(pubKeyHash);
await instance.connect(getDefaultSigner());
const deployTx = await instance.deploy(1000);
const callTx = await instance.methods.unlock(sig, pubKey);
// Runar — SDK deployment
import { Contract, WocProvider, LocalSigner } from 'runar-sdk';
const provider = new WocProvider('mainnet');
const signer = new LocalSigner(privateKey);
const contract = new Contract(artifact, provider, signer);
const deployTx = await contract.deploy([constructorArg], { satoshis: 1000 });
// sCrypt — deploy API
await instance.connect(new TestWallet(privateKey, provider));
const tx = await instance.deploy(satoshis);
Both frameworks produce standard Bitcoin Script. The compiled output integrates with @bsv/sdk transaction building:
import { Transaction, P2PKH } from '@bsv/sdk';
// Use compiled contract script as locking script in any @bsv/sdk transaction
For raw script template authoring (BitCom protocols), see the create-script-template skill.
For script validation and opcode analysis, see the validate-bsv-script skill.
For detailed framework-specific guides, consult:
references/runar-guide.md — Runar installation, language reference, compilation pipeline, all contract patterns, deployment SDK, multi-language supportreferences/scrypt-guide.md — sCrypt installation, decorators, testing, deployment, advanced patternsreferences/contract-patterns.md — Side-by-side implementations of common patterns in both frameworks