|
2 | 2 |
|
3 | 3 | The documentation is split into various pages, each covering a set of related functionality. The pages are as follows: |
4 | 4 |
|
5 | | -- [Wallet](./wallet.md) — |
6 | | -- [Client](./client.md) — |
7 | | -- [Storage](./storage.md) — |
8 | | -- [Services](./services.md) — |
9 | | -- [Monitor](./monitor.md) — |
| 5 | +- [Getting Started](#getting-started) - |
| 6 | +- [Wallet](./wallet.md) — |
| 7 | +- [Client](./client.md) — |
| 8 | +- [Storage](./storage.md) — |
| 9 | +- [Services](./services.md) — |
| 10 | +- [Monitor](./monitor.md) — |
10 | 11 |
|
11 | 12 | ## Swagger |
12 | 13 |
|
13 | 14 | [BRC-100](https://brc.dev/100) defines a Unified, Vendor-Neutral, Unchanging, and Open BSV Blockchain Standard Wallet-to-Application Interface which is implemented in this library within the WalletClient class. The API is laid out here as a swagger openapi document to offer a fast-track to understanding the interface which is implemented across multiple substrates. The JSON api is generally considered a developer friendly introduction to the WalletClient, where an binary equivalent ABI may be preferred for production use cases. |
14 | 15 |
|
15 | | -- [Wallet JSON API Swagger](https://bitcoin-sv.github.io/ts-sdk/swagger) |
| 16 | +- [Wallet JSON API Swagger](https://bitcoin-sv.github.io/ts-sdk/swagger) |
| 17 | + |
| 18 | +## Getting Started |
| 19 | + |
| 20 | +### Installation |
| 21 | + |
| 22 | +To install the toolbox, run: |
| 23 | + |
| 24 | +```bash |
| 25 | +npm install @bsv/wallet-toolbox |
| 26 | +``` |
| 27 | + |
| 28 | +### Basic Usage |
| 29 | + |
| 30 | +Here's a simple example of using the toolbox to create and fund a testnet wallet using SQLite for persistent storage: |
| 31 | + |
| 32 | +```ts |
| 33 | +import { InternalizeActionArgs, PrivateKey, Utils } from '@bsv/sdk' |
| 34 | +import { Setup } from '@bsv/wallet-toolbox' |
| 35 | + |
| 36 | +const rootKeyHex = PrivateKey.fromRandom().toString() |
| 37 | +console.log(`MAKE A SECURE COPY OF YOUR WALLET PRIVATE ROOT KEY: ${rootKeyHex}`) |
| 38 | + |
| 39 | +const { wallet } = await Setup.createSQLiteWallet({ |
| 40 | + filePath: './myTestWallet.sqlite', |
| 41 | + databaseName: 'myTestWallet', |
| 42 | + chain: 'test', |
| 43 | + rootKeyHex |
| 44 | +}) |
| 45 | + |
| 46 | +// Obtain a Wallet Payment for your new wallet from a testnet funding faucet. |
| 47 | +// Update or replace the values in the following example object with your actual funding payment. |
| 48 | +// Note that the values below will not be accepted as they are not intended for your new wallet. |
| 49 | +const r = { |
| 50 | + senderIdentityKey: '03ac2d10bdb0023f4145cc2eba2fcd2ad3070cb2107b0b48170c46a9440e4cc3fe', |
| 51 | + vout: 0, |
| 52 | + txid: '942f094cee517276182e5857369ea53d64763a327d433489312a9606db188dfb', |
| 53 | + derivationPrefix: 'jSlU588BWkw=', |
| 54 | + derivationSuffix: 'l37vv/Bn4Lw=', |
| 55 | + atomicBEEF: '01010101942f094cee517...a914b29d56273f6c1df90cd8f383c8117680f2bdd05188ac00000000' |
| 56 | +} |
| 57 | + |
| 58 | +const args: InternalizeActionArgs = { |
| 59 | + tx: Utils.toArray(r.atomicBEEF, 'hex'), |
| 60 | + outputs: [ |
| 61 | + { |
| 62 | + outputIndex: r.vout, |
| 63 | + protocol: 'wallet payment', |
| 64 | + paymentRemittance: { |
| 65 | + derivationPrefix: r.derivationPrefix, |
| 66 | + derivationSuffix: r.derivationSuffix, |
| 67 | + senderIdentityKey: r.senderIdentityKey |
| 68 | + } |
| 69 | + } |
| 70 | + ], |
| 71 | + description: 'from faucet' |
| 72 | +} |
| 73 | + |
| 74 | +const rw = await wallet.internalizeAction(args) |
| 75 | +console.log(rw.accepted) |
| 76 | +``` |
| 77 | + |
| 78 | +For a more detailed tutorial and advanced examples, check our [Documentation](#documentation). |
0 commit comments