{"_id":"@arch-network/arch-sdk","_rev":"6-3d65e1ac9af315430ff3800ba2552f76","name":"@arch-network/arch-sdk","dist-tags":{"latest":"0.0.28"},"versions":{"0.0.25":{"name":"@arch-network/arch-sdk","version":"0.0.25","keywords":["arch","arch-network","sdk","bitcoin","typescript"],"author":{"name":"Arch Network"},"license":"MIT","_id":"@arch-network/arch-sdk@0.0.25","maintainers":[{"name":"hoffmabc","email":"brian@ob1.io"}],"homepage":"https://github.com/Arch-Network/arch-typescript-sdk#readme","bugs":{"url":"https://github.com/Arch-Network/arch-typescript-sdk/issues"},"dist":{"shasum":"7921fab1055dda03f30d12b322da1d656df8229d","tarball":"https://registry.npmjs.org/@arch-network/arch-sdk/-/arch-sdk-0.0.25.tgz","fileCount":7,"integrity":"sha512-aRc7GsKb3O0fhNdad3Bbb/jYCG2Dti9mRLO0x3+XP2O5yF4pZjnrGz6zFbCq9AjDGl7ac92FkrP4s6Bbw+4qJA==","signatures":[{"sig":"MEQCIFU3zlKXN9lJL3wA4Oe0274Yh6LpCbWKu9ROLDlycuilAiAGJiCEtcrQM4PYE+4vB05qSqJ1NKwAEr2Ty5R4PU/B/Q==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":250274},"main":"dist/index.js","types":"dist/index.d.ts","gitHead":"8309177951a4e87b4205425b72808a1b8637501b","scripts":{"lint":"tsc","test":"vitest","build":"tsup src/index.ts --format cjs,esm --dts","deploy":"npm i && npm run build && npm publish","test:rpc":"npx tsx test/rpc-harness.ts"},"_npmUser":{"name":"hoffmabc","email":"brian@ob1.io"},"prettier":{"semi":true,"useTabs":false,"tabWidth":2,"endOfLine":"lf","printWidth":80,"arrowParens":"always","singleQuote":true,"insertPragma":false,"requirePragma":false,"trailingComma":"all","bracketSpacing":true,"bracketSameLine":false},"repository":{"url":"git+https://github.com/Arch-Network/arch-typescript-sdk.git","type":"git"},"_npmVersion":"10.9.2","description":"Arch SDK","directories":{},"_nodeVersion":"23.11.0","dependencies":{"borsh":"^2.0.0","@scure/base":"^1.1.7","@noble/curves":"^1.5.0","@noble/hashes":"^1.4.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"ws":"^8.18.0","tsup":"^8.2.4","vitest":"^2.0.5","prettier":"^3.3.3","@types/ws":"^8.5.12","typescript":"^5.5.4","@types/node":"^22.1.0"},"_npmOperationalInternal":{"tmp":"tmp/arch-sdk_0.0.25_1771426762743_0.9332809071816888","host":"s3://npm-registry-packages-npm-production"}},"0.0.26":{"name":"@arch-network/arch-sdk","version":"0.0.26","keywords":["arch","arch-network","sdk","bitcoin","typescript"],"author":{"name":"Arch Network"},"license":"MIT","_id":"@arch-network/arch-sdk@0.0.26","maintainers":[{"name":"hoffmabc","email":"brian@ob1.io"}],"homepage":"https://github.com/Arch-Network/arch-typescript-sdk#readme","bugs":{"url":"https://github.com/Arch-Network/arch-typescript-sdk/issues"},"dist":{"shasum":"bc8c0b0dfb85d372026f2c505dd78d75c81b4595","tarball":"https://registry.npmjs.org/@arch-network/arch-sdk/-/arch-sdk-0.0.26.tgz","fileCount":7,"integrity":"sha512-1yYbH7dpuZc8JJA0hvjl4vmTwVTaNyHlEZcmAKoOx95heOwFenAsnic0eSQm2KVD/ovOBRgJ3JyKQQVLxi/MJQ==","signatures":[{"sig":"MEYCIQCw99xPYdEgx4SuEGrCwNPUToMiSgUTfR38dtop33+GFQIhAN9gPRpJSHHQCSSWbn1ZEZK006oi8+7H0Z3Bvmwp5HRD","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":249886},"main":"dist/index.js","types":"dist/index.d.ts","gitHead":"01af33e28e5191fb5aa66a882b4a62afe1bedd74","scripts":{"lint":"tsc","test":"vitest","build":"tsup src/index.ts --format cjs,esm --dts","deploy":"npm i && npm run build && npm publish","test:rpc":"npx tsx test/rpc-harness.ts"},"_npmUser":{"name":"hoffmabc","email":"brian@ob1.io"},"prettier":{"semi":true,"useTabs":false,"tabWidth":2,"endOfLine":"lf","printWidth":80,"arrowParens":"always","singleQuote":true,"insertPragma":false,"requirePragma":false,"trailingComma":"all","bracketSpacing":true,"bracketSameLine":false},"repository":{"url":"git+https://github.com/Arch-Network/arch-typescript-sdk.git","type":"git"},"_npmVersion":"10.9.2","description":"Arch SDK","directories":{},"_nodeVersion":"23.11.0","dependencies":{"borsh":"^2.0.0","@scure/base":"^1.1.7","@noble/curves":"^1.5.0","@noble/hashes":"^1.4.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"ws":"^8.18.0","tsup":"^8.2.4","vitest":"^2.0.5","prettier":"^3.3.3","@types/ws":"^8.5.12","typescript":"^5.5.4","@types/node":"^22.1.0"},"_npmOperationalInternal":{"tmp":"tmp/arch-sdk_0.0.26_1771434141720_0.015716606994531146","host":"s3://npm-registry-packages-npm-production"}},"0.0.27":{"name":"@arch-network/arch-sdk","version":"0.0.27","keywords":["arch","arch-network","sdk","bitcoin","typescript"],"author":{"name":"Arch Network"},"license":"MIT","_id":"@arch-network/arch-sdk@0.0.27","maintainers":[{"name":"hoffmabc","email":"brian@ob1.io"},{"name":"0xfinetuned","email":"amine@arch.network"}],"homepage":"https://github.com/Arch-Network/arch-typescript-sdk#readme","bugs":{"url":"https://github.com/Arch-Network/arch-typescript-sdk/issues"},"dist":{"shasum":"9919011440999628470d2137c4ac0c3477fc8675","tarball":"https://registry.npmjs.org/@arch-network/arch-sdk/-/arch-sdk-0.0.27.tgz","fileCount":3,"integrity":"sha512-Pknw9O7LrVOpW3LREg6zNQnXc9FDcWatcYXaffKMKG7oWEQ79Gpah2nLhiDT19zazZGLHwO4ltw8cqgURT8xIw==","signatures":[{"sig":"MEUCIAOTsF5eBSIrRjOB4VnPCKo1Eaz55cPTYtDrOXPoZFzvAiEAhFiuvEhxUuPigO8YUurEXQ6jBC3rVOk2BYNYcy6ceJI=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":15137},"main":"dist/index.js","types":"dist/index.d.ts","gitHead":"d6ad12bb9bf138a0f03305414b88d752ee55d578","scripts":{"lint":"tsc","test":"vitest","build":"tsup src/index.ts --format cjs,esm --dts","deploy":"npm i && npm run build && npm publish","test:rpc":"npx tsx test/rpc-harness.ts"},"_npmUser":{"name":"hoffmabc","email":"brian@ob1.io"},"prettier":{"semi":true,"useTabs":false,"tabWidth":2,"endOfLine":"lf","printWidth":80,"arrowParens":"always","singleQuote":true,"insertPragma":false,"requirePragma":false,"trailingComma":"all","bracketSpacing":true,"bracketSameLine":false},"repository":{"url":"git+https://github.com/Arch-Network/arch-typescript-sdk.git","type":"git"},"_npmVersion":"10.9.2","description":"Arch SDK","directories":{},"_nodeVersion":"23.11.0","dependencies":{"borsh":"^2.0.0","@scure/base":"^1.1.7","@noble/curves":"^1.5.0","@noble/hashes":"^1.4.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"ws":"^8.18.0","tsup":"^8.2.4","vitest":"^2.0.5","prettier":"^3.3.3","@types/ws":"^8.5.12","typescript":"^5.5.4","@types/node":"^22.1.0"},"_npmOperationalInternal":{"tmp":"tmp/arch-sdk_0.0.27_1773147628843_0.22531619107759204","host":"s3://npm-registry-packages-npm-production"}},"0.0.28":{"name":"@arch-network/arch-sdk","version":"0.0.28","description":"Arch SDK","author":{"name":"Arch Network"},"main":"./dist/index.js","module":"./dist/index.mjs","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.js"}},"publishConfig":{"access":"public"},"repository":{"type":"git","url":"git+https://github.com/Arch-Network/arch-typescript-sdk.git"},"bugs":{"url":"https://github.com/Arch-Network/arch-typescript-sdk/issues"},"homepage":"https://github.com/Arch-Network/arch-typescript-sdk#readme","keywords":["arch","arch-network","sdk","bitcoin","typescript"],"scripts":{"build":"tsup src/index.ts --format cjs,esm --dts","prepublishOnly":"npm run build","deploy":"npm i && npm run build && npm publish","lint":"tsc","test":"vitest","test:rpc":"npx tsx test/rpc-harness.ts"},"license":"MIT","devDependencies":{"@types/node":"^22.1.0","@types/ws":"^8.5.12","prettier":"^3.3.3","tsup":"^8.2.4","typescript":"^5.5.4","vitest":"^2.0.5","ws":"^8.18.0"},"prettier":{"printWidth":80,"tabWidth":2,"useTabs":false,"semi":true,"singleQuote":true,"trailingComma":"all","bracketSpacing":true,"bracketSameLine":false,"arrowParens":"always","requirePragma":false,"insertPragma":false,"endOfLine":"lf"},"dependencies":{"@noble/curves":"^1.5.0","@noble/hashes":"^1.4.0","@scure/base":"^1.1.7","borsh":"^2.0.0"},"_id":"@arch-network/arch-sdk@0.0.28","gitHead":"e00dfebcb6465c50a8fdcaf8b09894d3195f02fe","_nodeVersion":"24.6.0","_npmVersion":"11.5.1","dist":{"integrity":"sha512-52WPTfzoZNGXP1UWJeVhBZIjVMVvZEcFJY9PggKv3K9JvPoXh+ccHYcic09+praKQxfDRcmgc+sn/mIuw/TXsQ==","shasum":"3d4de52dc92ff4610b12106f86897bcec983c5a3","tarball":"https://registry.npmjs.org/@arch-network/arch-sdk/-/arch-sdk-0.0.28.tgz","fileCount":7,"unpackedSize":271357,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIA5AwojDKJcIUtPupv/pFuFAu6NXeD1A6n3q9Zh21W1NAiEAnz28uiQe5eGaX1+w/SDdZ9R+gPouBjZoICUKV3H/anM="}]},"_npmUser":{"name":"hoffmabc","email":"brian@ob1.io"},"directories":{},"maintainers":[{"name":"hoffmabc","email":"brian@ob1.io"},{"name":"0xfinetuned","email":"amine@arch.network"},{"name":"jsblair9","email":"james@lionsmouth.digital"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/arch-sdk_0.0.28_1787833981267_0.2747795789763683"},"_hasShrinkwrap":false}},"time":{"created":"2026-02-18T14:59:22.675Z","modified":"2026-08-27T12:33:01.650Z","0.0.25":"2026-02-18T14:59:22.906Z","0.0.26":"2026-02-18T17:02:21.909Z","0.0.27":"2026-03-10T13:00:28.998Z","0.0.28":"2026-08-27T12:33:01.428Z"},"bugs":{"url":"https://github.com/Arch-Network/arch-typescript-sdk/issues"},"author":{"name":"Arch Network"},"license":"MIT","homepage":"https://github.com/Arch-Network/arch-typescript-sdk#readme","keywords":["arch","arch-network","sdk","bitcoin","typescript"],"repository":{"type":"git","url":"git+https://github.com/Arch-Network/arch-typescript-sdk.git"},"description":"Arch SDK","maintainers":[{"name":"hoffmabc","email":"brian@ob1.io"},{"name":"0xfinetuned","email":"amine@arch.network"},{"name":"jsblair9","email":"james@lionsmouth.digital"}],"readme":"# Arch TypeScript SDK\n\nA TypeScript SDK for building, signing, and sending transactions on the Arch Network. This SDK provides low-level primitives for message creation, signature handling, and transaction submission, enabling developers to build custom workflows and applications on top of the Arch protocol.\n\n## Installation\n\n```bash\nnpm install @arch-network/arch-sdk\n```\n\n## Quickstart Example\n\nBelow is a minimal example showing how to create a message, sign it, adjust the signature, and send an Arch transaction using this SDK.\n\n```typescript\nimport {\n  ArchConnection,\n  SanitizedMessageUtil,\n  SignatureUtil,\n  RpcConnection,\n} from '@arch-network/arch-sdk';\n\n// 1. Set up a provider (e.g., RPC connection to an Arch node)\nconst provider = new RpcConnection({ nodeUrl: 'http://localhost:8899' });\nconst arch = ArchConnection(provider);\n\n// 2. Prepare your instruction(s) (see Instruction type for structure)\nconst instructions = [/* ...your instructions here... */];\nconst payerPubkey = /* Uint8Array (32 bytes) */;\nconst recentBlockhash = /* Call the archRpc.getBestBlockhash */;\n\n// 3. Create a SanitizedMessage\nconst message = SanitizedMessageUtil.createSanitizedMessage(\n  instructions,\n  payerPubkey,\n  recentBlockhash\n);\n\n// 4. Hash the message and sign it (using your signing method)\nconst messageHash = SanitizedMessageUtil.hash(message); // Uint8Array\n\n// Decode it using utf-8\nconst messageHashString = new TextDecoder().decode(messageHash);\n\n// Sign the message hash using your Bitcoin private key, producing a BIP322-compliant signature.\n// You can use a wallet or library that supports BIP322 signing.\nconst signature = bip322Sign(privateKey, messageHashString, addressType); // pseudocode\n\n// 5. Adjust the signature to the required format\nconst adjustedSignature = SignatureUtil.adjustSignature(signature);\n\n// 6. Build the transaction object\nconst transaction = {\n  version: 0,\n  signatures: [adjustedSignature],\n  message,\n};\n\n// 7. Send the transaction\nconst txid = await arch.sendTransaction(transaction);\nconsole.log('Arch transaction ID:', txid);\n\n```\n\n## API Overview\n\n### Providers\n\n- **RpcConnection**: Connects to an Arch node via HTTP.\n- **ArchConnection**: Extends a provider with Arch-specific helpers (e.g., createNewAccount).\n\n### Message Creation\n\n- **SanitizedMessageUtil.createSanitizedMessage(instructions, payer, recentBlockhash)**\n  - Compiles instructions into a canonical message for signing and sending.\n- **SanitizedMessageUtil.hash(message)**\n  - Returns the hash (Uint8Array) of a sanitized message for signing.\n\n### Signature Utilities\n\n- **SignatureUtil.adjustSignature(signature: Uint8Array)**\n  - Normalizes a signature to the required 64-byte format for Arch transactions.\n\n### Transaction Structure\n\n- **RuntimeTransaction**\n  - `{ version: number, signatures: Uint8Array[], message: SanitizedMessage }`\n\n### Sending Transactions\n\n- **arch.sendTransaction(transaction: RuntimeTransaction): Promise<string>**\n  - Sends a transaction to the Arch network and returns the transaction ID.\n\n### Creating a New Account\n\n- **arch.createNewAccount(): Promise<{ privkey, pubkey, address }>**\n  - Generates a new keypair and returns the address, pubkey, and privkey.\n\n## Types\n\n- **Instruction**: `{ program_id, accounts, data }`\n- **SanitizedMessage**: `{ header, account_keys, recent_blockhash, instructions }`\n- **Signature**: `Uint8Array (64 bytes)`\n- **RuntimeTransaction**: `{ version, signatures, message }`\n\n## System Instruction Helpers\n\nThe SDK provides low-level helper functions for constructing system instructions compatible with the Arch blockchain. These helpers serialize instruction data in a format expected by the on-chain Rust programs, making it easy to create, transfer, and manage accounts from TypeScript.\n\n### `createAccount`\n\nCreates a new account on the blockchain.\n\n**Parameters:**\n\n- `fromPubkey: Pubkey` — Funding account public key (signer, writable)\n- `toPubkey: Pubkey` — New account public key (signer, writable)\n- `lamports: bigint` — Number of lamports to transfer to the new account\n- `space: bigint` — Number of bytes of memory to allocate\n- `owner: Pubkey` — Program that will own the new account\n\n**Example:**\n\n```typescript\nconst ix = createAccount(funder, newAccount, 1000n, 128n, ownerProgramId);\n```\n\n---\n\n### `createAccountWithAnchor`\n\nCreates a new account and anchors it to a specific UTXO (e.g., for Bitcoin integration).\n\n**Parameters:**\n\n- `fromPubkey: Pubkey` — Funding account public key (signer, writable)\n- `toPubkey: Pubkey` — New account public key (signer, writable)\n- `lamports: bigint` — Number of lamports to transfer\n- `space: bigint` — Number of bytes of memory to allocate\n- `owner: Pubkey` — Program that will own the new account\n- `txid: string` — 64-character hex string of the UTXO transaction ID\n- `vout: number` — Output index of the UTXO\n\n**Example:**\n\n```typescript\nconst ix = createAccountWithAnchor(\n  funder,\n  newAccount,\n  1000n,\n  128n,\n  ownerProgramId,\n  'aabbcc...ff', // 64-char hex string\n  0,\n);\n```\n\n---\n\n### `transfer`\n\nTransfers lamports from one account to another.\n\n**Parameters:**\n\n- `fromPubkey: Pubkey` — Sender account public key (signer, writable)\n- `toPubkey: Pubkey` — Recipient account public key (writable)\n- `lamports: bigint` — Amount to transfer\n\n**Example:**\n\n```typescript\nconst ix = transfer(sender, recipient, 500n);\n```\n\n---\n\n### `assign`\n\nAssigns a new owner (program) to an account.\n\n**Parameters:**\n\n- `pubkey: Pubkey` — Account to reassign (signer, writable)\n- `owner: Pubkey` — New owner program public key\n\n**Example:**\n\n```typescript\nconst ix = assign(account, newOwnerProgramId);\n```\n\n---\n\n### `allocate`\n\nAllocates space in an account without funding it.\n\n**Parameters:**\n\n- `pubkey: Pubkey` — Account to allocate space for (signer, writable)\n- `space: bigint` — Number of bytes to allocate\n\n**Example:**\n\n```typescript\nconst ix = allocate(account, 256n);\n```\n\n---\n\n**Usage Note:**\nAfter constructing an instruction with these helpers, use the SDK's serialization utilities (see above) to serialize and send the instruction as part of a transaction.\n\n## Example: Creating and Sending a Transaction\n\n```typescript\nimport {\n  ArchConnection,\n  SanitizedMessageUtil,\n  SignatureUtil,\n  RpcConnection,\n  // ...other imports\n} from '@arch-network/arch-sdk';\n\n// Set up provider and arch connection\nconst provider = new RpcConnection({ nodeUrl: 'http://localhost:8899' });\nconst arch = ArchConnection(provider);\n\n// Example instruction (replace with your actual data)\nconst instruction = {\n  program_id: new Uint8Array(32), // 32-byte program ID\n  accounts: [\n    {\n      pubkey: new Uint8Array(32), // 32-byte pubkey\n      is_signer: true,\n      is_writable: true,\n    },\n  ],\n  data: new Uint8Array([1, 2, 3]), // Your instruction data\n};\n\nconst payerPubkey = new Uint8Array(32); // Replace with your payer pubkey\nconst recentBlockhash = '...'; // Call the archRpc.getBestBlockhash\n\nconst message = SanitizedMessageUtil.createSanitizedMessage(\n  [instruction],\n  payerPubkey,\n  recentBlockhash,\n);\n\nconst messageHash = SanitizedMessageUtil.hash(message);\n// Sign the message hash with your Bitcoin private key using the BIP322 standard.\n// (You must use a wallet or library that supports BIP322 message signing.)\nconst signature = bip322Sign(privateKey, messageHash, addressType); // pseudocode\nconst adjustedSignature = SignatureUtil.adjustSignature(signature);\n\nconst transaction = {\n  version: 0,\n  signatures: [adjustedSignature],\n  message,\n};\n\nconst txid = await arch.sendTransaction(transaction);\nconsole.log('Arch transaction ID:', txid);\n```\n\n## Advanced Topics\n\n- **Multiple Signers**: Add multiple signatures to the `signatures` array in the transaction.\n- **Custom Providers**: Implement the `Provider` interface for custom transport or signing logic.\n\n## Troubleshooting\n\n- Ensure all public keys and signatures are 32 and 64 bytes respectively.\n- Use `SignatureUtil.adjustSignature` to normalize signatures from different signing libraries.\n- Check node connectivity and blockhash freshness if transactions fail to send.\n\n## WebSocket Client: Real-Time Event Subscriptions\n\nThe SDK provides a WebSocket client for subscribing to real-time events from the Arch network, such as new blocks, transactions, account updates, and more.\n\n### Features\n\n- Connect/disconnect to a WebSocket server\n- Subscribe to event topics (block, transaction, account update, etc.)\n- Filter events by custom criteria\n- Add/remove listeners for events\n- Automatic reconnection with backoff strategies\n\n### Event Topics\n\n- `block`: New block events\n- `transaction`: Transaction status updates\n- `account_update`: Account state changes\n- `rolledback_transactions`, `reapplied_transactions`, `dkg`: Advanced protocol events\n\n### Configuration Options\n\nYou can customize the WebSocket client by passing a configuration object to the constructor:\n\n```typescript\ninterface WebSocketClientOptions {\n  url: string; // (Required) WebSocket server URL\n  maxReconnectAttempts?: number; // Max reconnection attempts (default: 5)\n  backoffStrategy?: BackoffStrategy; // Reconnection backoff strategy (see below)\n  autoReconnect?: boolean; // Enable auto-reconnect (default: false)\n  timeout?: number; // Connection timeout in ms (default: 20000)\n  transports?: string[]; // Socket.IO transports (default: ['websocket', 'polling'])\n  forceNew?: boolean; // Force new connection (default: true)\n  multiplex?: boolean; // Enable multiplexing (default: false)\n}\n\ninterface BackoffStrategy {\n  type: 'constant' | 'linear' | 'exponential'; // Strategy type\n  initial?: number; // Initial delay in ms (default: 1000)\n  factor?: number; // Growth factor for exponential (default: 2)\n  maxDelay?: number; // Max delay in ms (default: 30000)\n  step?: number; // Step size for linear (optional)\n  jitter?: number; // Jitter as a fraction (default: 0.2)\n}\n```\n\n**Defaults:**\n\n- `maxReconnectAttempts`: 5\n- `autoReconnect`: false\n- `timeout`: 20000\n- `transports`: ['websocket', 'polling']\n- `forceNew`: true\n- `multiplex`: false\n- `backoffStrategy`: Exponential (initial: 1000ms, factor: 2, maxDelay: 30000ms, jitter: 0.2)\n\n#### Example\n\n```typescript\nconst client = new ArchWebSocketClient({\n  url: 'ws://localhost:3001',\n  autoReconnect: true,\n  maxReconnectAttempts: 10,\n  timeout: 15000,\n  transports: ['websocket'],\n  backoffStrategy: {\n    type: 'exponential',\n    initial: 500,\n    factor: 2,\n    maxDelay: 20000,\n    jitter: 0.1,\n  },\n});\n```\n\n### Example Usage\n\n```typescript\nimport { ArchWebSocketClient } from '@arch-network/arch-sdk';\nimport { EventTopic } from '@arch-network/arch-sdk/websocket-client/types/events';\n\nconst client = new ArchWebSocketClient({ url: 'ws://localhost:3001' });\n\n// Connect to the server\nawait client.connect();\n\n// Subscribe to new block events\nconst blockCallback = async (event) => {\n  console.log('New block:', event.hash, event.timestamp);\n};\nawait client.subscribe(EventTopic.Block, blockCallback);\n\n// Subscribe to transaction events with a filter\nconst txCallback = async (event) => {\n  console.log('Transaction update:', event.hash, event.status);\n};\nawait client.subscribe(EventTopic.Transaction, txCallback, {\n  status: 'Processed',\n});\n\n// Add an additional listener for account updates\nclient.on(EventTopic.AccountUpdate, (event) => {\n  console.log('Account updated:', event.account);\n});\n\n// Disconnect when done\nawait client.disconnect();\n```\n\n### Filters\n\nYou can filter events by fields such as status, programIds, block hash, etc. (see `EventFilter`, `TransactionFilter`, `BlockFilter`).\n\n### Reconnection\n\nThe client supports automatic reconnection with customizable backoff strategies:\n\n```typescript\nclient.setReconnectOptions(\n  true,\n  /* strategy */ 'exponential',\n  /* maxAttempts */ 5,\n);\n```\n\n### Event Types\n\nSee the SDK source for all event interfaces (e.g., `BlockEvent`, `TransactionEvent`, `AccountUpdateEvent`).\n\n---\n\n## Wallet Types\n\nThe SDK and related packages define types for representing user wallets, UTXOs, and collections:\n\n```typescript\ninterface Wallet {\n  address: string;\n  balance: bigint;\n  utxos: Array<CollectionUtxo>;\n}\n\ninterface CollectionUtxo {\n  // UTXO details\n  collectionStatuses: Array<CollectionAmount>;\n  hasInscription: boolean;\n}\n\ninterface CollectionAmount {\n  id: string;\n  type: 'rune' | 'btc';\n  amount: bigint;\n}\n```\n\nThese types are useful for wallet management, UTXO selection, and integration with pool or transaction logic.\n\n---\n","readmeFilename":"README.md"}