@secondlayer/stacks 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (178) hide show
  1. package/README.md +92 -0
  2. package/dist/shared/stacks-02actsrx.cjs +17 -0
  3. package/dist/shared/stacks-02actsrx.cjs.map +10 -0
  4. package/dist/shared/stacks-1aqm7c2h.cjs +110 -0
  5. package/dist/shared/stacks-1aqm7c2h.cjs.map +11 -0
  6. package/dist/shared/stacks-24h5k94q.cjs +74 -0
  7. package/dist/shared/stacks-24h5k94q.cjs.map +11 -0
  8. package/dist/shared/stacks-2ar4prfz.cjs +328 -0
  9. package/dist/shared/stacks-2ar4prfz.cjs.map +11 -0
  10. package/dist/shared/stacks-4py5pm0r.cjs +237 -0
  11. package/dist/shared/stacks-4py5pm0r.cjs.map +10 -0
  12. package/dist/shared/stacks-5tprhns9.cjs +54 -0
  13. package/dist/shared/stacks-5tprhns9.cjs.map +11 -0
  14. package/dist/shared/stacks-61rvzkz1.cjs +132 -0
  15. package/dist/shared/stacks-61rvzkz1.cjs.map +17 -0
  16. package/dist/shared/stacks-709tra19.js +30 -0
  17. package/dist/shared/stacks-709tra19.js.map +10 -0
  18. package/dist/shared/stacks-74k8cxgb.cjs +567 -0
  19. package/dist/shared/stacks-74k8cxgb.cjs.map +13 -0
  20. package/dist/shared/stacks-8m9byk2j.js +7 -0
  21. package/dist/shared/stacks-8m9byk2j.js.map +9 -0
  22. package/dist/shared/stacks-8yykgdww.js +125 -0
  23. package/dist/shared/stacks-8yykgdww.js.map +11 -0
  24. package/dist/shared/stacks-9g0jhab3.cjs +40 -0
  25. package/dist/shared/stacks-9g0jhab3.cjs.map +10 -0
  26. package/dist/shared/stacks-an5k8n4t.cjs +291 -0
  27. package/dist/shared/stacks-an5k8n4t.cjs.map +23 -0
  28. package/dist/shared/stacks-b008c3w8.cjs +214 -0
  29. package/dist/shared/stacks-b008c3w8.cjs.map +11 -0
  30. package/dist/shared/stacks-bnvfmt7y.cjs +31 -0
  31. package/dist/shared/stacks-bnvfmt7y.cjs.map +9 -0
  32. package/dist/shared/stacks-bycy6t9k.js +22 -0
  33. package/dist/shared/stacks-bycy6t9k.js.map +10 -0
  34. package/dist/shared/stacks-d1fmkv3p.js +258 -0
  35. package/dist/shared/stacks-d1fmkv3p.js.map +13 -0
  36. package/dist/shared/stacks-dr5en54r.cjs +119 -0
  37. package/dist/shared/stacks-dr5en54r.cjs.map +10 -0
  38. package/dist/shared/stacks-dxhntr76.js +278 -0
  39. package/dist/shared/stacks-dxhntr76.js.map +10 -0
  40. package/dist/shared/stacks-evnzth1q.cjs +35 -0
  41. package/dist/shared/stacks-evnzth1q.cjs.map +10 -0
  42. package/dist/shared/stacks-f3tk2k5s.js +27 -0
  43. package/dist/shared/stacks-f3tk2k5s.js.map +9 -0
  44. package/dist/shared/stacks-f7wdrzs3.js +285 -0
  45. package/dist/shared/stacks-f7wdrzs3.js.map +11 -0
  46. package/dist/shared/stacks-fcaefc5b.cjs +16 -0
  47. package/dist/shared/stacks-fcaefc5b.cjs.map +10 -0
  48. package/dist/shared/stacks-g9mcjcqg.cjs +3 -0
  49. package/dist/shared/stacks-g9mcjcqg.cjs.map +9 -0
  50. package/dist/shared/stacks-gck1sq7h.cjs +28 -0
  51. package/dist/shared/stacks-gck1sq7h.cjs.map +10 -0
  52. package/dist/shared/stacks-gjvbq6w7.js +46 -0
  53. package/dist/shared/stacks-gjvbq6w7.js.map +10 -0
  54. package/dist/shared/stacks-j2cy7qtt.js +237 -0
  55. package/dist/shared/stacks-j2cy7qtt.js.map +11 -0
  56. package/dist/shared/stacks-k08tgzyp.cjs +232 -0
  57. package/dist/shared/stacks-k08tgzyp.cjs.map +13 -0
  58. package/dist/shared/stacks-k2p5tv6x.js +37 -0
  59. package/dist/shared/stacks-k2p5tv6x.js.map +10 -0
  60. package/dist/shared/stacks-k58k970n.js +234 -0
  61. package/dist/shared/stacks-k58k970n.js.map +10 -0
  62. package/dist/shared/stacks-n2g56wgg.js +338 -0
  63. package/dist/shared/stacks-n2g56wgg.js.map +23 -0
  64. package/dist/shared/stacks-nqytwfcc.js +243 -0
  65. package/dist/shared/stacks-nqytwfcc.js.map +11 -0
  66. package/dist/shared/stacks-qcae5852.js +19 -0
  67. package/dist/shared/stacks-qcae5852.js.map +10 -0
  68. package/dist/shared/stacks-qt8ehebn.js +76 -0
  69. package/dist/shared/stacks-qt8ehebn.js.map +11 -0
  70. package/dist/shared/stacks-qvg7c24g.cjs +232 -0
  71. package/dist/shared/stacks-qvg7c24g.cjs.map +10 -0
  72. package/dist/shared/stacks-r1t6g3c3.cjs +241 -0
  73. package/dist/shared/stacks-r1t6g3c3.cjs.map +11 -0
  74. package/dist/shared/stacks-tjxmrssa.js +282 -0
  75. package/dist/shared/stacks-tjxmrssa.js.map +11 -0
  76. package/dist/shared/stacks-v9jqcpd4.js +18 -0
  77. package/dist/shared/stacks-v9jqcpd4.js.map +10 -0
  78. package/dist/shared/stacks-vdfag81a.cjs +121 -0
  79. package/dist/shared/stacks-vdfag81a.cjs.map +10 -0
  80. package/dist/shared/stacks-vdfs3e5v.js +134 -0
  81. package/dist/shared/stacks-vdfs3e5v.js.map +10 -0
  82. package/dist/shared/stacks-y3dh7hv1.js +60 -0
  83. package/dist/shared/stacks-y3dh7hv1.js.map +11 -0
  84. package/dist/shared/stacks-ya3x01yd.cjs +16 -0
  85. package/dist/shared/stacks-ya3x01yd.cjs.map +10 -0
  86. package/dist/shared/stacks-yfgsm6ap.js +599 -0
  87. package/dist/shared/stacks-yfgsm6ap.js.map +13 -0
  88. package/dist/shared/stacks-yfveb68e.js +121 -0
  89. package/dist/shared/stacks-yfveb68e.js.map +10 -0
  90. package/dist/shared/stacks-zm0b3tgy.js +160 -0
  91. package/dist/shared/stacks-zm0b3tgy.js.map +17 -0
  92. package/dist/shared/stacks-zyv9qqme.cjs +249 -0
  93. package/dist/shared/stacks-zyv9qqme.cjs.map +11 -0
  94. package/dist/src/accounts/index.cjs +90 -0
  95. package/dist/src/accounts/index.cjs.map +12 -0
  96. package/dist/src/accounts/index.d.cts +47 -0
  97. package/dist/src/accounts/index.d.ts +47 -0
  98. package/dist/src/accounts/index.js +104 -0
  99. package/dist/src/accounts/index.js.map +12 -0
  100. package/dist/src/actions/index.cjs +36 -0
  101. package/dist/src/actions/index.cjs.map +9 -0
  102. package/dist/src/actions/index.d.cts +886 -0
  103. package/dist/src/actions/index.d.ts +886 -0
  104. package/dist/src/actions/index.js +81 -0
  105. package/dist/src/actions/index.js.map +9 -0
  106. package/dist/src/bns/index.cjs +590 -0
  107. package/dist/src/bns/index.cjs.map +15 -0
  108. package/dist/src/bns/index.d.cts +241 -0
  109. package/dist/src/bns/index.d.ts +241 -0
  110. package/dist/src/bns/index.js +611 -0
  111. package/dist/src/bns/index.js.map +15 -0
  112. package/dist/src/chains/index.cjs +13 -0
  113. package/dist/src/chains/index.cjs.map +9 -0
  114. package/dist/src/chains/index.d.cts +53 -0
  115. package/dist/src/chains/index.d.ts +53 -0
  116. package/dist/src/chains/index.js +18 -0
  117. package/dist/src/chains/index.js.map +9 -0
  118. package/dist/src/clarity/index.cjs +3 -0
  119. package/dist/src/clarity/index.cjs.map +9 -0
  120. package/dist/src/clarity/index.d.cts +821 -0
  121. package/dist/src/clarity/index.d.ts +821 -0
  122. package/dist/src/clarity/index.js +145 -0
  123. package/dist/src/clarity/index.js.map +9 -0
  124. package/dist/src/connect/index.cjs +480 -0
  125. package/dist/src/connect/index.cjs.map +19 -0
  126. package/dist/src/connect/index.d.cts +110 -0
  127. package/dist/src/connect/index.d.ts +110 -0
  128. package/dist/src/connect/index.js +448 -0
  129. package/dist/src/connect/index.js.map +19 -0
  130. package/dist/src/connect/walletconnect/index.cjs +1322 -0
  131. package/dist/src/connect/walletconnect/index.cjs.map +18 -0
  132. package/dist/src/connect/walletconnect/index.d.cts +132 -0
  133. package/dist/src/connect/walletconnect/index.d.ts +132 -0
  134. package/dist/src/connect/walletconnect/index.js +1290 -0
  135. package/dist/src/connect/walletconnect/index.js.map +18 -0
  136. package/dist/src/index.cjs +557 -0
  137. package/dist/src/index.cjs.map +21 -0
  138. package/dist/src/index.d.cts +847 -0
  139. package/dist/src/index.d.ts +847 -0
  140. package/dist/src/index.js +629 -0
  141. package/dist/src/index.js.map +21 -0
  142. package/dist/src/postconditions/index.cjs +3 -0
  143. package/dist/src/postconditions/index.cjs.map +9 -0
  144. package/dist/src/postconditions/index.d.cts +91 -0
  145. package/dist/src/postconditions/index.d.ts +91 -0
  146. package/dist/src/postconditions/index.js +12 -0
  147. package/dist/src/postconditions/index.js.map +9 -0
  148. package/dist/src/pox/index.cjs +860 -0
  149. package/dist/src/pox/index.cjs.map +15 -0
  150. package/dist/src/pox/index.d.cts +244 -0
  151. package/dist/src/pox/index.d.ts +244 -0
  152. package/dist/src/pox/index.js +877 -0
  153. package/dist/src/pox/index.js.map +15 -0
  154. package/dist/src/stackingdao/index.cjs +300 -0
  155. package/dist/src/stackingdao/index.cjs.map +13 -0
  156. package/dist/src/stackingdao/index.d.cts +179 -0
  157. package/dist/src/stackingdao/index.d.ts +179 -0
  158. package/dist/src/stackingdao/index.js +318 -0
  159. package/dist/src/stackingdao/index.js.map +13 -0
  160. package/dist/src/subscriptions/index.cjs +14 -0
  161. package/dist/src/subscriptions/index.cjs.map +9 -0
  162. package/dist/src/subscriptions/index.d.cts +250 -0
  163. package/dist/src/subscriptions/index.d.ts +250 -0
  164. package/dist/src/subscriptions/index.js +21 -0
  165. package/dist/src/subscriptions/index.js.map +9 -0
  166. package/dist/src/transactions/index.cjs +50 -0
  167. package/dist/src/transactions/index.cjs.map +9 -0
  168. package/dist/src/transactions/index.d.cts +412 -0
  169. package/dist/src/transactions/index.d.ts +412 -0
  170. package/dist/src/transactions/index.js +101 -0
  171. package/dist/src/transactions/index.js.map +9 -0
  172. package/dist/src/utils/index.cjs +168 -0
  173. package/dist/src/utils/index.cjs.map +11 -0
  174. package/dist/src/utils/index.d.cts +140 -0
  175. package/dist/src/utils/index.d.ts +140 -0
  176. package/dist/src/utils/index.js +222 -0
  177. package/dist/src/utils/index.js.map +11 -0
  178. package/package.json +105 -0
@@ -0,0 +1,886 @@
1
+ /** Full chain descriptor used by clients and transports for network-aware operations. */
2
+ type StacksChain = {
3
+ /** Chain ID (e.g. 0x00000001 for mainnet) */
4
+ id: number
5
+ /** Human-readable name */
6
+ name: string
7
+ /** Network type */
8
+ network: "mainnet" | "testnet"
9
+ /** Transaction version byte for serialization */
10
+ transactionVersion: number
11
+ /** Peer network ID for P2P broadcasting */
12
+ peerNetworkId: number
13
+ /** Address version bytes */
14
+ addressVersion: {
15
+ singleSig: number
16
+ multiSig: number
17
+ }
18
+ /** Magic bytes for network identification */
19
+ magicBytes: string
20
+ /** Boot address (system contracts deployer) */
21
+ bootAddress: string
22
+ /** Native currency info */
23
+ nativeCurrency: {
24
+ name: string
25
+ symbol: string
26
+ decimals: number
27
+ }
28
+ /** Default RPC URLs */
29
+ rpcUrls: {
30
+ default: {
31
+ http: string[]
32
+ ws?: string[]
33
+ }
34
+ }
35
+ /** Block explorer URLs */
36
+ blockExplorers?: {
37
+ default: {
38
+ name: string
39
+ url: string
40
+ }
41
+ }
42
+ };
43
+ /** Function that sends an HTTP request to a Stacks node API path. */
44
+ type RequestFn = (path: string, options?: RequestOptions) => Promise<any>;
45
+ /** Options for a transport-level HTTP request. */
46
+ type RequestOptions = {
47
+ method?: "GET" | "POST" | "PUT" | "DELETE"
48
+ body?: unknown
49
+ headers?: Record<string, string>
50
+ };
51
+ /** Shared configuration for all transport types. */
52
+ type TransportConfig = {
53
+ url?: string
54
+ timeout?: number
55
+ retryCount?: number
56
+ retryDelay?: number
57
+ fetchOptions?: RequestInit
58
+ apiKey?: string
59
+ };
60
+ /** A resolved transport instance with a bound request function. */
61
+ type Transport = {
62
+ type: string
63
+ request: RequestFn
64
+ config: TransportConfig
65
+ destroy?: () => void
66
+ };
67
+ /** Account derived from a local private key (mnemonic or raw key). */
68
+ type LocalAccount = {
69
+ type: "local"
70
+ address: string
71
+ /** Compressed public key (hex) */
72
+ publicKey: string
73
+ /** Raw ECDSA sign over a hash */
74
+ sign(hash: Uint8Array): Uint8Array
75
+ /** Sign a structured message (SIP-018) */
76
+ signMessage(message: string | Uint8Array): string
77
+ };
78
+ /** Account with a user-provided signing function (sync or async). */
79
+ type CustomAccount = {
80
+ type: "custom"
81
+ address: string
82
+ publicKey: string
83
+ sign(hash: Uint8Array): Promise<Uint8Array> | Uint8Array
84
+ };
85
+ /** Browser wallet provider interface (e.g. Leather, Xverse). */
86
+ type StacksProvider = {
87
+ request(method: string, params?: any): Promise<any>
88
+ };
89
+ /** Account backed by a browser wallet {@link StacksProvider}. */
90
+ type ProviderAccount = {
91
+ type: "provider"
92
+ address: string
93
+ publicKey: string
94
+ provider: StacksProvider
95
+ };
96
+ /** Union of all supported account types (local key, custom signer, or browser provider). */
97
+ type Account = LocalAccount | CustomAccount | ProviderAccount;
98
+ /**
99
+ * Core client instance that holds chain context, transport, and extensible actions.
100
+ * Created via {@link createClient}, {@link createPublicClient}, or {@link createWalletClient}.
101
+ */
102
+ type Client<TExtended extends Record<string, unknown> = Record<string, unknown>> = {
103
+ chain?: StacksChain
104
+ account?: Account
105
+ transport: Transport
106
+ request: RequestFn
107
+ extend: <const TNew extends Record<string, unknown>>(fn: (client: Client<TExtended>) => TNew) => Client<TExtended & TNew> & TNew
108
+ } & TExtended;
109
+ type GetNonceParams = {
110
+ address: string
111
+ };
112
+ declare function getNonce(client: Client, params: GetNonceParams): Promise<bigint>;
113
+ type GetBalanceParams = {
114
+ address: string
115
+ };
116
+ declare function getBalance(client: Client, params: GetBalanceParams): Promise<bigint>;
117
+ type GetAccountInfoParams = {
118
+ address: string
119
+ };
120
+ type AccountInfo = {
121
+ balance: bigint
122
+ nonce: bigint
123
+ balanceProof: string
124
+ nonceProof: string
125
+ };
126
+ declare function getAccountInfo(client: Client, params: GetAccountInfoParams): Promise<AccountInfo>;
127
+ type GetBlockParams = {
128
+ height?: number
129
+ hash?: string
130
+ };
131
+ declare function getBlock(client: Client, params?: GetBlockParams): Promise<any>;
132
+ declare function getBlockHeight(client: Client): Promise<number>;
133
+ type IntCV = {
134
+ readonly type: "int"
135
+ readonly value: bigint
136
+ };
137
+ type UIntCV = {
138
+ readonly type: "uint"
139
+ readonly value: bigint
140
+ };
141
+ type BooleanCV = TrueCV | FalseCV;
142
+ type TrueCV = {
143
+ readonly type: "true"
144
+ };
145
+ type FalseCV = {
146
+ readonly type: "false"
147
+ };
148
+ type BufferCV = {
149
+ readonly type: "buffer"
150
+ readonly value: string
151
+ };
152
+ type NoneCV = {
153
+ readonly type: "none"
154
+ };
155
+ type SomeCV = {
156
+ readonly type: "some"
157
+ readonly value: ClarityValue
158
+ };
159
+ type ResponseOkCV = {
160
+ readonly type: "ok"
161
+ readonly value: ClarityValue
162
+ };
163
+ type ResponseErrorCV = {
164
+ readonly type: "err"
165
+ readonly value: ClarityValue
166
+ };
167
+ type StandardPrincipalCV = {
168
+ readonly type: "address"
169
+ readonly value: string
170
+ };
171
+ type ContractPrincipalCV = {
172
+ readonly type: "contract"
173
+ readonly value: string
174
+ };
175
+ type ListCV = {
176
+ type: "list"
177
+ value: ClarityValue[]
178
+ };
179
+ type TupleData = {
180
+ [key: string]: ClarityValue
181
+ };
182
+ type TupleCV = {
183
+ type: "tuple"
184
+ value: TupleData
185
+ };
186
+ type StringAsciiCV = {
187
+ readonly type: "ascii"
188
+ readonly value: string
189
+ };
190
+ type StringUtf8CV = {
191
+ readonly type: "utf8"
192
+ readonly value: string
193
+ };
194
+ type ClarityValue = IntCV | UIntCV | BooleanCV | BufferCV | NoneCV | SomeCV | ResponseOkCV | ResponseErrorCV | StandardPrincipalCV | ContractPrincipalCV | ListCV | TupleCV | StringAsciiCV | StringUtf8CV;
195
+ type ReadContractParams = {
196
+ contract: string
197
+ functionName: string
198
+ args?: ClarityValue[]
199
+ sender?: string
200
+ };
201
+ declare function readContract<T extends ClarityValue = ClarityValue>(client: Client, params: ReadContractParams): Promise<T>;
202
+ type GetContractAbiParams = {
203
+ contract: string
204
+ };
205
+ declare function getContractAbi(client: Client, params: GetContractAbiParams): Promise<any>;
206
+ type GetMapEntryParams = {
207
+ contract: string
208
+ mapName: string
209
+ key: ClarityValue
210
+ };
211
+ declare function getMapEntry<T extends ClarityValue = ClarityValue>(client: Client, params: GetMapEntryParams): Promise<T>;
212
+ declare const AuthType: {
213
+ readonly Standard: 0x04
214
+ readonly Sponsored: 0x05
215
+ };
216
+ type AuthType = (typeof AuthType)[keyof typeof AuthType];
217
+ declare const PayloadType: {
218
+ readonly TokenTransfer: 0x00
219
+ readonly SmartContract: 0x01
220
+ readonly ContractCall: 0x02
221
+ readonly PoisonMicroblock: 0x03
222
+ readonly Coinbase: 0x04
223
+ readonly CoinbaseToAltRecipient: 0x05
224
+ readonly VersionedSmartContract: 0x06
225
+ readonly TenureChange: 0x07
226
+ readonly NakamotoCoinbase: 0x08
227
+ };
228
+ type PayloadType = (typeof PayloadType)[keyof typeof PayloadType];
229
+ declare const ClarityVersion: {
230
+ readonly Clarity1: 1
231
+ readonly Clarity2: 2
232
+ readonly Clarity3: 3
233
+ };
234
+ type ClarityVersion = (typeof ClarityVersion)[keyof typeof ClarityVersion];
235
+ declare const AnchorMode: {
236
+ readonly OnChainOnly: 0x01
237
+ readonly OffChainOnly: 0x02
238
+ readonly Any: 0x03
239
+ };
240
+ type AnchorMode = (typeof AnchorMode)[keyof typeof AnchorMode];
241
+ declare const PostConditionModeWire: {
242
+ readonly Allow: 0x01
243
+ readonly Deny: 0x02
244
+ };
245
+ type PostConditionModeWire = (typeof PostConditionModeWire)[keyof typeof PostConditionModeWire];
246
+ declare const AddressHashMode: {
247
+ readonly P2PKH: 0x00
248
+ readonly P2SH: 0x01
249
+ readonly P2WPKH: 0x02
250
+ readonly P2WSH: 0x03
251
+ readonly P2SH_NonSequential: 0x05
252
+ readonly P2WSH_P2SH_NonSequential: 0x07
253
+ };
254
+ type AddressHashMode = (typeof AddressHashMode)[keyof typeof AddressHashMode];
255
+ declare const PubKeyEncoding: {
256
+ readonly Compressed: 0x00
257
+ readonly Uncompressed: 0x01
258
+ };
259
+ type PubKeyEncoding = (typeof PubKeyEncoding)[keyof typeof PubKeyEncoding];
260
+ type TokenTransferPayload = {
261
+ payloadType: typeof PayloadType.TokenTransfer
262
+ recipient: ClarityValue
263
+ amount: bigint
264
+ memo: string
265
+ };
266
+ type ContractCallPayload = {
267
+ payloadType: typeof PayloadType.ContractCall
268
+ contractAddress: string
269
+ contractName: string
270
+ functionName: string
271
+ functionArgs: ClarityValue[]
272
+ };
273
+ type SmartContractPayload = {
274
+ payloadType: typeof PayloadType.SmartContract | typeof PayloadType.VersionedSmartContract
275
+ clarityVersion?: ClarityVersion
276
+ contractName: string
277
+ codeBody: string
278
+ };
279
+ type TransactionPayload = TokenTransferPayload | ContractCallPayload | SmartContractPayload;
280
+ type SingleSigSpendingCondition = {
281
+ hashMode: typeof AddressHashMode.P2PKH | typeof AddressHashMode.P2WPKH
282
+ signer: string
283
+ nonce: bigint
284
+ fee: bigint
285
+ keyEncoding: PubKeyEncoding
286
+ signature: string
287
+ };
288
+ type TransactionAuthField = {
289
+ pubKeyEncoding: PubKeyEncoding
290
+ type: "publicKey" | "signature"
291
+ data: string
292
+ };
293
+ type MultiSigHashMode = typeof AddressHashMode.P2SH | typeof AddressHashMode.P2WSH | typeof AddressHashMode.P2SH_NonSequential | typeof AddressHashMode.P2WSH_P2SH_NonSequential;
294
+ type MultiSigSpendingCondition = {
295
+ hashMode: MultiSigHashMode
296
+ signer: string
297
+ nonce: bigint
298
+ fee: bigint
299
+ fields: TransactionAuthField[]
300
+ signaturesRequired: number
301
+ };
302
+ type SpendingCondition = SingleSigSpendingCondition | MultiSigSpendingCondition;
303
+ type StandardAuthorization = {
304
+ authType: typeof AuthType.Standard
305
+ spendingCondition: SpendingCondition
306
+ };
307
+ type SponsoredAuthorization = {
308
+ authType: typeof AuthType.Sponsored
309
+ spendingCondition: SpendingCondition
310
+ sponsorSpendingCondition: SpendingCondition
311
+ };
312
+ type Authorization = StandardAuthorization | SponsoredAuthorization;
313
+ type StacksTransaction = {
314
+ version: number
315
+ chainId: number
316
+ auth: Authorization
317
+ anchorMode: AnchorMode
318
+ postConditionMode: PostConditionModeWire
319
+ postConditions: PostConditionWire[]
320
+ payload: TransactionPayload
321
+ };
322
+ type PostConditionWire = StxPostConditionWire | FtPostConditionWire | NftPostConditionWire;
323
+ type StxPostConditionWire = {
324
+ type: "stx"
325
+ principal: PostConditionPrincipalWire
326
+ conditionCode: number
327
+ amount: bigint
328
+ };
329
+ type FtPostConditionWire = {
330
+ type: "ft"
331
+ principal: PostConditionPrincipalWire
332
+ asset: AssetInfoWire
333
+ conditionCode: number
334
+ amount: bigint
335
+ };
336
+ type NftPostConditionWire = {
337
+ type: "nft"
338
+ principal: PostConditionPrincipalWire
339
+ asset: AssetInfoWire
340
+ conditionCode: number
341
+ assetId: ClarityValue
342
+ };
343
+ type PostConditionPrincipalWire = {
344
+ type: "origin"
345
+ } | {
346
+ type: "standard"
347
+ address: string
348
+ } | {
349
+ type: "contract"
350
+ address: string
351
+ contractName: string
352
+ };
353
+ type AssetInfoWire = {
354
+ address: string
355
+ contractName: string
356
+ assetName: string
357
+ };
358
+ type EstimateFeeParams = {
359
+ transaction: StacksTransaction
360
+ };
361
+ type FeeEstimation = {
362
+ feeRate: number
363
+ fee: number
364
+ };
365
+ declare function estimateFee(client: Client, params: EstimateFeeParams): Promise<FeeEstimation[]>;
366
+ type MulticallCall = {
367
+ contract: string
368
+ functionName: string
369
+ args?: ClarityValue[]
370
+ sender?: string
371
+ };
372
+ type MulticallParams<TAllowFailure extends boolean = true> = {
373
+ calls: readonly MulticallCall[]
374
+ allowFailure?: TAllowFailure
375
+ };
376
+ type MulticallSuccessResult = {
377
+ status: "success"
378
+ result: ClarityValue
379
+ };
380
+ type MulticallFailureResult = {
381
+ status: "failure"
382
+ error: Error
383
+ };
384
+ type MulticallResult<T extends boolean> = T extends true ? (MulticallSuccessResult | MulticallFailureResult)[] : ClarityValue[];
385
+ declare function multicall<TAllowFailure extends boolean = true>(client: Client, params: MulticallParams<TAllowFailure>): Promise<MulticallResult<TAllowFailure>>;
386
+ declare class BaseError extends Error {
387
+ name: string;
388
+ shortMessage: string;
389
+ details?: string;
390
+ constructor(shortMessage: string, options?: {
391
+ cause?: Error
392
+ details?: string
393
+ });
394
+ toJSON(): {};
395
+ }
396
+ declare class SimulationError extends BaseError {
397
+ name: string;
398
+ writesDetected: boolean;
399
+ constructor(message: string, options: {
400
+ writesDetected: boolean
401
+ details?: string
402
+ });
403
+ }
404
+ type SimulateCallParams = {
405
+ contract: string
406
+ functionName: string
407
+ args?: ClarityValue[]
408
+ sender?: string
409
+ tip?: string
410
+ };
411
+ type SimulateCallSuccess = {
412
+ success: true
413
+ result: ClarityValue
414
+ };
415
+ type SimulateCallFailure = {
416
+ success: false
417
+ error: SimulationError
418
+ };
419
+ type SimulateCallResult = SimulateCallSuccess | SimulateCallFailure;
420
+ declare function simulateCall(client: Client, params: SimulateCallParams): Promise<SimulateCallResult>;
421
+ type SimulateTransactionParams = {
422
+ transaction: StacksTransaction
423
+ sender?: string
424
+ tip?: string
425
+ };
426
+ type SimulateContractCallResult = {
427
+ type: "contract-call"
428
+ execution: SimulateCallResult
429
+ fees: FeeEstimation[]
430
+ };
431
+ type SimulateTransferResult = {
432
+ type: "token-transfer"
433
+ fees: FeeEstimation[]
434
+ };
435
+ type SimulateDeployResult = {
436
+ type: "contract-deploy"
437
+ fees: FeeEstimation[]
438
+ };
439
+ type SimulateTransactionResult = SimulateContractCallResult | SimulateTransferResult | SimulateDeployResult;
440
+ declare function simulateTransaction(client: Client, params: SimulateTransactionParams): Promise<SimulateTransactionResult>;
441
+ /** Handle returned by WebSocket subscription methods; call `unsubscribe()` to stop. */
442
+ type Subscription = {
443
+ unsubscribe: () => void
444
+ };
445
+ type BlockNotification = {
446
+ canonical: boolean
447
+ height: number
448
+ hash: string
449
+ index_block_hash: string
450
+ parent_block_hash: string
451
+ burn_block_height: number
452
+ burn_block_hash: string
453
+ parent_burn_block_hash: string
454
+ parent_burn_block_height: number
455
+ parent_index_block_hash: string
456
+ txs: string[]
457
+ };
458
+ type MempoolNotification = {
459
+ tx_id: string
460
+ tx_type: string
461
+ tx_status: string
462
+ receipt_time: number
463
+ receipt_time_iso: string
464
+ fee_rate: string
465
+ sender_address: string
466
+ sponsor_address?: string
467
+ nonce: number
468
+ contract_call?: {
469
+ contract_id: string
470
+ function_name: string
471
+ function_signature: string
472
+ }
473
+ token_transfer?: {
474
+ recipient_address: string
475
+ amount: string
476
+ memo: string
477
+ }
478
+ };
479
+ type TxUpdateNotification = {
480
+ tx_id: string
481
+ tx_type: string
482
+ tx_status: string
483
+ block_hash?: string
484
+ block_height?: number
485
+ burn_block_height?: number
486
+ burn_block_time?: number
487
+ tx_result?: {
488
+ hex: string
489
+ repr: string
490
+ }
491
+ };
492
+ type AddressTxNotification = {
493
+ address: string
494
+ tx_id: string
495
+ tx_type: string
496
+ tx_status: string
497
+ stx_sent: string
498
+ stx_received: string
499
+ stx_transfers: Array<{
500
+ amount: string
501
+ sender: string
502
+ recipient: string
503
+ }>
504
+ ft_transfers: Array<{
505
+ amount: string
506
+ asset_identifier: string
507
+ sender: string
508
+ recipient: string
509
+ }>
510
+ nft_transfers: Array<{
511
+ asset_identifier: string
512
+ sender: string
513
+ recipient: string
514
+ value: {
515
+ hex: string
516
+ repr: string
517
+ }
518
+ }>
519
+ };
520
+ type AddressBalanceNotification = {
521
+ address: string
522
+ balance: string
523
+ total_sent: string
524
+ total_received: string
525
+ total_fees_sent: string
526
+ total_miner_rewards_received: string
527
+ lock_tx_id: string
528
+ locked: string
529
+ lock_height: number
530
+ burnchain_lock_height: number
531
+ burnchain_unlock_height: number
532
+ };
533
+ type NftEventNotification = {
534
+ sender: string
535
+ recipient: string
536
+ asset_identifier: string
537
+ asset_event_type: string
538
+ value: {
539
+ hex: string
540
+ repr: string
541
+ }
542
+ tx_id: string
543
+ block_height: number
544
+ };
545
+ type WatchBlocksParams = {
546
+ onBlock: (block: BlockNotification) => void
547
+ };
548
+ declare function watchBlocks(client: Client, params: WatchBlocksParams): Promise<Subscription>;
549
+ type WatchMempoolParams = {
550
+ onTransaction: (tx: MempoolNotification) => void
551
+ };
552
+ declare function watchMempool(client: Client, params: WatchMempoolParams): Promise<Subscription>;
553
+ type WatchTransactionParams = {
554
+ txId: string
555
+ onUpdate: (update: TxUpdateNotification) => void
556
+ };
557
+ declare function watchTransaction(client: Client, params: WatchTransactionParams): Promise<Subscription>;
558
+ type WatchAddressParams = {
559
+ address: string
560
+ onTransaction: (tx: AddressTxNotification) => void
561
+ };
562
+ declare function watchAddress(client: Client, params: WatchAddressParams): Promise<Subscription>;
563
+ type WatchAddressBalanceParams = {
564
+ address: string
565
+ onBalance: (balance: AddressBalanceNotification) => void
566
+ };
567
+ declare function watchAddressBalance(client: Client, params: WatchAddressBalanceParams): Promise<Subscription>;
568
+ type WatchNftEventParams = {
569
+ onEvent: (event: NftEventNotification) => void
570
+ assetIdentifier?: string
571
+ value?: string
572
+ };
573
+ declare function watchNftEvent(client: Client, params: WatchNftEventParams): Promise<Subscription>;
574
+ type SendTransactionParams = {
575
+ transaction: StacksTransaction
576
+ attachment?: Uint8Array | string
577
+ };
578
+ type SendTransactionResult = {
579
+ txid: string
580
+ };
581
+ /** Broadcast a signed transaction to the network */
582
+ declare function sendTransaction(client: Client, params: SendTransactionParams): Promise<SendTransactionResult>;
583
+ type SignTransactionParams = {
584
+ transaction: StacksTransaction
585
+ /** Public keys for multi-sig signing (auto-detected from _multisig metadata if omitted) */
586
+ signers?: string[]
587
+ };
588
+ /** Sign a transaction using the client's account */
589
+ declare function signTransactionAction(client: Client, params: SignTransactionParams): Promise<StacksTransaction>;
590
+ type FungibleComparator = "eq" | "gt" | "gte" | "lt" | "lte";
591
+ type NonFungibleComparator = "sent" | "not-sent";
592
+ type StxPostCondition = {
593
+ type: "stx-postcondition"
594
+ address: string
595
+ condition: FungibleComparator
596
+ amount: string | bigint | number
597
+ };
598
+ type FtPostCondition = {
599
+ type: "ft-postcondition"
600
+ address: string
601
+ condition: FungibleComparator
602
+ asset: string
603
+ amount: string | bigint | number
604
+ };
605
+ type NftPostCondition = {
606
+ type: "nft-postcondition"
607
+ address: string
608
+ condition: NonFungibleComparator
609
+ asset: string
610
+ assetId: ClarityValue
611
+ };
612
+ type PostCondition = StxPostCondition | FtPostCondition | NftPostCondition;
613
+ type IntegerType = number | string | bigint | Uint8Array;
614
+ type TransferStxParams = {
615
+ to: string
616
+ amount: IntegerType
617
+ memo?: string
618
+ fee?: IntegerType
619
+ nonce?: IntegerType
620
+ postConditionMode?: "allow" | "deny"
621
+ postConditions?: PostCondition[]
622
+ };
623
+ /** Build, sign, and broadcast an STX transfer */
624
+ declare function transferStx(client: Client, params: TransferStxParams): Promise<string>;
625
+ type CallContractParams = {
626
+ contract: string
627
+ functionName: string
628
+ functionArgs?: ClarityValue[]
629
+ fee?: IntegerType
630
+ nonce?: IntegerType
631
+ postConditionMode?: "allow" | "deny"
632
+ postConditions?: PostCondition[]
633
+ };
634
+ /** Build, sign, and broadcast a contract call */
635
+ declare function callContract(client: Client, params: CallContractParams): Promise<string>;
636
+ type DeployContractParams = {
637
+ contractName: string
638
+ codeBody: string
639
+ clarityVersion?: ClarityVersion
640
+ fee?: IntegerType
641
+ nonce?: IntegerType
642
+ postConditionMode?: "allow" | "deny"
643
+ postConditions?: PostCondition[]
644
+ };
645
+ /** Build, sign, and broadcast a contract deploy */
646
+ declare function deployContract(client: Client, params: DeployContractParams): Promise<string>;
647
+ type SignMessageParams = {
648
+ message: string | ClarityValue
649
+ domain?: {
650
+ name: string
651
+ version: string
652
+ chainId: number
653
+ }
654
+ };
655
+ /** Sign a structured message per SIP-018 */
656
+ declare function signMessage2(client: Client, params: SignMessageParams): Promise<string>;
657
+ type SponsorTransactionParams = {
658
+ transaction: StacksTransaction
659
+ fee?: IntegerType
660
+ nonce?: IntegerType
661
+ };
662
+ /** Sponsor a transaction: set sponsor spending condition, sign as sponsor */
663
+ declare function sponsorTransaction(client: Client, params: SponsorTransactionParams): Promise<StacksTransaction>;
664
+ declare function isProviderAccount(account: Account): account is ProviderAccount;
665
+ type AbiUInt128 = "uint128";
666
+ type AbiInt128 = "int128";
667
+ type AbiBool = "bool";
668
+ type AbiPrincipal = "principal";
669
+ type AbiTraitReference = "trait_reference";
670
+ type AbiNone = "none";
671
+ type AbiStringAscii<L extends number = number> = {
672
+ "string-ascii": {
673
+ length: L
674
+ }
675
+ };
676
+ type AbiStringUtf8<L extends number = number> = {
677
+ "string-utf8": {
678
+ length: L
679
+ }
680
+ };
681
+ type AbiBuffer<L extends number = number> = {
682
+ buff: {
683
+ length: L
684
+ }
685
+ };
686
+ type AbiPrimitiveType = AbiUInt128 | AbiInt128 | AbiBool | AbiPrincipal | AbiTraitReference | AbiNone | AbiStringAscii | AbiStringUtf8 | AbiBuffer;
687
+ interface AbiListType {
688
+ list: {
689
+ type: AbiType
690
+ length: number
691
+ };
692
+ }
693
+ interface AbiTupleType {
694
+ tuple: ReadonlyArray<{
695
+ name: string
696
+ type: AbiType
697
+ }>;
698
+ }
699
+ interface AbiOptionalType {
700
+ optional: AbiType;
701
+ }
702
+ interface AbiResponseType {
703
+ response: {
704
+ ok: AbiType
705
+ error: AbiType
706
+ };
707
+ }
708
+ /** Discriminated union of all Clarity value types (primitives, buffers, lists, tuples, optionals, responses). */
709
+ type AbiType = AbiPrimitiveType | AbiListType | AbiTupleType | AbiOptionalType | AbiResponseType;
710
+ type CamelCaseInner<S extends string> = S extends `${infer P1}-${infer P2}${infer P3}` ? `${P1}${Capitalize<CamelCaseInner<`${P2}${P3}`>>}` : S;
711
+ type ToCamelCase<S extends string> = CamelCaseInner<S> extends `${number}${string}` ? `_${CamelCaseInner<S>}` : CamelCaseInner<S>;
712
+ declare function toCamelCase(str: string): string;
713
+ type TupleToObject<T extends ReadonlyArray<{
714
+ name: string
715
+ type: AbiType
716
+ }>> = { [K in T[number]["name"] as ToCamelCase<K>] : AbiToTS<Extract<T[number], {
717
+ name: K
718
+ }>["type"]> };
719
+ type AbiToTS<T extends AbiType> = T extends "none" ? never : T extends "uint128" ? bigint : T extends "int128" ? bigint : T extends "bool" ? boolean : T extends "principal" ? string : T extends "trait_reference" ? string : T extends {
720
+ "string-ascii": any
721
+ } ? string : T extends {
722
+ "string-utf8": any
723
+ } ? string : T extends {
724
+ buff: any
725
+ } ? Uint8Array : T extends {
726
+ list: {
727
+ type: infer U extends AbiType
728
+ }
729
+ } ? Array<AbiToTS<U>> : T extends {
730
+ optional: infer U extends AbiType
731
+ } ? AbiToTS<U> | null : T extends {
732
+ response: {
733
+ ok: infer O extends AbiType
734
+ error: infer E extends AbiType
735
+ }
736
+ } ? {
737
+ ok: AbiToTS<O>
738
+ } | {
739
+ err: AbiToTS<E>
740
+ } : T extends {
741
+ tuple: infer Fields extends ReadonlyArray<{
742
+ name: string
743
+ type: AbiType
744
+ }>
745
+ } ? TupleToObject<Fields> : never;
746
+ type FunctionAccess = "public" | "read-only" | "private";
747
+ interface FunctionArg {
748
+ name: string;
749
+ type: AbiType;
750
+ }
751
+ /** A single Clarity function definition with name, access level, arguments, and return type. */
752
+ interface AbiFunction {
753
+ name: string;
754
+ access: FunctionAccess;
755
+ args: ReadonlyArray<FunctionArg>;
756
+ outputs: AbiType;
757
+ }
758
+ type VariableAccess = "constant" | "variable";
759
+ interface AbiVariable {
760
+ name: string;
761
+ type: AbiType;
762
+ access: VariableAccess;
763
+ }
764
+ interface AbiMap {
765
+ name: string;
766
+ key: AbiType;
767
+ value: AbiType;
768
+ }
769
+ interface AbiFungibleToken {
770
+ name: string;
771
+ }
772
+ interface AbiNonFungibleToken {
773
+ name: string;
774
+ type: AbiType;
775
+ }
776
+ type TraitFunctionAccess = Exclude<FunctionAccess, "private">;
777
+ interface AbiTraitFunction {
778
+ name: string;
779
+ access: TraitFunctionAccess;
780
+ args: ReadonlyArray<FunctionArg>;
781
+ outputs: AbiType;
782
+ }
783
+ interface AbiTraitDefinition {
784
+ name: string;
785
+ functions: ReadonlyArray<AbiTraitFunction>;
786
+ }
787
+ /** Full Clarity contract ABI including functions, maps, variables, and token definitions. */
788
+ interface AbiContract {
789
+ functions: ReadonlyArray<AbiFunction>;
790
+ maps?: ReadonlyArray<AbiMap>;
791
+ variables?: ReadonlyArray<AbiVariable>;
792
+ fungible_tokens?: ReadonlyArray<AbiFungibleToken>;
793
+ non_fungible_tokens?: ReadonlyArray<AbiNonFungibleToken>;
794
+ implemented_traits?: ReadonlyArray<string>;
795
+ defined_traits?: ReadonlyArray<AbiTraitDefinition>;
796
+ }
797
+ type ExtractFunctionNames<
798
+ C extends AbiContract,
799
+ Access extends FunctionAccess = FunctionAccess
800
+ > = Extract<C["functions"][number], {
801
+ access: Access
802
+ }>["name"];
803
+ type ExtractFunction<
804
+ C extends AbiContract,
805
+ N extends ExtractFunctionNames<C>
806
+ > = Extract<C["functions"][number], {
807
+ name: N
808
+ }>;
809
+ type ExtractFunctionArgs<
810
+ C extends AbiContract,
811
+ N extends ExtractFunctionNames<C>
812
+ > = ExtractFunction<C, N> extends {
813
+ args: infer Args extends ReadonlyArray<{
814
+ name: string
815
+ type: any
816
+ }>
817
+ } ? { [K in Args[number]["name"] as ToCamelCase<K>] : AbiToTS<Extract<Args[number], {
818
+ name: K
819
+ }>["type"]> } : never;
820
+ type ExtractFunctionOutput<
821
+ C extends AbiContract,
822
+ N extends ExtractFunctionNames<C>
823
+ > = ExtractFunction<C, N> extends {
824
+ outputs: infer O extends AbiType
825
+ } ? AbiToTS<O> : never;
826
+ type ExtractPublicFunctions<C extends AbiContract> = ExtractFunctionNames<C, "public">;
827
+ type ExtractReadOnlyFunctions<C extends AbiContract> = ExtractFunctionNames<C, "read-only">;
828
+ type ExtractMapNames<C extends AbiContract> = C["maps"] extends ReadonlyArray<{
829
+ name: infer N extends string
830
+ }> ? N : never;
831
+ type ExtractMap<
832
+ C extends AbiContract,
833
+ N extends ExtractMapNames<C>
834
+ > = C["maps"] extends ReadonlyArray<infer M> ? Extract<M, {
835
+ name: N
836
+ }> : never;
837
+ type ExtractMapKey<
838
+ C extends AbiContract,
839
+ N extends ExtractMapNames<C>
840
+ > = ExtractMap<C, N> extends {
841
+ key: infer K extends AbiType
842
+ } ? AbiToTS<K> : never;
843
+ type ExtractMapValue<
844
+ C extends AbiContract,
845
+ N extends ExtractMapNames<C>
846
+ > = ExtractMap<C, N> extends {
847
+ value: infer V extends AbiType
848
+ } ? AbiToTS<V> : never;
849
+ /** Unwrap `(response ok err)` → just the `ok` branch type */
850
+ type UnwrapResponse<T> = T extends {
851
+ ok: infer O
852
+ } | {
853
+ err: any
854
+ } ? O : T;
855
+ type ReadMethodReturn<
856
+ C extends AbiContract,
857
+ N extends ExtractReadOnlyFunctions<C>
858
+ > = UnwrapResponse<ExtractFunctionOutput<C, N>>;
859
+ type ReadMethods<C extends AbiContract> = { [N in ExtractReadOnlyFunctions<C> as ToCamelCaseName<N>] : (args: ExtractFunctionArgs<C, N>) => Promise<ReadMethodReturn<C, N>> };
860
+ type CallMethods<C extends AbiContract> = { [N in ExtractPublicFunctions<C> as ToCamelCaseName<N>] : (args: ExtractFunctionArgs<C, N>, options?: ContractCallOptions) => Promise<string> };
861
+ type MapMethods<C extends AbiContract> = { [N in ExtractMapNames<C> as ToCamelCaseName<N>] : (key: ExtractMapKey<C, N>) => Promise<ExtractMapValue<C, N> | null> };
862
+ type ToCamelCaseName<S extends string> = S extends string ? ReturnType<typeof toCamelCase> extends string ? S : S : S;
863
+ type ContractCallOptions = {
864
+ fee?: IntegerType
865
+ nonce?: IntegerType
866
+ postConditionMode?: "allow" | "deny"
867
+ postConditions?: PostCondition[]
868
+ };
869
+ type ContractInstance<C extends AbiContract> = {
870
+ read: ReadMethods<C>
871
+ call: CallMethods<C>
872
+ maps: MapMethods<C>
873
+ };
874
+ type GetContractParams<C extends AbiContract> = {
875
+ client: Client
876
+ address: string
877
+ name: string
878
+ abi: C
879
+ };
880
+ declare function getContract<const TAbi extends AbiContract>(params: GetContractParams<TAbi>): ContractInstance<TAbi>;
881
+ declare class ContractResponseError extends Error {
882
+ readonly errorValue: unknown;
883
+ name: string;
884
+ constructor(message: string, errorValue: unknown);
885
+ }
886
+ export { watchTransaction, watchNftEvent, watchMempool, watchBlocks, watchAddressBalance, watchAddress, transferStx, sponsorTransaction, simulateTransaction, simulateCall, signTransactionAction, signMessage2 as signMessage, sendTransaction, readContract, multicall, isProviderAccount, getNonce, getMapEntry, getContractAbi, getContract, getBlockHeight, getBlock, getBalance, getAccountInfo, estimateFee, deployContract, callContract, WatchTransactionParams, WatchNftEventParams, WatchMempoolParams, WatchBlocksParams, WatchAddressParams, WatchAddressBalanceParams, TransferStxParams, SponsorTransactionParams, SimulateTransferResult, SimulateTransactionResult, SimulateTransactionParams, SimulateDeployResult, SimulateContractCallResult, SimulateCallSuccess, SimulateCallResult, SimulateCallParams, SimulateCallFailure, SignTransactionParams, SignMessageParams, SendTransactionResult, SendTransactionParams, ReadContractParams, MulticallSuccessResult, MulticallResult, MulticallParams, MulticallFailureResult, MulticallCall, GetNonceParams, GetMapEntryParams, GetContractParams, GetContractAbiParams, GetBlockParams, GetBalanceParams, GetAccountInfoParams, FeeEstimation, EstimateFeeParams, DeployContractParams, ContractResponseError, ContractInstance, ContractCallOptions, CallContractParams, AccountInfo };