@secondlayer/stacks 2.10.0 → 2.12.0

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 (118) hide show
  1. package/README.md +24 -0
  2. package/dist/shared/{stacks-4t2vmp4y.js → stacks-01pbr7gf.js} +17 -16
  3. package/dist/shared/stacks-01pbr7gf.js.map +11 -0
  4. package/dist/shared/{stacks-wyxj879g.cjs → stacks-18jv9aen.js} +83 -4
  5. package/dist/shared/stacks-18jv9aen.js.map +13 -0
  6. package/dist/shared/{stacks-0zysn74p.js → stacks-2mm20wqf.js} +3 -3
  7. package/dist/shared/{stacks-hxm7r5ay.cjs → stacks-44y18a8e.cjs} +3 -10
  8. package/dist/shared/stacks-44y18a8e.cjs.map +10 -0
  9. package/dist/shared/{stacks-2dhf79w5.js → stacks-59xy6t1p.js} +33 -31
  10. package/dist/shared/{stacks-2dhf79w5.js.map → stacks-59xy6t1p.js.map} +6 -6
  11. package/dist/shared/{stacks-99ghanwx.js → stacks-6n2m9hyk.js} +56 -6
  12. package/dist/shared/stacks-6n2m9hyk.js.map +10 -0
  13. package/dist/shared/{stacks-g7ffp8aj.js → stacks-6xt8py97.cjs} +59 -30
  14. package/dist/shared/stacks-6xt8py97.cjs.map +13 -0
  15. package/dist/shared/stacks-azp00pve.js +70 -0
  16. package/dist/shared/stacks-azp00pve.js.map +11 -0
  17. package/dist/shared/{stacks-vk8fwz0t.cjs → stacks-b9904rc2.cjs} +3 -2
  18. package/dist/shared/{stacks-vk8fwz0t.cjs.map → stacks-b9904rc2.cjs.map} +2 -2
  19. package/dist/shared/stacks-esn3wcw5.cjs +416 -0
  20. package/dist/shared/stacks-esn3wcw5.cjs.map +18 -0
  21. package/dist/shared/{stacks-3y058qda.cjs → stacks-fhzwsn5d.cjs} +16 -2
  22. package/dist/shared/{stacks-3y058qda.cjs.map → stacks-fhzwsn5d.cjs.map} +5 -4
  23. package/dist/shared/{stacks-e60vrr34.js → stacks-g11v9a35.js} +4 -4
  24. package/dist/shared/{stacks-0ek3cyt8.js → stacks-g67f4w1d.js} +7 -14
  25. package/dist/shared/stacks-g67f4w1d.js.map +10 -0
  26. package/dist/shared/{stacks-6xmk24yw.js → stacks-gfm3r397.cjs} +20 -7
  27. package/dist/shared/stacks-gfm3r397.cjs.map +11 -0
  28. package/dist/shared/{stacks-43cxvnr7.js → stacks-jbmcwky5.js} +3 -3
  29. package/dist/shared/stacks-kjg7fw4y.js +434 -0
  30. package/dist/shared/stacks-kjg7fw4y.js.map +18 -0
  31. package/dist/shared/{stacks-q1mjkt15.js → stacks-msmgyerb.js} +4 -4
  32. package/dist/shared/{stacks-2h8d2y27.js → stacks-qs5fzts5.js} +17 -3
  33. package/dist/shared/{stacks-2h8d2y27.js.map → stacks-qs5fzts5.js.map} +5 -4
  34. package/dist/shared/{stacks-xw0j252s.cjs → stacks-shn9zw99.cjs} +43 -3
  35. package/dist/shared/stacks-shn9zw99.cjs.map +10 -0
  36. package/dist/shared/{stacks-vf0ekgwb.js → stacks-ssndnbbd.js} +8 -10
  37. package/dist/shared/{stacks-vf0ekgwb.js.map → stacks-ssndnbbd.js.map} +2 -2
  38. package/dist/shared/{stacks-maamjqma.cjs → stacks-tbv5p6pn.cjs} +7 -9
  39. package/dist/shared/stacks-tbv5p6pn.cjs.map +11 -0
  40. package/dist/shared/{stacks-a36n7sjz.js → stacks-x94a1d6s.js} +3 -3
  41. package/dist/shared/{stacks-k5an9zcw.cjs → stacks-y5epf0sb.cjs} +19 -22
  42. package/dist/shared/{stacks-k5an9zcw.cjs.map → stacks-y5epf0sb.cjs.map} +6 -6
  43. package/dist/src/accounts/index.js +3 -5
  44. package/dist/src/accounts/index.js.map +2 -2
  45. package/dist/src/actions/index.cjs +8 -1
  46. package/dist/src/actions/index.cjs.map +1 -1
  47. package/dist/src/actions/index.d.cts +198 -13
  48. package/dist/src/actions/index.d.ts +198 -13
  49. package/dist/src/actions/index.js +29 -17
  50. package/dist/src/actions/index.js.map +1 -1
  51. package/dist/src/bitcoin/index.js +8 -11
  52. package/dist/src/bitcoin/index.js.map +2 -2
  53. package/dist/src/bns/index.js +12 -14
  54. package/dist/src/bns/index.js.map +2 -2
  55. package/dist/src/clarity/index.d.cts +50 -1
  56. package/dist/src/clarity/index.d.ts +50 -1
  57. package/dist/src/clarity/index.js +8 -7
  58. package/dist/src/clarity/index.js.map +1 -1
  59. package/dist/src/index.cjs +10 -1
  60. package/dist/src/index.cjs.map +3 -3
  61. package/dist/src/index.d.cts +167 -9
  62. package/dist/src/index.d.ts +167 -9
  63. package/dist/src/index.js +30 -17
  64. package/dist/src/index.js.map +3 -3
  65. package/dist/src/postconditions/index.js +3 -3
  66. package/dist/src/pox/index.js +11 -13
  67. package/dist/src/pox/index.js.map +2 -2
  68. package/dist/src/sbtc/index.js +10 -12
  69. package/dist/src/sbtc/index.js.map +2 -2
  70. package/dist/src/stackingdao/index.js +11 -13
  71. package/dist/src/stackingdao/index.js.map +2 -2
  72. package/dist/src/tools/index.cjs +348 -63
  73. package/dist/src/tools/index.cjs.map +18 -15
  74. package/dist/src/tools/index.js +348 -63
  75. package/dist/src/tools/index.js.map +18 -15
  76. package/dist/src/transactions/index.js +6 -7
  77. package/dist/src/transactions/index.js.map +1 -1
  78. package/dist/src/utils/index.cjs +2 -1
  79. package/dist/src/utils/index.cjs.map +2 -2
  80. package/dist/src/utils/index.d.cts +5 -1
  81. package/dist/src/utils/index.d.ts +5 -1
  82. package/dist/src/utils/index.js +12 -14
  83. package/dist/src/utils/index.js.map +2 -2
  84. package/dist/src/x402/index.cjs +5 -2
  85. package/dist/src/x402/index.cjs.map +3 -3
  86. package/dist/src/x402/index.d.cts +36 -0
  87. package/dist/src/x402/index.d.ts +36 -0
  88. package/dist/src/x402/index.js +13 -11
  89. package/dist/src/x402/index.js.map +3 -3
  90. package/package.json +1 -1
  91. package/dist/shared/stacks-0ek3cyt8.js.map +0 -10
  92. package/dist/shared/stacks-4t2vmp4y.js.map +0 -11
  93. package/dist/shared/stacks-6xmk24yw.js.map +0 -10
  94. package/dist/shared/stacks-99ghanwx.js.map +0 -10
  95. package/dist/shared/stacks-9g0jhab3.cjs +0 -40
  96. package/dist/shared/stacks-9g0jhab3.cjs.map +0 -10
  97. package/dist/shared/stacks-9t68zmpn.js +0 -210
  98. package/dist/shared/stacks-9t68zmpn.js.map +0 -15
  99. package/dist/shared/stacks-fcaefc5b.cjs +0 -16
  100. package/dist/shared/stacks-fcaefc5b.cjs.map +0 -10
  101. package/dist/shared/stacks-g7ffp8aj.js.map +0 -13
  102. package/dist/shared/stacks-hxm7r5ay.cjs.map +0 -10
  103. package/dist/shared/stacks-maamjqma.cjs.map +0 -11
  104. package/dist/shared/stacks-v9jqcpd4.js +0 -18
  105. package/dist/shared/stacks-v9jqcpd4.js.map +0 -10
  106. package/dist/shared/stacks-wyxj879g.cjs.map +0 -13
  107. package/dist/shared/stacks-xmsms921.cjs +0 -196
  108. package/dist/shared/stacks-xmsms921.cjs.map +0 -15
  109. package/dist/shared/stacks-xw0j252s.cjs.map +0 -10
  110. package/dist/shared/stacks-xxn5ma6g.js +0 -22
  111. package/dist/shared/stacks-xxn5ma6g.js.map +0 -10
  112. package/dist/shared/stacks-ya3x01yd.cjs +0 -16
  113. package/dist/shared/stacks-ya3x01yd.cjs.map +0 -10
  114. /package/dist/shared/{stacks-0zysn74p.js.map → stacks-2mm20wqf.js.map} +0 -0
  115. /package/dist/shared/{stacks-e60vrr34.js.map → stacks-g11v9a35.js.map} +0 -0
  116. /package/dist/shared/{stacks-43cxvnr7.js.map → stacks-jbmcwky5.js.map} +0 -0
  117. /package/dist/shared/{stacks-q1mjkt15.js.map → stacks-msmgyerb.js.map} +0 -0
  118. /package/dist/shared/{stacks-a36n7sjz.js.map → stacks-x94a1d6s.js.map} +0 -0
@@ -581,6 +581,78 @@ type GetMapEntryParams = {
581
581
  type GetNonceParams = {
582
582
  address: string
583
583
  };
584
+ /**
585
+ * Pluggable transaction-status sources for {@link getTransaction} /
586
+ * `waitForTransactionReceipt`.
587
+ *
588
+ * A bare stacks-node has no confirmed-transaction endpoint, so status reads
589
+ * need a host that indexes transactions. Where that data comes from is
590
+ * pluggable, mirroring the nonce sources:
591
+ *
592
+ * - {@link extendedApiSource} — default; `/extended/v1/tx/{txid}` on the
593
+ * client's transport host (Hiro API or any extended-API-compatible host).
594
+ * - {@link indexTxSource} — Secondlayer's `/v1/index/transactions/{txid}`;
595
+ * returns the chain tip in the same response, so N-confirmation waits
596
+ * need no second request.
597
+ */
598
+ type TransactionStatus = "pending" | "success" | "abort_by_response" | "abort_by_post_condition" | "dropped";
599
+ type TransactionReceipt = {
600
+ txid: string
601
+ status: TransactionStatus
602
+ /** Anchor block height; absent while pending. */
603
+ blockHeight?: number
604
+ blockHash?: string
605
+ /** Decoded Clarity result; absent while pending or when the source omits it. */
606
+ result?: ClarityValue
607
+ resultHex?: string
608
+ events: unknown[]
609
+ /** The source's unnormalized response, for fields the receipt doesn't model. */
610
+ raw: unknown
611
+ };
612
+ type TransactionSnapshot = {
613
+ /** `null` when the source has no record of the tx (mempool + chain). */
614
+ receipt: TransactionReceipt | null
615
+ /** Chain tip height, when the source knows it (saves a round-trip). */
616
+ tip?: number
617
+ };
618
+ type TransactionStatusSource = {
619
+ get(args: {
620
+ client: Client
621
+ txid: string
622
+ }): Promise<TransactionSnapshot>
623
+ };
624
+ type FetchImpl = typeof globalThis.fetch;
625
+ /**
626
+ * Default source: `GET /extended/v1/tx/{txid}` via the client's transport.
627
+ * Requires a host that serves Hiro's extended API (a bare stacks-node does
628
+ * not). Does not report the chain tip — the wait action fetches it separately
629
+ * when `confirmations > 1`.
630
+ */
631
+ declare function extendedApiSource(): TransactionStatusSource;
632
+ type IndexTxSourceParams = {
633
+ /** Base URL of a Secondlayer-shaped index API. */
634
+ baseUrl?: string
635
+ apiKey?: string
636
+ fetchImpl?: FetchImpl
637
+ };
638
+ /**
639
+ * Source backed by Secondlayer's `/v1/index/transactions/{txid}`. The response
640
+ * embeds the chain tip, so N-confirmation math needs no extra request. The
641
+ * index only returns canonical (mined) transactions — while a tx is in the
642
+ * mempool this source reports `receipt: null`, and the wait action's grace
643
+ * window carries it until inclusion.
644
+ */
645
+ declare function indexTxSource(params?: IndexTxSourceParams): TransactionStatusSource;
646
+ type GetTransactionParams = {
647
+ txid: string
648
+ /** Where to read status from. Defaults to {@link extendedApiSource}. */
649
+ source?: TransactionStatusSource
650
+ };
651
+ /**
652
+ * Fetch a transaction's receipt (status, block info, decoded result).
653
+ * Returns `null` when the source has no record of the transaction.
654
+ */
655
+ declare function getTransaction2(client: Client, params: GetTransactionParams): Promise<TransactionReceipt | null>;
584
656
  type MulticallCall = {
585
657
  contract: string
586
658
  functionName: string
@@ -665,6 +737,37 @@ type SimulateDeployResult = {
665
737
  fees: FeeEstimation[]
666
738
  };
667
739
  type SimulateTransactionResult = SimulateContractCallResult | SimulateTransferResult | SimulateDeployResult;
740
+ type WaitForTransactionReceiptParams = {
741
+ txid: string
742
+ /** Anchor-block confirmations to wait for. Default 1 (mined). */
743
+ confirmations?: number
744
+ /** Give up after this many ms. Default 180_000 (3 min). */
745
+ timeout?: number
746
+ /** Delay between status polls, ms. Default 3_000. */
747
+ pollingInterval?: number
748
+ /**
749
+ * How long a tx may be unknown to the source before it counts as dropped,
750
+ * ms. Covers broadcast propagation lag and canonical-only sources that
751
+ * can't see the mempool. Default 30_000.
752
+ */
753
+ droppedGracePeriod?: number
754
+ /** Where to read status from. Defaults to {@link extendedApiSource}. */
755
+ source?: TransactionStatusSource
756
+ };
757
+ /**
758
+ * Poll until a transaction is mined with N confirmations, then return its
759
+ * receipt.
760
+ *
761
+ * Rejects with {@link TransactionAbortedError} when the tx mines but aborts
762
+ * (`abort_by_response` / `abort_by_post_condition`) — the receipt is attached.
763
+ * Rejects with {@link TransactionDroppedError} when the tx leaves the mempool
764
+ * unmined or stays unknown past `droppedGracePeriod`, and
765
+ * {@link WaitForTransactionTimeoutError} at `timeout`.
766
+ *
767
+ * Reorg-tolerant: every cycle re-reads the receipt (block height may change)
768
+ * and recomputes confirmations from the current tip.
769
+ */
770
+ declare function waitForTransactionReceipt2(client: Client, params: WaitForTransactionReceiptParams): Promise<TransactionReceipt>;
668
771
  /** Handle returned by WebSocket subscription methods; call `unsubscribe()` to stop. */
669
772
  type Subscription = {
670
773
  unsubscribe: () => void
@@ -814,6 +917,8 @@ type PublicActions = {
814
917
  multicall: <T extends boolean = true>(params: MulticallParams<T>) => Promise<MulticallResult<T>>
815
918
  simulateCall: (params: SimulateCallParams) => Promise<SimulateCallResult>
816
919
  simulateTransaction: (params: SimulateTransactionParams) => Promise<SimulateTransactionResult>
920
+ getTransaction: (params: GetTransactionParams) => Promise<TransactionReceipt | null>
921
+ waitForTransactionReceipt: (params: WaitForTransactionReceiptParams) => Promise<TransactionReceipt>
817
922
  watchBlocks: (params: WatchBlocksParams) => Promise<Subscription>
818
923
  watchMempool: (params: WatchMempoolParams) => Promise<Subscription>
819
924
  watchTransaction: (params: WatchTransactionParams) => Promise<Subscription>
@@ -866,11 +971,19 @@ type PoxPostCondition = {
866
971
  };
867
972
  type PostCondition = StxPostCondition | FtPostCondition | NftPostCondition | StakingPostCondition | PoxPostCondition;
868
973
  type IntegerType = number | string | bigint | Uint8Array;
974
+ /**
975
+ * Named fee tiers. `'low' | 'mid' | 'high'` map to the node's three fee
976
+ * estimations; `'min'` is the node's minimum relay fee — 1 uSTX per byte of
977
+ * the serialized transaction, computable offline.
978
+ */
979
+ type FeeTier = "min" | "low" | "mid" | "high";
980
+ /** Fee input accepted by wallet actions: an explicit amount or a named tier. */
981
+ type FeeParam = IntegerType | FeeTier;
869
982
  type CallContractParams = {
870
983
  contract: string
871
984
  functionName: string
872
985
  functionArgs?: ClarityValue[]
873
- fee?: IntegerType
986
+ fee?: FeeParam
874
987
  nonce?: IntegerType
875
988
  postConditionMode?: "allow" | "deny"
876
989
  postConditions?: PostCondition[]
@@ -879,7 +992,7 @@ type DeployContractParams = {
879
992
  contractName: string
880
993
  codeBody: string
881
994
  clarityVersion?: ClarityVersion
882
- fee?: IntegerType
995
+ fee?: FeeParam
883
996
  nonce?: IntegerType
884
997
  postConditionMode?: "allow" | "deny"
885
998
  postConditions?: PostCondition[]
@@ -887,9 +1000,17 @@ type DeployContractParams = {
887
1000
  type SendTransactionParams = {
888
1001
  transaction: StacksTransaction
889
1002
  attachment?: Uint8Array | string
1003
+ /**
1004
+ * Wait for the transaction to be mined before returning. `true` waits for
1005
+ * 1 confirmation; a number waits for that many. The receipt lands on the
1006
+ * result. Rejects if the tx aborts, is dropped, or the wait times out.
1007
+ */
1008
+ wait?: boolean | number
890
1009
  };
891
1010
  type SendTransactionResult = {
892
1011
  txid: string
1012
+ /** Present when `wait` was requested. */
1013
+ receipt?: TransactionReceipt
893
1014
  };
894
1015
  type SignMessageParams = {
895
1016
  message: string | ClarityValue
@@ -906,14 +1027,14 @@ type SignTransactionParams = {
906
1027
  };
907
1028
  type SponsorTransactionParams = {
908
1029
  transaction: StacksTransaction
909
- fee?: IntegerType
1030
+ fee?: FeeParam
910
1031
  nonce?: IntegerType
911
1032
  };
912
1033
  type TransferStxParams = {
913
1034
  to: string
914
1035
  amount: IntegerType
915
1036
  memo?: string
916
- fee?: IntegerType
1037
+ fee?: FeeParam
917
1038
  nonce?: IntegerType
918
1039
  postConditionMode?: "allow" | "deny"
919
1040
  postConditions?: PostCondition[]
@@ -1052,7 +1173,7 @@ declare function postgresStore(params: PostgresStoreParams): NonceStore;
1052
1173
  * - {@link indexSource} — prebuilt over Secondlayer's `/v1/index/mempool`.
1053
1174
  * - {@link hiroNonceSource} — prebuilt over Hiro's `/extended` nonces endpoint.
1054
1175
  */
1055
- type FetchImpl = typeof globalThis.fetch;
1176
+ type FetchImpl2 = typeof globalThis.fetch;
1056
1177
  /**
1057
1178
  * The next free nonce ≥ `confirmed` not already taken by a pending tx.
1058
1179
  *
@@ -1088,7 +1209,7 @@ type IndexSourceParams = {
1088
1209
  baseUrl?: string
1089
1210
  /** Optional API key (keyless by default; supply to raise rate limits). */
1090
1211
  apiKey?: string
1091
- fetchImpl?: FetchImpl
1212
+ fetchImpl?: FetchImpl2
1092
1213
  /** Max mempool pages to page through per address. Default 10 (×200 = 2000 txs). */
1093
1214
  maxPages?: number
1094
1215
  /** Override the confirmed floor (defaults to the node read). */
@@ -1108,7 +1229,7 @@ type HiroNonceSourceParams = {
1108
1229
  /** Hiro API base URL, e.g. `https://api.hiro.so` or `https://api.testnet.hiro.so`. */
1109
1230
  baseUrl: string
1110
1231
  apiKey?: string
1111
- fetchImpl?: FetchImpl
1232
+ fetchImpl?: FetchImpl2
1112
1233
  };
1113
1234
  /**
1114
1235
  * Off-the-shelf, non-Secondlayer mempool-aware source over Hiro's
@@ -1350,14 +1471,51 @@ declare function getContractAddress(deployer: string, contractName: string): str
1350
1471
  declare class TransactionError extends BaseError {
1351
1472
  name: string;
1352
1473
  }
1474
+ /**
1475
+ * Rejection reasons a stacks-node returns from `POST /v2/transactions`.
1476
+ * Wire strings from stacks-core `MemPoolRejection::into_json`
1477
+ * (`stackslib/src/chainstate/stacks/db/blocks.rs`).
1478
+ */
1479
+ type TxRejectionReason = "Serialization" | "Deserialization" | "SignatureValidation" | "BadNonce" | "ConflictingNonceInMempool" | "TooMuchChaining" | "FeeTooLow" | "NotEnoughFunds" | "NoSuchContract" | "NoSuchPublicFunction" | "BadFunctionArgument" | "ContractAlreadyExists" | "BadTransactionVersion" | "TransferRecipientCannotEqualSender" | "TransferAmountMustBePositive" | "PoisonMicroblocksDoNotConflict" | "PoisonMicroblockHasUnknownPubKeyHash" | "PoisonMicroblockIsInvalid" | "BadAddressVersionByte" | "NoCoinbaseViaMempool" | "NoTenureChangeViaMempool" | "EstimatorError" | "TemporarilyBlacklisted" | "ServerFailureNoSuchChainTip" | "ServerFailureDatabase" | "ServerFailureOther";
1353
1480
  declare class BroadcastError extends BaseError {
1354
1481
  name: string;
1355
1482
  txid?: string;
1356
- reason?: string;
1483
+ reason?: TxRejectionReason | (string & {});
1484
+ /** Node-provided detail; shape varies per reason (see stacks-core RPC docs). */
1485
+ reasonData?: unknown;
1357
1486
  constructor(message: string, options?: {
1358
1487
  cause?: Error
1359
1488
  txid?: string
1360
1489
  reason?: string
1490
+ reasonData?: unknown
1491
+ });
1492
+ }
1493
+ /** The transaction was mined but its execution aborted (runtime error or failed post-condition). */
1494
+ declare class TransactionAbortedError extends BaseError {
1495
+ name: string;
1496
+ /** The abort receipt (status, block info, raw source response). */
1497
+ receipt: unknown;
1498
+ constructor(message: string, options: {
1499
+ receipt: unknown
1500
+ cause?: Error
1501
+ });
1502
+ }
1503
+ /** The transaction left the mempool without being mined (dropped/replaced). */
1504
+ declare class TransactionDroppedError extends BaseError {
1505
+ name: string;
1506
+ txid: string;
1507
+ constructor(message: string, options: {
1508
+ txid: string
1509
+ cause?: Error
1510
+ });
1511
+ }
1512
+ /** waitForTransactionReceipt gave up before the tx reached the requested state. */
1513
+ declare class WaitForTransactionTimeoutError extends BaseError {
1514
+ name: string;
1515
+ txid: string;
1516
+ constructor(message: string, options: {
1517
+ txid: string
1518
+ cause?: Error
1361
1519
  });
1362
1520
  }
1363
1521
  declare class SerializationError extends BaseError {
@@ -1375,4 +1533,4 @@ declare class ReadOnlyCallError extends BaseError {
1375
1533
  declare class WebSocketError extends BaseError {
1376
1534
  name: string;
1377
1535
  }
1378
- export { webSocket, walletActions, testnet, startNonceReconciler, resolveNonce, redisStore, reconcileNonce, publicActions, providerToAccount, postgresStore, parseStx, exports_on as on, nextFreeNonce, multisigActions, mocknet, mempoolAwareSource, memoryStore, mainnet, jsonRpcSource, isValidAddress, isNonceConflictError, isAddressEqual, indexSource, http, hiroNonceSource, getContractAddress, formatStx, fallback, devnet, defineChain, custom, createWalletClient, createPublicClient, createNonceManager, createMultiSigClient, createClient, broadcastWithNonceReset, ZERO_ADDRESS, WebSocketTransportConfig, WebSocketTransport, WebSocketError, WalletClientConfig, WalletClient, WalletActions, TransportFactory, TransportConfig, Transport, TransactionError, TESTNET_ZERO_ADDRESS, SubscriptionFilterSpec, Subscription, StartNonceReconcilerParams, StacksProvider, StacksChain, SqlLike, SimulationError, SigningError, SerializationError, RequestOptions, RequestFn, RedisStoreParams, RedisLike, ReconcileNonceResult, ReconcileNonceParams, ReadOnlyCallError, PublicClientConfig, PublicClient, PublicActions, ProviderAccount, PoxFunction, PostgresStoreParams, NonceStore, NonceManagerSource, NonceManager, MultiSigClientConfig, MultiSigClient, MultiSigActions, MempoolAwareSourceParams, MICROSTX_PER_STX, LocalAccount, IndexSourceParams, HiroNonceSourceParams, FilterPrimitive, FilterOperator, FilterClause, Filter, FactoryTarget, CustomAccount, CreateNonceManagerParams, ContractCallError, ClientConfig, Client, BroadcastError, BnsAction, BaseError, AddressVersion, Account };
1536
+ export { webSocket, walletActions, waitForTransactionReceipt2 as waitForTransactionReceipt, testnet, startNonceReconciler, resolveNonce, redisStore, reconcileNonce, publicActions, providerToAccount, postgresStore, parseStx, exports_on as on, nextFreeNonce, multisigActions, mocknet, mempoolAwareSource, memoryStore, mainnet, jsonRpcSource, isValidAddress, isNonceConflictError, isAddressEqual, indexTxSource, indexSource, http, hiroNonceSource, getTransaction2 as getTransaction, getContractAddress, formatStx, fallback, extendedApiSource, devnet, defineChain, custom, createWalletClient, createPublicClient, createNonceManager, createMultiSigClient, createClient, broadcastWithNonceReset, ZERO_ADDRESS, WebSocketTransportConfig, WebSocketTransport, WebSocketError, WalletClientConfig, WalletClient, WalletActions, WaitForTransactionTimeoutError, WaitForTransactionReceiptParams, TxRejectionReason, TransportFactory, TransportConfig, Transport, TransactionStatusSource, TransactionStatus, TransactionSnapshot, TransactionReceipt, TransactionError, TransactionDroppedError, TransactionAbortedError, TESTNET_ZERO_ADDRESS, SubscriptionFilterSpec, Subscription, StartNonceReconcilerParams, StacksProvider, StacksChain, SqlLike, SimulationError, SigningError, SerializationError, RequestOptions, RequestFn, RedisStoreParams, RedisLike, ReconcileNonceResult, ReconcileNonceParams, ReadOnlyCallError, PublicClientConfig, PublicClient, PublicActions, ProviderAccount, PoxFunction, PostgresStoreParams, NonceStore, NonceManagerSource, NonceManager, MultiSigClientConfig, MultiSigClient, MultiSigActions, MempoolAwareSourceParams, MICROSTX_PER_STX, LocalAccount, IndexTxSourceParams, IndexSourceParams, HiroNonceSourceParams, GetTransactionParams, FilterPrimitive, FilterOperator, FilterClause, Filter, FactoryTarget, CustomAccount, CreateNonceManagerParams, ContractCallError, ClientConfig, Client, BroadcastError, BnsAction, BaseError, AddressVersion, Account };
@@ -581,6 +581,78 @@ type GetMapEntryParams = {
581
581
  type GetNonceParams = {
582
582
  address: string
583
583
  };
584
+ /**
585
+ * Pluggable transaction-status sources for {@link getTransaction} /
586
+ * `waitForTransactionReceipt`.
587
+ *
588
+ * A bare stacks-node has no confirmed-transaction endpoint, so status reads
589
+ * need a host that indexes transactions. Where that data comes from is
590
+ * pluggable, mirroring the nonce sources:
591
+ *
592
+ * - {@link extendedApiSource} — default; `/extended/v1/tx/{txid}` on the
593
+ * client's transport host (Hiro API or any extended-API-compatible host).
594
+ * - {@link indexTxSource} — Secondlayer's `/v1/index/transactions/{txid}`;
595
+ * returns the chain tip in the same response, so N-confirmation waits
596
+ * need no second request.
597
+ */
598
+ type TransactionStatus = "pending" | "success" | "abort_by_response" | "abort_by_post_condition" | "dropped";
599
+ type TransactionReceipt = {
600
+ txid: string
601
+ status: TransactionStatus
602
+ /** Anchor block height; absent while pending. */
603
+ blockHeight?: number
604
+ blockHash?: string
605
+ /** Decoded Clarity result; absent while pending or when the source omits it. */
606
+ result?: ClarityValue
607
+ resultHex?: string
608
+ events: unknown[]
609
+ /** The source's unnormalized response, for fields the receipt doesn't model. */
610
+ raw: unknown
611
+ };
612
+ type TransactionSnapshot = {
613
+ /** `null` when the source has no record of the tx (mempool + chain). */
614
+ receipt: TransactionReceipt | null
615
+ /** Chain tip height, when the source knows it (saves a round-trip). */
616
+ tip?: number
617
+ };
618
+ type TransactionStatusSource = {
619
+ get(args: {
620
+ client: Client
621
+ txid: string
622
+ }): Promise<TransactionSnapshot>
623
+ };
624
+ type FetchImpl = typeof globalThis.fetch;
625
+ /**
626
+ * Default source: `GET /extended/v1/tx/{txid}` via the client's transport.
627
+ * Requires a host that serves Hiro's extended API (a bare stacks-node does
628
+ * not). Does not report the chain tip — the wait action fetches it separately
629
+ * when `confirmations > 1`.
630
+ */
631
+ declare function extendedApiSource(): TransactionStatusSource;
632
+ type IndexTxSourceParams = {
633
+ /** Base URL of a Secondlayer-shaped index API. */
634
+ baseUrl?: string
635
+ apiKey?: string
636
+ fetchImpl?: FetchImpl
637
+ };
638
+ /**
639
+ * Source backed by Secondlayer's `/v1/index/transactions/{txid}`. The response
640
+ * embeds the chain tip, so N-confirmation math needs no extra request. The
641
+ * index only returns canonical (mined) transactions — while a tx is in the
642
+ * mempool this source reports `receipt: null`, and the wait action's grace
643
+ * window carries it until inclusion.
644
+ */
645
+ declare function indexTxSource(params?: IndexTxSourceParams): TransactionStatusSource;
646
+ type GetTransactionParams = {
647
+ txid: string
648
+ /** Where to read status from. Defaults to {@link extendedApiSource}. */
649
+ source?: TransactionStatusSource
650
+ };
651
+ /**
652
+ * Fetch a transaction's receipt (status, block info, decoded result).
653
+ * Returns `null` when the source has no record of the transaction.
654
+ */
655
+ declare function getTransaction2(client: Client, params: GetTransactionParams): Promise<TransactionReceipt | null>;
584
656
  type MulticallCall = {
585
657
  contract: string
586
658
  functionName: string
@@ -665,6 +737,37 @@ type SimulateDeployResult = {
665
737
  fees: FeeEstimation[]
666
738
  };
667
739
  type SimulateTransactionResult = SimulateContractCallResult | SimulateTransferResult | SimulateDeployResult;
740
+ type WaitForTransactionReceiptParams = {
741
+ txid: string
742
+ /** Anchor-block confirmations to wait for. Default 1 (mined). */
743
+ confirmations?: number
744
+ /** Give up after this many ms. Default 180_000 (3 min). */
745
+ timeout?: number
746
+ /** Delay between status polls, ms. Default 3_000. */
747
+ pollingInterval?: number
748
+ /**
749
+ * How long a tx may be unknown to the source before it counts as dropped,
750
+ * ms. Covers broadcast propagation lag and canonical-only sources that
751
+ * can't see the mempool. Default 30_000.
752
+ */
753
+ droppedGracePeriod?: number
754
+ /** Where to read status from. Defaults to {@link extendedApiSource}. */
755
+ source?: TransactionStatusSource
756
+ };
757
+ /**
758
+ * Poll until a transaction is mined with N confirmations, then return its
759
+ * receipt.
760
+ *
761
+ * Rejects with {@link TransactionAbortedError} when the tx mines but aborts
762
+ * (`abort_by_response` / `abort_by_post_condition`) — the receipt is attached.
763
+ * Rejects with {@link TransactionDroppedError} when the tx leaves the mempool
764
+ * unmined or stays unknown past `droppedGracePeriod`, and
765
+ * {@link WaitForTransactionTimeoutError} at `timeout`.
766
+ *
767
+ * Reorg-tolerant: every cycle re-reads the receipt (block height may change)
768
+ * and recomputes confirmations from the current tip.
769
+ */
770
+ declare function waitForTransactionReceipt2(client: Client, params: WaitForTransactionReceiptParams): Promise<TransactionReceipt>;
668
771
  /** Handle returned by WebSocket subscription methods; call `unsubscribe()` to stop. */
669
772
  type Subscription = {
670
773
  unsubscribe: () => void
@@ -814,6 +917,8 @@ type PublicActions = {
814
917
  multicall: <T extends boolean = true>(params: MulticallParams<T>) => Promise<MulticallResult<T>>
815
918
  simulateCall: (params: SimulateCallParams) => Promise<SimulateCallResult>
816
919
  simulateTransaction: (params: SimulateTransactionParams) => Promise<SimulateTransactionResult>
920
+ getTransaction: (params: GetTransactionParams) => Promise<TransactionReceipt | null>
921
+ waitForTransactionReceipt: (params: WaitForTransactionReceiptParams) => Promise<TransactionReceipt>
817
922
  watchBlocks: (params: WatchBlocksParams) => Promise<Subscription>
818
923
  watchMempool: (params: WatchMempoolParams) => Promise<Subscription>
819
924
  watchTransaction: (params: WatchTransactionParams) => Promise<Subscription>
@@ -866,11 +971,19 @@ type PoxPostCondition = {
866
971
  };
867
972
  type PostCondition = StxPostCondition | FtPostCondition | NftPostCondition | StakingPostCondition | PoxPostCondition;
868
973
  type IntegerType = number | string | bigint | Uint8Array;
974
+ /**
975
+ * Named fee tiers. `'low' | 'mid' | 'high'` map to the node's three fee
976
+ * estimations; `'min'` is the node's minimum relay fee — 1 uSTX per byte of
977
+ * the serialized transaction, computable offline.
978
+ */
979
+ type FeeTier = "min" | "low" | "mid" | "high";
980
+ /** Fee input accepted by wallet actions: an explicit amount or a named tier. */
981
+ type FeeParam = IntegerType | FeeTier;
869
982
  type CallContractParams = {
870
983
  contract: string
871
984
  functionName: string
872
985
  functionArgs?: ClarityValue[]
873
- fee?: IntegerType
986
+ fee?: FeeParam
874
987
  nonce?: IntegerType
875
988
  postConditionMode?: "allow" | "deny"
876
989
  postConditions?: PostCondition[]
@@ -879,7 +992,7 @@ type DeployContractParams = {
879
992
  contractName: string
880
993
  codeBody: string
881
994
  clarityVersion?: ClarityVersion
882
- fee?: IntegerType
995
+ fee?: FeeParam
883
996
  nonce?: IntegerType
884
997
  postConditionMode?: "allow" | "deny"
885
998
  postConditions?: PostCondition[]
@@ -887,9 +1000,17 @@ type DeployContractParams = {
887
1000
  type SendTransactionParams = {
888
1001
  transaction: StacksTransaction
889
1002
  attachment?: Uint8Array | string
1003
+ /**
1004
+ * Wait for the transaction to be mined before returning. `true` waits for
1005
+ * 1 confirmation; a number waits for that many. The receipt lands on the
1006
+ * result. Rejects if the tx aborts, is dropped, or the wait times out.
1007
+ */
1008
+ wait?: boolean | number
890
1009
  };
891
1010
  type SendTransactionResult = {
892
1011
  txid: string
1012
+ /** Present when `wait` was requested. */
1013
+ receipt?: TransactionReceipt
893
1014
  };
894
1015
  type SignMessageParams = {
895
1016
  message: string | ClarityValue
@@ -906,14 +1027,14 @@ type SignTransactionParams = {
906
1027
  };
907
1028
  type SponsorTransactionParams = {
908
1029
  transaction: StacksTransaction
909
- fee?: IntegerType
1030
+ fee?: FeeParam
910
1031
  nonce?: IntegerType
911
1032
  };
912
1033
  type TransferStxParams = {
913
1034
  to: string
914
1035
  amount: IntegerType
915
1036
  memo?: string
916
- fee?: IntegerType
1037
+ fee?: FeeParam
917
1038
  nonce?: IntegerType
918
1039
  postConditionMode?: "allow" | "deny"
919
1040
  postConditions?: PostCondition[]
@@ -1052,7 +1173,7 @@ declare function postgresStore(params: PostgresStoreParams): NonceStore;
1052
1173
  * - {@link indexSource} — prebuilt over Secondlayer's `/v1/index/mempool`.
1053
1174
  * - {@link hiroNonceSource} — prebuilt over Hiro's `/extended` nonces endpoint.
1054
1175
  */
1055
- type FetchImpl = typeof globalThis.fetch;
1176
+ type FetchImpl2 = typeof globalThis.fetch;
1056
1177
  /**
1057
1178
  * The next free nonce ≥ `confirmed` not already taken by a pending tx.
1058
1179
  *
@@ -1088,7 +1209,7 @@ type IndexSourceParams = {
1088
1209
  baseUrl?: string
1089
1210
  /** Optional API key (keyless by default; supply to raise rate limits). */
1090
1211
  apiKey?: string
1091
- fetchImpl?: FetchImpl
1212
+ fetchImpl?: FetchImpl2
1092
1213
  /** Max mempool pages to page through per address. Default 10 (×200 = 2000 txs). */
1093
1214
  maxPages?: number
1094
1215
  /** Override the confirmed floor (defaults to the node read). */
@@ -1108,7 +1229,7 @@ type HiroNonceSourceParams = {
1108
1229
  /** Hiro API base URL, e.g. `https://api.hiro.so` or `https://api.testnet.hiro.so`. */
1109
1230
  baseUrl: string
1110
1231
  apiKey?: string
1111
- fetchImpl?: FetchImpl
1232
+ fetchImpl?: FetchImpl2
1112
1233
  };
1113
1234
  /**
1114
1235
  * Off-the-shelf, non-Secondlayer mempool-aware source over Hiro's
@@ -1350,14 +1471,51 @@ declare function getContractAddress(deployer: string, contractName: string): str
1350
1471
  declare class TransactionError extends BaseError {
1351
1472
  name: string;
1352
1473
  }
1474
+ /**
1475
+ * Rejection reasons a stacks-node returns from `POST /v2/transactions`.
1476
+ * Wire strings from stacks-core `MemPoolRejection::into_json`
1477
+ * (`stackslib/src/chainstate/stacks/db/blocks.rs`).
1478
+ */
1479
+ type TxRejectionReason = "Serialization" | "Deserialization" | "SignatureValidation" | "BadNonce" | "ConflictingNonceInMempool" | "TooMuchChaining" | "FeeTooLow" | "NotEnoughFunds" | "NoSuchContract" | "NoSuchPublicFunction" | "BadFunctionArgument" | "ContractAlreadyExists" | "BadTransactionVersion" | "TransferRecipientCannotEqualSender" | "TransferAmountMustBePositive" | "PoisonMicroblocksDoNotConflict" | "PoisonMicroblockHasUnknownPubKeyHash" | "PoisonMicroblockIsInvalid" | "BadAddressVersionByte" | "NoCoinbaseViaMempool" | "NoTenureChangeViaMempool" | "EstimatorError" | "TemporarilyBlacklisted" | "ServerFailureNoSuchChainTip" | "ServerFailureDatabase" | "ServerFailureOther";
1353
1480
  declare class BroadcastError extends BaseError {
1354
1481
  name: string;
1355
1482
  txid?: string;
1356
- reason?: string;
1483
+ reason?: TxRejectionReason | (string & {});
1484
+ /** Node-provided detail; shape varies per reason (see stacks-core RPC docs). */
1485
+ reasonData?: unknown;
1357
1486
  constructor(message: string, options?: {
1358
1487
  cause?: Error
1359
1488
  txid?: string
1360
1489
  reason?: string
1490
+ reasonData?: unknown
1491
+ });
1492
+ }
1493
+ /** The transaction was mined but its execution aborted (runtime error or failed post-condition). */
1494
+ declare class TransactionAbortedError extends BaseError {
1495
+ name: string;
1496
+ /** The abort receipt (status, block info, raw source response). */
1497
+ receipt: unknown;
1498
+ constructor(message: string, options: {
1499
+ receipt: unknown
1500
+ cause?: Error
1501
+ });
1502
+ }
1503
+ /** The transaction left the mempool without being mined (dropped/replaced). */
1504
+ declare class TransactionDroppedError extends BaseError {
1505
+ name: string;
1506
+ txid: string;
1507
+ constructor(message: string, options: {
1508
+ txid: string
1509
+ cause?: Error
1510
+ });
1511
+ }
1512
+ /** waitForTransactionReceipt gave up before the tx reached the requested state. */
1513
+ declare class WaitForTransactionTimeoutError extends BaseError {
1514
+ name: string;
1515
+ txid: string;
1516
+ constructor(message: string, options: {
1517
+ txid: string
1518
+ cause?: Error
1361
1519
  });
1362
1520
  }
1363
1521
  declare class SerializationError extends BaseError {
@@ -1375,4 +1533,4 @@ declare class ReadOnlyCallError extends BaseError {
1375
1533
  declare class WebSocketError extends BaseError {
1376
1534
  name: string;
1377
1535
  }
1378
- export { webSocket, walletActions, testnet, startNonceReconciler, resolveNonce, redisStore, reconcileNonce, publicActions, providerToAccount, postgresStore, parseStx, exports_on as on, nextFreeNonce, multisigActions, mocknet, mempoolAwareSource, memoryStore, mainnet, jsonRpcSource, isValidAddress, isNonceConflictError, isAddressEqual, indexSource, http, hiroNonceSource, getContractAddress, formatStx, fallback, devnet, defineChain, custom, createWalletClient, createPublicClient, createNonceManager, createMultiSigClient, createClient, broadcastWithNonceReset, ZERO_ADDRESS, WebSocketTransportConfig, WebSocketTransport, WebSocketError, WalletClientConfig, WalletClient, WalletActions, TransportFactory, TransportConfig, Transport, TransactionError, TESTNET_ZERO_ADDRESS, SubscriptionFilterSpec, Subscription, StartNonceReconcilerParams, StacksProvider, StacksChain, SqlLike, SimulationError, SigningError, SerializationError, RequestOptions, RequestFn, RedisStoreParams, RedisLike, ReconcileNonceResult, ReconcileNonceParams, ReadOnlyCallError, PublicClientConfig, PublicClient, PublicActions, ProviderAccount, PoxFunction, PostgresStoreParams, NonceStore, NonceManagerSource, NonceManager, MultiSigClientConfig, MultiSigClient, MultiSigActions, MempoolAwareSourceParams, MICROSTX_PER_STX, LocalAccount, IndexSourceParams, HiroNonceSourceParams, FilterPrimitive, FilterOperator, FilterClause, Filter, FactoryTarget, CustomAccount, CreateNonceManagerParams, ContractCallError, ClientConfig, Client, BroadcastError, BnsAction, BaseError, AddressVersion, Account };
1536
+ export { webSocket, walletActions, waitForTransactionReceipt2 as waitForTransactionReceipt, testnet, startNonceReconciler, resolveNonce, redisStore, reconcileNonce, publicActions, providerToAccount, postgresStore, parseStx, exports_on as on, nextFreeNonce, multisigActions, mocknet, mempoolAwareSource, memoryStore, mainnet, jsonRpcSource, isValidAddress, isNonceConflictError, isAddressEqual, indexTxSource, indexSource, http, hiroNonceSource, getTransaction2 as getTransaction, getContractAddress, formatStx, fallback, extendedApiSource, devnet, defineChain, custom, createWalletClient, createPublicClient, createNonceManager, createMultiSigClient, createClient, broadcastWithNonceReset, ZERO_ADDRESS, WebSocketTransportConfig, WebSocketTransport, WebSocketError, WalletClientConfig, WalletClient, WalletActions, WaitForTransactionTimeoutError, WaitForTransactionReceiptParams, TxRejectionReason, TransportFactory, TransportConfig, Transport, TransactionStatusSource, TransactionStatus, TransactionSnapshot, TransactionReceipt, TransactionError, TransactionDroppedError, TransactionAbortedError, TESTNET_ZERO_ADDRESS, SubscriptionFilterSpec, Subscription, StartNonceReconcilerParams, StacksProvider, StacksChain, SqlLike, SimulationError, SigningError, SerializationError, RequestOptions, RequestFn, RedisStoreParams, RedisLike, ReconcileNonceResult, ReconcileNonceParams, ReadOnlyCallError, PublicClientConfig, PublicClient, PublicActions, ProviderAccount, PoxFunction, PostgresStoreParams, NonceStore, NonceManagerSource, NonceManager, MultiSigClientConfig, MultiSigClient, MultiSigActions, MempoolAwareSourceParams, MICROSTX_PER_STX, LocalAccount, IndexTxSourceParams, IndexSourceParams, HiroNonceSourceParams, GetTransactionParams, FilterPrimitive, FilterOperator, FilterClause, Filter, FactoryTarget, CustomAccount, CreateNonceManagerParams, ContractCallError, ClientConfig, Client, BroadcastError, BnsAction, BaseError, AddressVersion, Account };