@bsv/sdk 1.0.33 → 1.0.36

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 (133) hide show
  1. package/README.md +1 -3
  2. package/dist/cjs/mod.js +2 -0
  3. package/dist/cjs/mod.js.map +1 -1
  4. package/dist/cjs/package.json +1 -1
  5. package/dist/cjs/src/transaction/Transaction.js +5 -3
  6. package/dist/cjs/src/transaction/Transaction.js.map +1 -1
  7. package/dist/cjs/src/transaction/broadcasters/ARC.js +37 -25
  8. package/dist/cjs/src/transaction/broadcasters/ARC.js.map +1 -1
  9. package/dist/cjs/src/transaction/broadcasters/DefaultBroadcaster.js +12 -0
  10. package/dist/cjs/src/transaction/broadcasters/DefaultBroadcaster.js.map +1 -0
  11. package/dist/cjs/src/transaction/broadcasters/WhatsOnChainBroadcaster.js +66 -0
  12. package/dist/cjs/src/transaction/broadcasters/WhatsOnChainBroadcaster.js.map +1 -0
  13. package/dist/cjs/src/transaction/broadcasters/index.js +5 -5
  14. package/dist/cjs/src/transaction/broadcasters/index.js.map +1 -1
  15. package/dist/cjs/src/transaction/chaintrackers/DefaultChainTracker.js +12 -0
  16. package/dist/cjs/src/transaction/chaintrackers/DefaultChainTracker.js.map +1 -0
  17. package/dist/cjs/src/transaction/chaintrackers/WhatsOnChain.js +49 -0
  18. package/dist/cjs/src/transaction/chaintrackers/WhatsOnChain.js.map +1 -0
  19. package/dist/cjs/src/transaction/chaintrackers/index.js +11 -0
  20. package/dist/cjs/src/transaction/chaintrackers/index.js.map +1 -0
  21. package/dist/cjs/src/transaction/{broadcasters → http}/DefaultHttpClient.js +8 -4
  22. package/dist/cjs/src/transaction/http/DefaultHttpClient.js.map +1 -0
  23. package/dist/cjs/src/transaction/http/FetchHttpClient.js +29 -0
  24. package/dist/cjs/src/transaction/http/FetchHttpClient.js.map +1 -0
  25. package/dist/cjs/src/transaction/http/HttpClient.js.map +1 -0
  26. package/dist/cjs/src/transaction/{broadcasters → http}/NodejsHttpClient.js +14 -12
  27. package/dist/cjs/src/transaction/http/NodejsHttpClient.js.map +1 -0
  28. package/dist/cjs/src/transaction/http/index.js +10 -0
  29. package/dist/cjs/src/transaction/http/index.js.map +1 -0
  30. package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -1
  31. package/dist/esm/mod.js +2 -0
  32. package/dist/esm/mod.js.map +1 -1
  33. package/dist/esm/src/transaction/Transaction.js +5 -3
  34. package/dist/esm/src/transaction/Transaction.js.map +1 -1
  35. package/dist/esm/src/transaction/broadcasters/ARC.js +37 -25
  36. package/dist/esm/src/transaction/broadcasters/ARC.js.map +1 -1
  37. package/dist/esm/src/transaction/broadcasters/DefaultBroadcaster.js +5 -0
  38. package/dist/esm/src/transaction/broadcasters/DefaultBroadcaster.js.map +1 -0
  39. package/dist/esm/src/transaction/broadcasters/WhatsOnChainBroadcaster.js +65 -0
  40. package/dist/esm/src/transaction/broadcasters/WhatsOnChainBroadcaster.js.map +1 -0
  41. package/dist/esm/src/transaction/broadcasters/index.js +2 -2
  42. package/dist/esm/src/transaction/broadcasters/index.js.map +1 -1
  43. package/dist/esm/src/transaction/chaintrackers/DefaultChainTracker.js +5 -0
  44. package/dist/esm/src/transaction/chaintrackers/DefaultChainTracker.js.map +1 -0
  45. package/dist/esm/src/transaction/chaintrackers/WhatsOnChain.js +50 -0
  46. package/dist/esm/src/transaction/chaintrackers/WhatsOnChain.js.map +1 -0
  47. package/dist/esm/src/transaction/chaintrackers/index.js +3 -0
  48. package/dist/esm/src/transaction/chaintrackers/index.js.map +1 -0
  49. package/dist/esm/src/transaction/{broadcasters → http}/DefaultHttpClient.js +8 -5
  50. package/dist/esm/src/transaction/http/DefaultHttpClient.js.map +1 -0
  51. package/dist/esm/src/transaction/http/FetchHttpClient.js +26 -0
  52. package/dist/esm/src/transaction/http/FetchHttpClient.js.map +1 -0
  53. package/dist/esm/src/transaction/http/HttpClient.js.map +1 -0
  54. package/dist/esm/src/transaction/http/NodejsHttpClient.js +38 -0
  55. package/dist/esm/src/transaction/http/NodejsHttpClient.js.map +1 -0
  56. package/dist/esm/src/transaction/http/index.js +4 -0
  57. package/dist/esm/src/transaction/http/index.js.map +1 -0
  58. package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
  59. package/dist/types/mod.d.ts +2 -0
  60. package/dist/types/mod.d.ts.map +1 -1
  61. package/dist/types/src/transaction/Transaction.d.ts +3 -3
  62. package/dist/types/src/transaction/Transaction.d.ts.map +1 -1
  63. package/dist/types/src/transaction/broadcasters/ARC.d.ts +23 -8
  64. package/dist/types/src/transaction/broadcasters/ARC.d.ts.map +1 -1
  65. package/dist/types/src/transaction/broadcasters/DefaultBroadcaster.d.ts +3 -0
  66. package/dist/types/src/transaction/broadcasters/DefaultBroadcaster.d.ts.map +1 -0
  67. package/dist/types/src/transaction/broadcasters/WhatsOnChainBroadcaster.d.ts +26 -0
  68. package/dist/types/src/transaction/broadcasters/WhatsOnChainBroadcaster.d.ts.map +1 -0
  69. package/dist/types/src/transaction/broadcasters/index.d.ts +3 -4
  70. package/dist/types/src/transaction/broadcasters/index.d.ts.map +1 -1
  71. package/dist/types/src/transaction/chaintrackers/DefaultChainTracker.d.ts +3 -0
  72. package/dist/types/src/transaction/chaintrackers/DefaultChainTracker.d.ts.map +1 -0
  73. package/dist/types/src/transaction/chaintrackers/WhatsOnChain.d.ts +28 -0
  74. package/dist/types/src/transaction/chaintrackers/WhatsOnChain.d.ts.map +1 -0
  75. package/dist/types/src/transaction/chaintrackers/index.d.ts +4 -0
  76. package/dist/types/src/transaction/chaintrackers/index.d.ts.map +1 -0
  77. package/dist/types/src/transaction/http/DefaultHttpClient.d.ts +8 -0
  78. package/dist/types/src/transaction/http/DefaultHttpClient.d.ts.map +1 -0
  79. package/dist/types/src/transaction/http/FetchHttpClient.d.ts +31 -0
  80. package/dist/types/src/transaction/http/FetchHttpClient.d.ts.map +1 -0
  81. package/dist/types/src/transaction/http/HttpClient.d.ts +43 -0
  82. package/dist/types/src/transaction/http/HttpClient.d.ts.map +1 -0
  83. package/dist/types/src/transaction/{broadcasters → http}/NodejsHttpClient.d.ts +2 -2
  84. package/dist/types/src/transaction/http/NodejsHttpClient.d.ts.map +1 -0
  85. package/dist/types/src/transaction/http/index.d.ts +7 -0
  86. package/dist/types/src/transaction/http/index.d.ts.map +1 -0
  87. package/dist/types/tsconfig.types.tsbuildinfo +1 -1
  88. package/docs/examples/EXAMPLE_BUILDING_CUSTOM_TX_BROADCASTER.md +2 -0
  89. package/docs/examples/EXAMPLE_COMPLEX_TX.md +2 -4
  90. package/docs/examples/EXAMPLE_SIMPLE_TX.md +44 -5
  91. package/docs/examples/EXAMPLE_VERIFYING_BEEF.md +29 -22
  92. package/docs/examples/EXAMPLE_VERIFYING_ROOTS.md +18 -63
  93. package/docs/examples/GETTING_STARTED_NODE_CJS.md +2 -4
  94. package/docs/examples/GETTING_STARTED_REACT.md +2 -4
  95. package/docs/primitives.md +61 -59
  96. package/docs/script.md +13 -11
  97. package/docs/transaction.md +489 -35
  98. package/mod.ts +3 -1
  99. package/package.json +21 -1
  100. package/src/transaction/Transaction.ts +5 -3
  101. package/src/transaction/__tests/Transaction.test.ts +62 -0
  102. package/src/transaction/broadcasters/ARC.ts +75 -27
  103. package/src/transaction/broadcasters/DefaultBroadcaster.ts +6 -0
  104. package/src/transaction/broadcasters/WhatsOnChainBroadcaster.ts +70 -0
  105. package/src/transaction/broadcasters/__tests/ARC.test.ts +92 -19
  106. package/src/transaction/broadcasters/__tests/WhatsOnChainBroadcaster.test.ts +165 -0
  107. package/src/transaction/broadcasters/index.ts +3 -4
  108. package/src/transaction/chaintrackers/DefaultChainTracker.ts +6 -0
  109. package/src/transaction/chaintrackers/WhatsOnChain.ts +70 -0
  110. package/src/transaction/chaintrackers/__tests/WhatsOnChainChainTracker.test.ts +135 -0
  111. package/src/transaction/chaintrackers/index.ts +3 -0
  112. package/src/transaction/http/DefaultHttpClient.ts +32 -0
  113. package/src/transaction/http/FetchHttpClient.ts +50 -0
  114. package/src/transaction/http/HttpClient.ts +45 -0
  115. package/src/transaction/http/NodejsHttpClient.ts +55 -0
  116. package/src/transaction/http/index.ts +6 -0
  117. package/dist/cjs/src/transaction/broadcasters/DefaultHttpClient.js.map +0 -1
  118. package/dist/cjs/src/transaction/broadcasters/HttpClient.js.map +0 -1
  119. package/dist/cjs/src/transaction/broadcasters/NodejsHttpClient.js.map +0 -1
  120. package/dist/esm/src/transaction/broadcasters/DefaultHttpClient.js.map +0 -1
  121. package/dist/esm/src/transaction/broadcasters/HttpClient.js.map +0 -1
  122. package/dist/esm/src/transaction/broadcasters/NodejsHttpClient.js +0 -36
  123. package/dist/esm/src/transaction/broadcasters/NodejsHttpClient.js.map +0 -1
  124. package/dist/types/src/transaction/broadcasters/DefaultHttpClient.d.ts +0 -6
  125. package/dist/types/src/transaction/broadcasters/DefaultHttpClient.d.ts.map +0 -1
  126. package/dist/types/src/transaction/broadcasters/HttpClient.d.ts +0 -33
  127. package/dist/types/src/transaction/broadcasters/HttpClient.d.ts.map +0 -1
  128. package/dist/types/src/transaction/broadcasters/NodejsHttpClient.d.ts.map +0 -1
  129. package/src/transaction/broadcasters/DefaultHttpClient.ts +0 -29
  130. package/src/transaction/broadcasters/HttpClient.ts +0 -34
  131. package/src/transaction/broadcasters/NodejsHttpClient.ts +0 -55
  132. /package/dist/cjs/src/transaction/{broadcasters → http}/HttpClient.js +0 -0
  133. /package/dist/esm/src/transaction/{broadcasters → http}/HttpClient.js +0 -0
@@ -45,7 +45,7 @@ await tx.sign()
45
45
  // Finally, we broadcast it with ARC.
46
46
  // get your api key from https://console.taal.com
47
47
  const apiKey = 'mainnet_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' // replace
48
- await tx.broadcast(new ARC('https://api.taal.com/arc', apiKey))
48
+ await tx.broadcast()
49
49
  ```
50
50
 
51
51
  This code snippet demonstrates creating a transaction, adding an input and an output, setting a change script, configuring the fee, signing the transaction, and broadcasting with the ARC broadcaster. It uses the P2PKH Template, which is a specific type of Bitcoin locking program. To learn more about templates, check out this example (link to be provided once cmpplete).
@@ -63,17 +63,36 @@ transaction.addOutput({
63
63
 
64
64
  The `Transaction` class abstracts the complexity of Bitcoin's transaction structure. It handles inputs, outputs, scripts, and serialization, offering methods to easily modify and interrogate the transaction. Check out the full code-level documentation, refer to other examples, or reach out to the community to learn more.
65
65
 
66
- ## Configuring the ARC with http client
66
+ ## Choosing broadcasting target (ARC or WhatsOnChain)
67
+
68
+ ### ARC
69
+
70
+ You can broadcast via selected ARC by providing ARC instance to the `broadcast` method.
71
+
72
+ ```typescript
73
+ await tx.broadcast(new ARC('https://api.taal.com/arc', apiKey))
74
+ ```
75
+
76
+ ### WhatsOnChain
77
+
78
+ You can broadcast via What's On Chain by providing WhatsOnChainBroadcaster instance to the `broadcast` method.
79
+
80
+ ```typescript
81
+ const network = 'main' // or 'test'
82
+ await tx.broadcast(new WhatsOnChainBroadcaster(network))
83
+ ```
84
+
85
+ ## Use custom http client for broadcasting
67
86
 
68
87
  The ARC broadcaster requires an HTTP client to broadcast transactions. By default, the SDK will try to search for `window.fetch` in browser or `https` module on Node.js.
69
- If you want to use a custom (or preconfigured) HTTP client, you can pass it as an argument to the ARC constructor:
88
+ If you want to use a custom (or preconfigured) HTTP client, you can pass it with use of the adapter the ARC constructor:
70
89
 
71
90
  ### fetch
72
91
 
73
92
  ```typescript
74
93
  // In this example we're assuming you have variable fetch holding the fetch function`
75
94
 
76
- const arc = new ARC('https://api.taal.com/arc', apiKey, {fetch})
95
+ const arc = new ARC('https://api.taal.com/arc', apiKey, new FetchHttpClient(mockFetch))
77
96
  ```
78
97
 
79
98
  ### https
@@ -94,7 +113,27 @@ Although the SDK is not providing adapters for axios, it can be easily used with
94
113
  You can make your own "adapter" for axios as follows:
95
114
 
96
115
  ```typescript
97
- const axiosHttpClient = { fetch: (url, options) => axios(url, {...options, data: options.body})}
116
+ const axiosHttpClient = const httpClient: HttpClient = {
117
+ request: async (...args) => {
118
+ let res;
119
+ try {
120
+ res = await axios(...args);
121
+ } catch (e: unknown) {
122
+ if (axios.isAxiosError(e)) {
123
+ res = e.response;
124
+ } else {
125
+ throw e;
126
+ }
127
+ }
128
+ if (!res) {
129
+ throw new Error('No response');
130
+ }
131
+ return {
132
+ ok: res.status >= 200 && res.status <= 299,
133
+ ...res
134
+ };
135
+ },
136
+ };
98
137
 
99
138
  new ARC('https://api.taal.com/arc', apiKey, axiosHttpClient)
100
139
  ```
@@ -12,26 +12,6 @@ Merkle proofs are simply a way for someone to prove the existence of a given tra
12
12
 
13
13
  The process for SPV is detailed in [BRC-67](https://github.com/bitcoin-sv/BRCs/blob/master/transactions/0067.md), but the main idea is that when a sender sends a transaction, they include merkle proofs on all of the input transactions. This allows anyone with a copy of the Bitcoin block headers to check that the input transactions are included in the blockchain. Verifiers then check that all the input and output scripts correctly transfer value from one party to the next, ensuring an unbroken chain of spends. The [BEEF data structure](https://github.com/bitcoin-sv/BRCs/blob/master/transactions/0062.md) provides a compact and efficient way for people to represent the data required to perform SPV.
14
14
 
15
- ## Block Headers Client
16
-
17
- To verify BEEF structures with the BSV SDK, you'll need to provide a block headers client that, given a merkle root, will indicate to the library whether the merkle root is correct for the block that's in the active chain at the given block height.
18
-
19
- For simplicity in this example, we are going to use a mock headers client that always indicates every merkle root as valid no matter what. However, in any real project, **you MUST always use an actual block headers client or attackers will be able to easily fool you with fraudulent transactions!**
20
-
21
- The TypeScript BSV SDK does not ship with a block headers client, but check out this example (link to be provided once complete) for setting up Pulse.
22
-
23
- Here is the gullible block headers client we will be using:
24
-
25
- ```typescript
26
- const gullibleHeadersClient = {
27
- // DO NOT USE IN A REAL PROJECT due to security risks of accepting any merkle root as valid without verification
28
- isValidRootForHeight: async (merkleRoot, height) => {
29
- console.log({ merkleRoot, height })
30
- return true
31
- }
32
- }
33
- ```
34
-
35
15
  ## Verifying a BEEF Structure
36
16
 
37
17
  Now that you have access to a block headers client (either Pulse on a real project or the above code for a toy example), we can proceed to verifying the BEEF structure with the following code:
@@ -46,10 +26,37 @@ const BEEFHex = '0100beef01fe636d0c0007021400fe507c0c7aa754cef1f7889d5fd395cf1f7
46
26
  const tx = Transaction.fromHexBEEF(BEEFHex)
47
27
 
48
28
  // This ensures the BEEF structure is legitimate
49
- const verified = await tx.verify(gullibleHeadersClient)
29
+ const verified = await tx.verify()
50
30
 
51
31
  // Print the results
52
32
  console.log(verified)
53
33
  ```
54
34
 
55
- The above code allows you to ensure that a given BEEF structure is valid according to the rules of SPV.
35
+ The above code allows you to ensure that a given BEEF structure is valid according to the rules of SPV.
36
+
37
+ ## Chain tracker
38
+
39
+ To verify BEEF structures with the BSV SDK, you'll need to provide a block headers client that, given a merkle root, will indicate to the library whether the merkle root is correct for the block that's in the active chain at the given block height.
40
+
41
+ The TypeScript BSV SDK does provides default implementation of the chain tracker that use What's On Chain API.
42
+
43
+ ### What's On Chain configuration
44
+
45
+ #### BSV network
46
+
47
+ The default network for the chain tracker is `main`. You can change it to other network by providing the instance of WhatsOnChain ChainTracker configured for other network to `.verify()` method.
48
+
49
+ ```typescript
50
+ tx.verify(new WhatsOnChain())
51
+ ```
52
+
53
+ #### Api Key
54
+
55
+ It is possible to use WhatsOnChain ChainTracker with obtained API KEY of [WhatsOnChain](https://docs.taal.com/core-products/whatsonchain).
56
+ To do so, you need to provide to `.verify()` method the custom instance of WhatsOnChain ChainTracker with the API KEY.
57
+
58
+ ```typescript
59
+ import { Transaction, WhatsOnChain } from '@bsv/sdk'
60
+
61
+ tx.verify(new WhatsOnChain('main', {apiKey: 'YOUR_API_KEY'}))
62
+ ```
@@ -1,6 +1,6 @@
1
1
  # Example: Building a Pulse Block Headers Client
2
2
 
3
- When [verifying BEEF structures](EXAMPLE_VERIFYING_BEEF.md), it's necessary to ensure that all transactions are well-anchored: this is to say, that they come from inputs in the honest chain. The SDK doesn't ship with a headers client, but this guide shows an example of how to use it with [Pulse](https://github.com/bitcoin-sv/block-headers-service): a popular client suitable for a wide range of use-cases.
3
+ When [verifying BEEF structures](EXAMPLE_VERIFYING_BEEF.md), it's necessary to ensure that all transactions are well-anchored: this is to say, that they come from inputs in the honest chain. The SDK doesn't ship with a headers client, but this guide shows an example of how to use it with [block-headers-service](https://github.com/bitcoin-sv/block-headers-service): a popular client suitable for a wide range of use-cases.
4
4
 
5
5
  ## Pre-requisites
6
6
 
@@ -41,59 +41,13 @@ export default interface ChainTracker {
41
41
 
42
42
  ```
43
43
 
44
- We will hide the complexities of making an https request from browsers/node.js in an separate function, which you could then import into the files you need otherwise.
45
-
46
- ```typescript
47
- // httpsClient.ts
48
- async function nodeFetch (https, url, requestOptions): Promise<any> {
49
- return await new Promise((resolve, reject) => {
50
- const req = https.request(url, requestOptions, res => {
51
- let data = ''
52
- res.on('data', (chunk: string) => {
53
- data += chunk
54
- })
55
- res.on('end', () => {
56
- resolve(data)
57
- })
58
- })
59
-
60
- req.on('error', error => {
61
- reject(error)
62
- })
63
-
64
- if (requestOptions.body as boolean) {
65
- req.write(requestOptions.body)
66
- }
67
- req.end()
68
- })
69
- }
70
- }
71
-
72
- export async function httpsClient (url: string, options: any) : Promise<any> {
73
- let response
74
- let data: any = {}
75
- if (typeof window !== 'undefined' && typeof window.fetch === 'function') {
76
- // Use fetch in a browser environment
77
- response = await window.fetch(url, options)
78
- data = await response.json()
79
- return data
80
- }
81
- if (typeof require === 'undefined') throw new Error('No method available to perform HTTP request')
82
- // Use Node.js https module
83
- // eslint-disable-next-line
84
- const https = require('https')
85
- response = await nodeFetch(https, url, requestOptions)
86
- data = JSON.parse(response)
87
- return data
88
- }
89
- ```
90
-
91
-
92
44
  Given an array of merkle roots and corresponding block heights, we return a boolean indicating whether they're all valid.
93
45
 
94
46
  We can plug in the Block Header Service API with appropriate HTTP handling logic as follows:
95
47
 
96
48
  ```typescript
49
+ import {defaultHttpClient} from "@bsv/sdk";
50
+
97
51
  /**
98
52
  * Represents a Block Headers Client.
99
53
  */
@@ -107,9 +61,10 @@ export default class BlockHeadersClient implements ChainTracker {
107
61
  * @param {string} URL - The URL endpoint for the Pulse API.
108
62
  * @param {string} apiKey - The API key used for authorization with the Pulse API.
109
63
  */
110
- constructor (URL: string, apiKey: string) {
64
+ constructor(URL: string, apiKey: string) {
111
65
  this.URL = URL
112
66
  this.apiKey = apiKey
67
+ this.httpClient = defaultHttpClient()
113
68
  }
114
69
 
115
70
  /**
@@ -119,19 +74,19 @@ export default class BlockHeadersClient implements ChainTracker {
119
74
  * @param height: number - The corresponding height
120
75
  * @returns {Promise<boolean>} A promise that resolves to either a success or failure response (true or false).
121
76
  */
122
- async isValidRootForHeight (root: string, height: number): Promise<boolean> {
123
- try {
124
- const data = await httpsClient(`${this.URL}/api/v1/chain/merkleroot/verify`, {
125
- method: 'POST',
126
- body: JSON.stringify([{ merkleRoot: root, blockHeight: height }]),
127
- headers: {
128
- 'Content-Type': 'application/json',
129
- Authorization: `Bearer ${this.apiKey}`
130
- }
131
- })
132
- return data?.confirmationState === 'CONFIRMED'
133
- } catch (error) {
134
- return false
77
+ async isValidRootForHeight(root: string, height: number): Promise<boolean> {
78
+ const response = await httpsClient(`${this.URL}/api/v1/chain/merkleroot/verify`, {
79
+ method: 'POST',
80
+ body: [{merkleRoot: root, blockHeight: height}],
81
+ headers: {
82
+ 'Content-Type': 'application/json',
83
+ Authorization: `Bearer ${this.apiKey}`
84
+ }
85
+ })
86
+ if (response.ok) {
87
+ return response.data?.confirmationState === 'CONFIRMED'
88
+ } else {
89
+ throw new Error(`Failed to verify root at height ${height} with response ${response.status}`)
135
90
  }
136
91
  }
137
92
  }
@@ -53,9 +53,7 @@ const tx = new Transaction(version, [input], [output])
53
53
  await tx.fee()
54
54
  await tx.sign()
55
55
 
56
- // get your api key from https://console.taal.com
57
- const apiKey = 'mainnet_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' // replace
58
- await tx.broadcast(new ARC('https://api.taal.com/arc', apiKey))
56
+ await tx.broadcast()
59
57
  ```
60
58
 
61
59
  This script demonstrates the entire process of creating a transaction, from initializing keys to signing and broadcast. When you run this script using Node.js (replacing the source transaction, private key, and ARC credentials), the spend will be signed and broadcast to the BSV network.
@@ -70,4 +68,4 @@ node index.js
70
68
 
71
69
  ## Conclusion
72
70
 
73
- Congratulations! You've successfully installed the BSV SDK in your NodeJS project and created a signed transaction. This guide covered the basics to get you started, but the BSV SDK is capable of much more. Explore the SDK documentation for detailed information on all the features and functionalities available to build scalable applications with the BSV blockchain.
71
+ Congratulations! You've successfully installed the BSV SDK in your NodeJS project and created a signed transaction. This guide covered the basics to get you started, but the BSV SDK is capable of much more. Explore the SDK documentation for detailed information on all the features and functionalities available to build scalable applications with the BSV blockchain.
@@ -60,9 +60,7 @@ const BsvButton: React.FC = () => {
60
60
  await tx.fee()
61
61
  await tx.sign()
62
62
 
63
- // grab your api key from https://console.taal.com
64
- const apiKey = 'mainnet_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' // replace
65
- await tx.broadcast(new ARC('https://api.taal.com/arc', apiKey))
63
+ await tx.broadcast()
66
64
  }
67
65
 
68
66
  return (
@@ -118,4 +116,4 @@ Now when you click the button, a transaction will be created, signed, and broadc
118
116
  Conclusion
119
117
  ----------
120
118
 
121
- Congratulations! You've successfully integrated the BSV SDK into your TypeScript & React application and created a button which broadcasts a bitcoin transaction on click. This guide covered the basic steps needed to get you started, but the BSV SDK can do a lot more. Explore the SDK documentation to dive deep into all the features and functionalities available to build scalable applications on the BSV blockchain.
119
+ Congratulations! You've successfully integrated the BSV SDK into your TypeScript & React application and created a button which broadcasts a bitcoin transaction on click. This guide covered the basic steps needed to get you started, but the BSV SDK can do a lot more. Explore the SDK documentation to dive deep into all the features and functionalities available to build scalable applications on the BSV blockchain.