@tari-project/ootle 0.1.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.
package/LICENSE ADDED
@@ -0,0 +1,29 @@
1
+ BSD 3-Clause License
2
+
3
+ Copyright (c) 2023, The Tari Developer Community
4
+ All rights reserved.
5
+
6
+ Redistribution and use in source and binary forms, with or without
7
+ modification, are permitted provided that the following conditions are met:
8
+
9
+ 1. Redistributions of source code must retain the above copyright notice, this
10
+ list of conditions and the following disclaimer.
11
+
12
+ 2. Redistributions in binary form must reproduce the above copyright notice,
13
+ this list of conditions and the following disclaimer in the documentation
14
+ and/or other materials provided with the distribution.
15
+
16
+ 3. Neither the name of the copyright holder nor the names of its
17
+ contributors may be used to endorse or promote products derived from
18
+ this software without specific prior written permission.
19
+
20
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package/README.md ADDED
@@ -0,0 +1,73 @@
1
+ # @tari-project/ootle
2
+
3
+ Core SDK for the Tari Ootle network — transaction builder, `Provider` / `Signer`
4
+ interfaces, transaction flow helpers, builtin templates, and the stealth
5
+ (confidential transfer) API.
6
+
7
+ ## Runtime support
8
+
9
+ | Package | Browser | Node ≥ 22 | Notes |
10
+ | --------------------- | ------- | --------- | ------------------------------------------------ |
11
+ | `@tari-project/ootle` | ✓ | ✓ | Core; WASM crypto via `@tari-project/ootle-wasm` |
12
+
13
+ > **Node note:** Node ≥ 22 currently requires
14
+ > `NODE_OPTIONS=--experimental-wasm-modules` when running under `tsx` or plain
15
+ > `node` (the WASM ESM gating in Node will be lifted in a future release). See
16
+ > [`examples/node/README.md`](../../examples/node/README.md) for the rationale
17
+ > and forward plan; every script in `examples/node/` wires the flag into its
18
+ > `pnpm` invocation so most users never set it manually.
19
+
20
+ ## Install
21
+
22
+ ```sh
23
+ pnpm add @tari-project/ootle
24
+ ```
25
+
26
+ Also pair it with a `Provider` (e.g. `@tari-project/ootle-indexer`) and a
27
+ `Signer` (e.g. `@tari-project/ootle-wallet-daemon-signer` or
28
+ `@tari-project/ootle-secret-key-wallet`).
29
+
30
+ ## Hello world
31
+
32
+ Build, sign, and submit a transaction end-to-end:
33
+
34
+ ```ts
35
+ import { TransactionBuilder, sendTransaction, Network } from "@tari-project/ootle";
36
+ import { ProviderBuilder } from "@tari-project/ootle-indexer";
37
+ import { WalletDaemonSigner } from "@tari-project/ootle-wallet-daemon-signer";
38
+
39
+ const provider = await ProviderBuilder.new().withNetwork(Network.LocalNet).connect();
40
+ const signer = await WalletDaemonSigner.connect({
41
+ url: "http://localhost:18103",
42
+ authToken: process.env.OOTLE_DAEMON_AUTH_TOKEN,
43
+ });
44
+
45
+ const unsignedTx = TransactionBuilder.new(Network.LocalNet)
46
+ .feeTransactionPayFromComponent(await signer.getAddress(), 1000n)
47
+ .callMethod({ componentAddress: senderAddress, methodName: "withdraw" }, [
48
+ { Literal: resourceAddress },
49
+ { Literal: "500" },
50
+ ])
51
+ .saveVar("bucket")
52
+ .callMethod({ componentAddress: recipientAddress, methodName: "deposit" }, [{ Workspace: "bucket" }])
53
+ .buildUnsignedTransaction();
54
+
55
+ const receipt = await sendTransaction(provider, signer, unsignedTx);
56
+ ```
57
+
58
+ ## Deep dive
59
+
60
+ For the full API surface — `TransactionBuilder` methods, the transaction flow
61
+ helpers (`resolveTransaction`, `signTransaction`, `sealTransaction`,
62
+ `submitTransaction`, `watchTransaction`, `sendTransaction`, `sendDryRun`,
63
+ `classifyOutcome`), `OotleWallet`, the stealth API (`StealthTransfer`,
64
+ `WalletStealthAuthorizer`, `decryptOwnedUtxo`), and the builtin template
65
+ helpers (`AccountInvokeBuilder`, `FaucetInvokeBuilder`) — see the
66
+ [root README's "`@tari-project/ootle`" section](../../README.md#tari-projectootle).
67
+
68
+ ## Examples
69
+
70
+ Runnable browser apps and Node scripts live under
71
+ [`examples/`](../../examples/README.md). The Node tier
72
+ ([`examples/node/`](../../examples/node/README.md)) is the canonical reference
73
+ for using this package from plain `tsx` / `node`.