@tari-project/tarijs 0.10.1 → 0.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.
- package/README.md +127 -67
- package/TODO.md +91 -3
- package/docusaurus/tari-docs/README.md +200 -17
- package/docusaurus/tari-docs/docs/api-reference.md +665 -0
- package/docusaurus/tari-docs/docs/contributing.md +619 -0
- package/docusaurus/tari-docs/docs/guides/getting-started-tutorial.md +965 -0
- package/docusaurus/tari-docs/docs/guides/production-deployment.md +977 -0
- package/docusaurus/tari-docs/docs/index.md +114 -11
- package/docusaurus/tari-docs/docs/installation.md +142 -1
- package/docusaurus/tari-docs/docs/signers/metamask.md +529 -0
- package/docusaurus/tari-docs/docs/troubleshooting.md +661 -0
- package/docusaurus/tari-docs/package.json +4 -4
- package/eslint.config.mjs +9 -0
- package/examples/vite-typescript-react/README.md +9 -0
- package/examples/vite-typescript-react/eslint.config.js +23 -0
- package/examples/vite-typescript-react/index.html +13 -0
- package/examples/vite-typescript-react/package.json +35 -0
- package/examples/vite-typescript-react/public/vite.svg +1 -0
- package/examples/vite-typescript-react/src/App.css +42 -0
- package/examples/vite-typescript-react/src/App.tsx +50 -0
- package/examples/vite-typescript-react/src/assets/react.svg +1 -0
- package/examples/vite-typescript-react/src/index.css +68 -0
- package/examples/vite-typescript-react/src/main.tsx +10 -0
- package/examples/vite-typescript-react/src/vite-env.d.ts +1 -0
- package/examples/vite-typescript-react/tsconfig.app.json +27 -0
- package/examples/vite-typescript-react/tsconfig.json +7 -0
- package/examples/vite-typescript-react/tsconfig.node.json +25 -0
- package/examples/vite-typescript-react/vite.config.ts +7 -0
- package/package.json +16 -3
- package/packages/builders/package.json +2 -2
- package/packages/builders/src/helpers/submitTransaction.ts +10 -35
- package/packages/builders/src/transaction/TransactionBuilder.ts +227 -29
- package/packages/indexer_provider/package.json +2 -2
- package/packages/indexer_provider/src/provider.ts +5 -5
- package/packages/indexer_provider/tsconfig.json +4 -2
- package/packages/metamask_signer/package.json +2 -2
- package/packages/metamask_signer/src/index.ts +3 -15
- package/packages/{tari_permissions → permissions}/package.json +2 -2
- package/packages/{tari_permissions → permissions}/src/helpers.ts +1 -1
- package/packages/permissions/src/index.ts +2 -0
- package/packages/{tari_permissions/src/tari_permissions.ts → permissions/src/permissions.ts} +56 -6
- package/packages/react-mui-connect-button/moon.yml +71 -0
- package/packages/react-mui-connect-button/package.json +40 -0
- package/packages/react-mui-connect-button/src/Logos.tsx +60 -0
- package/packages/react-mui-connect-button/src/TariConnectButton.tsx +51 -0
- package/packages/react-mui-connect-button/src/TariWalletSelectionDialog.tsx +116 -0
- package/packages/react-mui-connect-button/src/content/tari-logo-white.svg +18 -0
- package/packages/react-mui-connect-button/src/content/tari-logo.svg +18 -0
- package/packages/react-mui-connect-button/src/content/walletconnect-logo.svg +13 -0
- package/packages/react-mui-connect-button/src/defaultPermissions.ts +0 -0
- package/packages/react-mui-connect-button/src/index.ts +24 -0
- package/packages/react-mui-connect-button/tsconfig.json +31 -0
- package/packages/tari_provider/package.json +2 -2
- package/packages/tari_provider/src/TariProvider.ts +6 -1
- package/packages/tari_signer/package.json +2 -2
- package/packages/tari_universe/package.json +2 -2
- package/packages/tari_universe/tsconfig.json +4 -2
- package/packages/tarijs/package.json +2 -2
- package/packages/tarijs/src/index.ts +27 -49
- package/packages/tarijs/src/templates/Account.ts +7 -4
- package/packages/tarijs/test/integration-tests/.env +1 -1
- package/packages/tarijs/test/integration-tests/wallet_daemon/json_rpc_provider.spec.ts +112 -73
- package/packages/tarijs/tsconfig.json +6 -4
- package/packages/tarijs/vitest.config.ts +2 -1
- package/packages/tarijs_types/package.json +4 -3
- package/packages/tarijs_types/src/Account.ts +68 -0
- package/packages/tarijs_types/src/Amount.ts +5 -1
- package/packages/tarijs_types/src/TransactionResult.ts +1 -8
- package/packages/tarijs_types/src/consts.ts +3 -0
- package/packages/tarijs_types/src/helpers/index.ts +4 -0
- package/packages/tarijs_types/src/helpers/simpleResult.ts +345 -0
- package/packages/tarijs_types/src/helpers/txResult.ts +1 -2
- package/packages/tarijs_types/src/index.ts +8 -0
- package/packages/tarijs_types/src/signer.ts +1 -1
- package/packages/wallet_daemon/package.json +2 -2
- package/packages/wallet_daemon/src/provider.ts +8 -6
- package/packages/wallet_daemon/src/signer.ts +18 -8
- package/packages/wallet_daemon/tsconfig.json +1 -1
- package/packages/walletconnect/package.json +3 -2
- package/packages/walletconnect/src/index.ts +54 -28
- package/packages/walletconnect/tsconfig.json +3 -0
- package/pnpm-workspace.yaml +15 -7
- package/scripts/check_versions.sh +4 -0
- package/scripts/clean_everything.sh +38 -0
- package/tsconfig.json +6 -0
- package/typedoc.json +10 -0
- package/packages/tari_permissions/src/index.ts +0 -2
- /package/packages/{tari_permissions → permissions}/moon.yml +0 -0
- /package/packages/{tari_permissions → permissions}/tsconfig.json +0 -0
|
@@ -1,21 +1,124 @@
|
|
|
1
1
|
---
|
|
2
2
|
sidebar_position: 1
|
|
3
3
|
slug: /
|
|
4
|
+
title: tari.js Documentation
|
|
5
|
+
description: Complete guide to building with tari.js - the TypeScript toolkit for Tari blockchain applications
|
|
4
6
|
---
|
|
5
7
|
|
|
6
|
-
#
|
|
8
|
+
# Welcome to tari.js! 👋
|
|
7
9
|
|
|
8
|
-
|
|
10
|
+
> **Build powerful Tari applications with confidence** — tari.js is the complete TypeScript toolkit for connecting wallets, querying the blockchain, and creating amazing dApps.
|
|
9
11
|
|
|
10
|
-
|
|
12
|
+
<div className="hero-badges">
|
|
11
13
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
14
|
+

|
|
15
|
+

|
|
16
|
+

|
|
15
17
|
|
|
16
|
-
|
|
18
|
+
</div>
|
|
17
19
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
## 🚀 **What is tari.js?**
|
|
21
|
+
|
|
22
|
+
tari.js is the **universal JavaScript/TypeScript library** for building on Tari. Whether you're creating a DeFi app, an NFT marketplace, or an enterprise solution, tari.js provides everything you need:
|
|
23
|
+
|
|
24
|
+
- **🔌 Universal Wallet Support** — Connect MetaMask, Wallet Daemon, Universe, WalletConnect with one API
|
|
25
|
+
- **🛡️ Privacy-First** — Built-in confidential transactions and zero-knowledge proofs
|
|
26
|
+
- **📱 Developer Friendly** — Full TypeScript support, intuitive APIs, comprehensive docs
|
|
27
|
+
- **⚡ Production Ready** — Battle-tested, optimized, and actively maintained
|
|
28
|
+
|
|
29
|
+
## ✨ **What Makes tari.js Special?**
|
|
30
|
+
|
|
31
|
+
### 🎯 **Provider/Signer Architecture**
|
|
32
|
+
Clean separation between reading data and wallet operations:
|
|
33
|
+
|
|
34
|
+
```typescript
|
|
35
|
+
// 📖 Provider: Read blockchain data (no wallet needed)
|
|
36
|
+
const provider = new IndexerProvider('http://localhost:18300');
|
|
37
|
+
const balance = await provider.getSubstate(substateId);
|
|
38
|
+
|
|
39
|
+
// ✍️ Signer: Wallet operations (requires authentication)
|
|
40
|
+
const signer = new WalletDaemonSigner('http://localhost:18103');
|
|
41
|
+
const tx = await signer.submitTransaction(transaction);
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### 🧩 **Unified API Across All Wallets**
|
|
45
|
+
Same code works with any wallet type:
|
|
46
|
+
|
|
47
|
+
```typescript
|
|
48
|
+
// Works with MetaMask, Universe, Wallet Daemon, WalletConnect
|
|
49
|
+
const wallet = await connectWallet();
|
|
50
|
+
const account = await wallet.getDefaultAccount();
|
|
51
|
+
const result = await wallet.submitTransaction(tx);
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### 🏗️ **Powerful Transaction Builder**
|
|
55
|
+
Fluent API for complex operations:
|
|
56
|
+
|
|
57
|
+
```typescript
|
|
58
|
+
const transaction = new TransactionBuilder()
|
|
59
|
+
.fee(100)
|
|
60
|
+
.callMethod('account', 'transfer', { amount: 1000, destination })
|
|
61
|
+
.callFunction('nft_template', 'mint', { metadata })
|
|
62
|
+
.build();
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## 🎯 **Quick Navigation**
|
|
66
|
+
|
|
67
|
+
### 🚀 **Get Started (5 minutes)**
|
|
68
|
+
- **[Installation](/docs/installation)** — Set up your development environment
|
|
69
|
+
- **[Getting Started Tutorial](/docs/guides/getting-started-tutorial)** — Build your first app
|
|
70
|
+
- **[Provider vs Signer](/docs/provider-vs-signer)** — Understand core concepts
|
|
71
|
+
|
|
72
|
+
### 🔌 **Wallet Integration**
|
|
73
|
+
- **[Wallet Daemon](/docs/signers/wallet-daemon)** — Full-featured server integration
|
|
74
|
+
- **[MetaMask](/docs/signers/metamask)** — Browser wallet via tari-snap
|
|
75
|
+
- **[Tari Universe](/docs/signers/tari-universe)** — Native mobile experience
|
|
76
|
+
- **[WalletConnect](/docs/signers/wallet-connect)** — Cross-platform mobile wallets
|
|
77
|
+
|
|
78
|
+
### 🏗️ **Building Transactions**
|
|
79
|
+
- **[Transaction Builder](/docs/wallet/submit-transaction/transaction-builder/)** — Create complex transactions
|
|
80
|
+
- **[Template System](/docs/wallet/template-definition)** — Work with smart contracts
|
|
81
|
+
- **[Fee Management](/docs/wallet/submit-transaction/transaction-builder/fee)** — Optimize transaction costs
|
|
82
|
+
|
|
83
|
+
### 🔧 **Reference**
|
|
84
|
+
- **[Complete API Reference](/docs/api-reference)** — Every method documented
|
|
85
|
+
- **[Troubleshooting](/docs/troubleshooting)** — Common issues & solutions
|
|
86
|
+
- **[Production Deployment](/docs/guides/production-deployment)** — Go live securely
|
|
87
|
+
|
|
88
|
+
## 📚 **Documentation Structure**
|
|
89
|
+
|
|
90
|
+
This documentation is organized for different user journeys:
|
|
91
|
+
|
|
92
|
+
| If you're... | Start here |
|
|
93
|
+
|--------------|------------|
|
|
94
|
+
| **🆕 New to tari.js** | [Installation](/docs/installation) → [Getting Started Tutorial](/docs/guides/getting-started-tutorial) |
|
|
95
|
+
| **🔌 Integrating wallets** | [Provider vs Signer](/docs/provider-vs-signer) → [Wallet Documentation](/docs/category/signers) |
|
|
96
|
+
| **🏗️ Building transactions** | [Transaction Builder](/docs/wallet/submit-transaction/transaction-builder/) → [Templates](/docs/wallet/template-definition) |
|
|
97
|
+
| **🚨 Having issues** | [Troubleshooting](/docs/troubleshooting) → [GitHub Issues](https://github.com/tari-project/tari.js/issues) |
|
|
98
|
+
| **📖 Looking for specifics** | [API Reference](/docs/api-reference) → Search this site |
|
|
99
|
+
|
|
100
|
+
## 🆕 **What's New in v0.5.0**
|
|
101
|
+
|
|
102
|
+
:::info Major Update
|
|
103
|
+
**Provider/Signer Split** — We've separated data access from wallet operations for better security and flexibility. [Learn about the changes →](/docs/provider-vs-signer)
|
|
104
|
+
:::
|
|
105
|
+
|
|
106
|
+
### 🎉 **New Features**
|
|
107
|
+
- **🔌 Unified wallet connection API** across all wallet types
|
|
108
|
+
- **🏗️ Enhanced transaction builder** with fluent API design
|
|
109
|
+
- **📱 Improved mobile support** for React Native and PWAs
|
|
110
|
+
- **🛡️ Better error handling** and debugging tools
|
|
111
|
+
|
|
112
|
+
### 🔄 **Migration Guide**
|
|
113
|
+
Upgrading from v0.4.0? Check our [GitHub releases](https://github.com/tari-project/tari.js/releases) for upgrade instructions.
|
|
114
|
+
|
|
115
|
+
## 🤝 **Community & Support**
|
|
116
|
+
|
|
117
|
+
- **💬 [GitHub Discussions](https://github.com/tari-project/tari.js/discussions)** — Ask questions, share ideas
|
|
118
|
+
- **🐛 [Issue Tracker](https://github.com/tari-project/tari.js/issues)** — Report bugs, request features
|
|
119
|
+
- **📺 [Discord Community](https://discord.gg/tari)** — Real-time chat with developers
|
|
120
|
+
- **🎮 [Example Apps](https://github.com/tari-project/tari.js/tree/main/examples)** — See tari.js in action
|
|
121
|
+
|
|
122
|
+
---
|
|
123
|
+
|
|
124
|
+
**Ready to build something amazing?** [Install tari.js](/docs/installation) and create your first Tari application in 5 minutes! 🚀
|
|
@@ -105,4 +105,145 @@ npm install @tari-project/tarijs
|
|
|
105
105
|
|
|
106
106
|
In order to use the wallet, you will need to connect either to an Ootle indexer or a signer that allows you to interact with the Ootle via several clients. We explain more about providers and signers in the following section, but in short:
|
|
107
107
|
- You will use an indexer when you simply want to obtain information from the Ootle.
|
|
108
|
-
- A signer is used when you wish to modify, interact with or create on the Ootle.
|
|
108
|
+
- A signer is used when you wish to modify, interact with or create on the Ootle.
|
|
109
|
+
|
|
110
|
+
### Quick Install Commands
|
|
111
|
+
|
|
112
|
+
For most use cases, install both provider and signer packages:
|
|
113
|
+
|
|
114
|
+
```bash npm2yarn
|
|
115
|
+
# Complete installation with indexer provider and wallet daemon signer
|
|
116
|
+
npm install @tari-project/tarijs @tari-project/indexer-provider @tari-project/wallet-daemon-signer
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
For specific wallet types:
|
|
120
|
+
|
|
121
|
+
```bash npm2yarn
|
|
122
|
+
# MetaMask integration
|
|
123
|
+
npm install @tari-project/tarijs @tari-project/metamask-signer
|
|
124
|
+
|
|
125
|
+
# Tari Universe wallet
|
|
126
|
+
npm install @tari-project/tarijs @tari-project/tari-universe
|
|
127
|
+
|
|
128
|
+
# WalletConnect integration
|
|
129
|
+
npm install @tari-project/tarijs @tari-project/walletconnect
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
## Verification
|
|
133
|
+
|
|
134
|
+
After installation, verify everything works:
|
|
135
|
+
|
|
136
|
+
```typescript
|
|
137
|
+
import { TariProvider } from '@tari-project/tarijs';
|
|
138
|
+
|
|
139
|
+
// This should not throw any import errors
|
|
140
|
+
console.log('tari.js installed successfully!');
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
## Common Installation Issues
|
|
144
|
+
|
|
145
|
+
### ❌ Package not found errors
|
|
146
|
+
|
|
147
|
+
**Problem:** `Module '@tari-project/tarijs' not found`
|
|
148
|
+
|
|
149
|
+
**Solution:**
|
|
150
|
+
```bash
|
|
151
|
+
# Clear package manager cache
|
|
152
|
+
npm cache clean --force
|
|
153
|
+
# or for pnpm
|
|
154
|
+
pnpm store prune
|
|
155
|
+
|
|
156
|
+
# Reinstall
|
|
157
|
+
rm -rf node_modules package-lock.json
|
|
158
|
+
npm install
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
### ❌ TypeScript compilation errors
|
|
162
|
+
|
|
163
|
+
**Problem:** TypeScript can't find type definitions
|
|
164
|
+
|
|
165
|
+
**Solution:**
|
|
166
|
+
```bash
|
|
167
|
+
# Install TypeScript and Node types
|
|
168
|
+
npm install --save-dev typescript @types/node
|
|
169
|
+
|
|
170
|
+
# Ensure your tsconfig.json includes:
|
|
171
|
+
{
|
|
172
|
+
"compilerOptions": {
|
|
173
|
+
"moduleResolution": "node",
|
|
174
|
+
"allowSyntheticDefaultImports": true,
|
|
175
|
+
"esModuleInterop": true
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
### ❌ Version compatibility issues
|
|
181
|
+
|
|
182
|
+
**Problem:** Conflicting dependency versions
|
|
183
|
+
|
|
184
|
+
**Solution:**
|
|
185
|
+
```bash
|
|
186
|
+
# Check for peer dependency warnings during install
|
|
187
|
+
npm install --legacy-peer-deps
|
|
188
|
+
|
|
189
|
+
# or use exact versions
|
|
190
|
+
npm install @tari-project/tarijs@latest
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
### ❌ Build tool configuration
|
|
194
|
+
|
|
195
|
+
**Problem:** Vite/Webpack build errors with tari.js
|
|
196
|
+
|
|
197
|
+
**Solution:**
|
|
198
|
+
|
|
199
|
+
For **Vite**, add to `vite.config.ts`:
|
|
200
|
+
```typescript
|
|
201
|
+
export default defineConfig({
|
|
202
|
+
optimizeDeps: {
|
|
203
|
+
include: ['@tari-project/tarijs']
|
|
204
|
+
},
|
|
205
|
+
define: {
|
|
206
|
+
global: 'globalThis',
|
|
207
|
+
}
|
|
208
|
+
});
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
For **Webpack**, add to config:
|
|
212
|
+
```javascript
|
|
213
|
+
module.exports = {
|
|
214
|
+
resolve: {
|
|
215
|
+
fallback: {
|
|
216
|
+
"buffer": require.resolve("buffer"),
|
|
217
|
+
"crypto": require.resolve("crypto-browserify")
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
};
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
### ❌ Node.js polyfill errors in browser
|
|
224
|
+
|
|
225
|
+
**Problem:** `Buffer is not defined` or similar Node.js polyfill errors
|
|
226
|
+
|
|
227
|
+
**Solution:**
|
|
228
|
+
```bash
|
|
229
|
+
# Install polyfills
|
|
230
|
+
npm install --save-dev buffer crypto-browserify
|
|
231
|
+
|
|
232
|
+
# For Vite projects, also install:
|
|
233
|
+
npm install --save-dev @esbuild-plugins/node-globals-polyfill
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
## Next Steps
|
|
237
|
+
|
|
238
|
+
Once installation is complete:
|
|
239
|
+
|
|
240
|
+
1. 📖 Read about [Provider vs Signer concepts](./provider-vs-signer.md)
|
|
241
|
+
2. 🚀 Follow our [Getting Started Tutorial](./guides/getting-started-tutorial.md)
|
|
242
|
+
3. 🔧 Set up your [wallet connections](./signers/wallet-daemon.md)
|
|
243
|
+
4. 💼 Learn about [transaction building](./wallet/submit-transaction/transaction-builder/)
|
|
244
|
+
|
|
245
|
+
## Need Help?
|
|
246
|
+
|
|
247
|
+
- 📚 Check our [Troubleshooting Guide](./troubleshooting.md)
|
|
248
|
+
- 💬 Ask questions in [GitHub Discussions](https://github.com/tari-project/tari.js/discussions)
|
|
249
|
+
- 🐛 Report bugs in [GitHub Issues](https://github.com/tari-project/tari.js/issues)
|