@solana/client 0.0.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 +79 -0
- package/package.json +80 -0
package/README.md
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# @solana/client-core
|
|
2
|
+
|
|
3
|
+
Framework-agnostic building blocks for Solana RPC, subscriptions, wallets, and transactions. Works
|
|
4
|
+
in any runtime (React, Svelte, API routes, workers, etc.).
|
|
5
|
+
|
|
6
|
+
> **Status:** Experimental – expect rapid iteration.
|
|
7
|
+
|
|
8
|
+
## Install
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
pnpm add @solana/client-core
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Quick start
|
|
15
|
+
|
|
16
|
+
```ts
|
|
17
|
+
import { createClient } from "@solana/client-core";
|
|
18
|
+
|
|
19
|
+
const client = createClient({
|
|
20
|
+
endpoint: "https://api.devnet.solana.com",
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
// Fetch an account once.
|
|
24
|
+
const account = await client.actions.fetchAccount(address);
|
|
25
|
+
console.log(account.lamports?.toString());
|
|
26
|
+
|
|
27
|
+
// Watch lamports in real time.
|
|
28
|
+
const watcher = client.watchers.watchBalance({ address }, (lamports) => {
|
|
29
|
+
console.log("balance:", lamports.toString());
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
// Later…
|
|
33
|
+
watcher.abort();
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Core pieces
|
|
37
|
+
|
|
38
|
+
- **Client store** – Zustand store that tracks cluster status, accounts, subscriptions, transactions,
|
|
39
|
+
and wallet state. Provide your own store if you need custom persistence.
|
|
40
|
+
- **Actions** – Promise-based helpers (`fetchAccount`, `fetchBalance`, `sendTransaction`, `requestAirdrop`, `setCluster`, etc.) that wrap the RPC and keep the store in sync.
|
|
41
|
+
- **Watchers** – Subscription helpers (`watchAccount`, `watchBalance`, `watchSignature`) that stream
|
|
42
|
+
updates into the store and call your listeners.
|
|
43
|
+
- **Helpers** – Opinionated utilities for SOL transfers, SPL tokens, and transactions. They handle
|
|
44
|
+
mundane tasks like resolving fee payers, refreshing blockhashes, or signing with Wallet Standard
|
|
45
|
+
sessions.
|
|
46
|
+
|
|
47
|
+
## Transaction helper
|
|
48
|
+
|
|
49
|
+
`client.helpers.transaction` handles blockhashes, fee payers, and signing for you.
|
|
50
|
+
|
|
51
|
+
```ts
|
|
52
|
+
const prepared = await client.helpers.transaction.prepare({
|
|
53
|
+
authority: walletSession,
|
|
54
|
+
instructions: [instruction],
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
const signature = await client.helpers.transaction.send(prepared);
|
|
58
|
+
console.log(signature.toString());
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
- `prepare` builds a transaction message and refreshes the blockhash.
|
|
62
|
+
- `sign` / `toWire` let you collect signatures or emit Base64 manually.
|
|
63
|
+
- `send` submits the prepared transaction (or uses `signAndSend` if the wallet supports it).
|
|
64
|
+
- `prepareAndSend` runs everything plus an optional simulation/logging pass via `prepareTransaction`.
|
|
65
|
+
- Versions default to `0` automatically when any instruction references address lookup tables, otherwise `legacy`; pass `version` if you need to override.
|
|
66
|
+
|
|
67
|
+
Need just the tuning step? Call `client.prepareTransaction` directly with your unsigned message.
|
|
68
|
+
|
|
69
|
+
## Wallet helpers
|
|
70
|
+
|
|
71
|
+
Use `createWalletStandardConnector` to wrap Wallet Standard apps and register them with
|
|
72
|
+
`createWalletRegistry`. The registry powers `client.actions.connectWallet` and the React hooks
|
|
73
|
+
package, but you can also query it directly to build your own selectors.
|
|
74
|
+
|
|
75
|
+
## Scripts
|
|
76
|
+
|
|
77
|
+
- `pnpm build` – run JS compilation and type definition emit
|
|
78
|
+
- `pnpm test:typecheck` – strict type-checking without emit
|
|
79
|
+
- `pnpm lint` / `pnpm format` – Biome-powered linting and formatting
|
package/package.json
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@solana/client",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"description": "Framework-agnostic Solana client orchestration layer powering higher-level experiences",
|
|
5
|
+
"exports": {
|
|
6
|
+
"edge-light": {
|
|
7
|
+
"import": "./dist/index.node.mjs",
|
|
8
|
+
"require": "./dist/index.node.cjs"
|
|
9
|
+
},
|
|
10
|
+
"workerd": {
|
|
11
|
+
"import": "./dist/index.node.mjs",
|
|
12
|
+
"require": "./dist/index.node.cjs"
|
|
13
|
+
},
|
|
14
|
+
"browser": {
|
|
15
|
+
"import": "./dist/index.browser.mjs",
|
|
16
|
+
"require": "./dist/index.browser.cjs"
|
|
17
|
+
},
|
|
18
|
+
"node": {
|
|
19
|
+
"import": "./dist/index.node.mjs",
|
|
20
|
+
"require": "./dist/index.node.cjs"
|
|
21
|
+
},
|
|
22
|
+
"react-native": "./dist/index.native.mjs",
|
|
23
|
+
"types": "./dist/types/index.d.ts"
|
|
24
|
+
},
|
|
25
|
+
"browser": {
|
|
26
|
+
"./dist/index.node.cjs": "./dist/index.browser.cjs",
|
|
27
|
+
"./dist/index.node.mjs": "./dist/index.browser.mjs"
|
|
28
|
+
},
|
|
29
|
+
"main": "./dist/index.node.cjs",
|
|
30
|
+
"module": "./dist/index.node.mjs",
|
|
31
|
+
"react-native": "./dist/index.native.mjs",
|
|
32
|
+
"types": "./dist/types/index.d.ts",
|
|
33
|
+
"type": "commonjs",
|
|
34
|
+
"files": [
|
|
35
|
+
"./dist/"
|
|
36
|
+
],
|
|
37
|
+
"sideEffects": false,
|
|
38
|
+
"keywords": [
|
|
39
|
+
"solana",
|
|
40
|
+
"web3",
|
|
41
|
+
"client",
|
|
42
|
+
"zustand"
|
|
43
|
+
],
|
|
44
|
+
"scripts": {
|
|
45
|
+
"build": "pnpm compile:js && pnpm compile:typedefs",
|
|
46
|
+
"compile:js": "tsup --config ../build-scripts/tsup.config.package.ts",
|
|
47
|
+
"compile:typedefs": "tsc -p ./tsconfig.declarations.json",
|
|
48
|
+
"format": "biome check --write src",
|
|
49
|
+
"lint": "biome check src",
|
|
50
|
+
"test:typecheck": "tsc --noEmit",
|
|
51
|
+
"test": "vitest run --config ./vitest.config.ts",
|
|
52
|
+
"typecheck": "pnpm test:typecheck"
|
|
53
|
+
},
|
|
54
|
+
"author": "Solana Labs Maintainers <maintainers@solanalabs.com>",
|
|
55
|
+
"license": "MIT",
|
|
56
|
+
"dependencies": {
|
|
57
|
+
"@solana/codecs-strings": "^5.0.0",
|
|
58
|
+
"@solana/kit": "^5.0.0",
|
|
59
|
+
"@solana/transactions": "^5.0.0",
|
|
60
|
+
"@solana/transaction-confirmation": "^5.0.0",
|
|
61
|
+
"@solana-program/system": "^0.9.0",
|
|
62
|
+
"@solana-program/compute-budget": "^0.9.0",
|
|
63
|
+
"@solana-program/token": "^0.5.1",
|
|
64
|
+
"@wallet-standard/app": "^1.0.1",
|
|
65
|
+
"@wallet-standard/base": "^1.1.0",
|
|
66
|
+
"@wallet-standard/errors": "^0.1.1",
|
|
67
|
+
"@wallet-standard/features": "^1.0.3",
|
|
68
|
+
"@solana/wallet-standard-features": "^1.3.0",
|
|
69
|
+
"zustand": "^5.0.0"
|
|
70
|
+
},
|
|
71
|
+
"devDependencies": {
|
|
72
|
+
"@types/node": "^24"
|
|
73
|
+
},
|
|
74
|
+
"peerDependencies": {
|
|
75
|
+
"typescript": ">=5.3.3"
|
|
76
|
+
},
|
|
77
|
+
"engines": {
|
|
78
|
+
"node": ">=20.18.0"
|
|
79
|
+
}
|
|
80
|
+
}
|