naracli 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/README.md +155 -0
- package/bin/nara-cli.ts +32 -0
- package/dist/nara-cli.mjs +2631 -0
- package/dist/quest/nara_quest.json +534 -0
- package/dist/zk/answer_proof.wasm +0 -0
- package/dist/zk/answer_proof_final.zkey +0 -0
- package/index.ts +76 -0
- package/package.json +54 -0
- package/src/cli/commands/config.ts +125 -0
- package/src/cli/commands/migrate.ts +270 -0
- package/src/cli/commands/pool.ts +364 -0
- package/src/cli/commands/quest.ts +312 -0
- package/src/cli/commands/swap.ts +349 -0
- package/src/cli/commands/wallet.ts +719 -0
- package/src/cli/index.ts +25 -0
- package/src/cli/quest/nara_quest.json +534 -0
- package/src/cli/quest/nara_quest_types.ts +540 -0
- package/src/cli/types.ts +207 -0
- package/src/cli/utils/output.ts +110 -0
- package/src/cli/utils/transaction.ts +146 -0
- package/src/cli/utils/validation.ts +120 -0
- package/src/cli/utils/wallet.ts +72 -0
- package/src/cli/zk/answer_proof.wasm +0 -0
- package/src/cli/zk/answer_proof_final.zkey +0 -0
- package/src/client.ts +96 -0
- package/src/config.ts +132 -0
- package/src/constants.ts +29 -0
- package/src/migrate.ts +222 -0
- package/src/pool.ts +259 -0
- package/src/quest.ts +379 -0
- package/src/swap.ts +608 -0
- package/src/types/snarkjs.d.ts +9 -0
package/README.md
ADDED
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
# Nara CLI
|
|
2
|
+
|
|
3
|
+
CLI and SDK for the Nara chain (Solana-compatible).
|
|
4
|
+
|
|
5
|
+
## Architecture
|
|
6
|
+
|
|
7
|
+
```text
|
|
8
|
+
NaraSDK
|
|
9
|
+
├── Solana web3.js ── RPC communication, transaction signing
|
|
10
|
+
├── Meteora DBC SDK ── Dynamic Bonding Curve pools & swaps
|
|
11
|
+
├── Meteora CP-AMM SDK ── Post-graduation concentrated liquidity
|
|
12
|
+
├── snarkjs (Groth16) ── Zero-knowledge proof generation
|
|
13
|
+
└── BIP39 + ed25519-hd-key ── Wallet derivation (m/44'/501'/0'/0')
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
### Wallet
|
|
17
|
+
|
|
18
|
+
Standard Solana-compatible wallet using BIP39 mnemonics and ed25519 key derivation. Supports NSO transfers, SPL token transfers, and balance queries.
|
|
19
|
+
|
|
20
|
+
### Quest (Answer-to-Earn with ZK Proofs)
|
|
21
|
+
|
|
22
|
+
On-chain quiz system where correct answers earn NSO rewards:
|
|
23
|
+
|
|
24
|
+
1. Fetch the current question from the Anchor program
|
|
25
|
+
2. Compute the answer locally and generate a **Groth16 ZK proof** proving `Poseidon(answer) == answer_hash` without revealing the answer
|
|
26
|
+
3. Proof also binds to the user's public key (pubkey_lo/hi) to prevent replay attacks
|
|
27
|
+
4. Submit proof on-chain (directly or via gasless relay). The program verifies the proof and distributes rewards to winners
|
|
28
|
+
|
|
29
|
+
Circuit files: `answer_proof.wasm` + `answer_proof_final.zkey` (BN254 curve).
|
|
30
|
+
|
|
31
|
+
### Token Lifecycle (DBC)
|
|
32
|
+
|
|
33
|
+
1. **Config** - Create bonding curve parameters (supply, initial/migration market cap, fees) via Meteora's `DynamicBondingCurveClient`
|
|
34
|
+
2. **Pool** - Launch a token pool with the bonding curve config, optionally with an initial buy
|
|
35
|
+
3. **Swap** - Buy/sell tokens on the bonding curve. Supports three modes: exact-in, partial-fill, exact-out
|
|
36
|
+
4. **Migrate** - When curve reaches 100%, graduate the pool to Meteora DAMM V2 (Concentrated Position AMM). Requires two Position NFT keypairs for liquidity positions
|
|
37
|
+
|
|
38
|
+
## Installation
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
npm install nara-cli
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## SDK Usage
|
|
45
|
+
|
|
46
|
+
```typescript
|
|
47
|
+
import { NaraSDK } from "nara-cli";
|
|
48
|
+
|
|
49
|
+
const sdk = new NaraSDK({
|
|
50
|
+
rpcUrl: "https://mainnet-api.nara.build/",
|
|
51
|
+
commitment: "confirmed",
|
|
52
|
+
});
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### Quest SDK
|
|
56
|
+
|
|
57
|
+
```typescript
|
|
58
|
+
import {
|
|
59
|
+
getQuestInfo,
|
|
60
|
+
hasAnswered,
|
|
61
|
+
generateProof,
|
|
62
|
+
submitAnswer,
|
|
63
|
+
submitAnswerViaRelay,
|
|
64
|
+
parseQuestReward,
|
|
65
|
+
Keypair,
|
|
66
|
+
} from "nara-cli";
|
|
67
|
+
import { Connection } from "@solana/web3.js";
|
|
68
|
+
|
|
69
|
+
const connection = new Connection("https://mainnet-api.nara.build/", "confirmed");
|
|
70
|
+
const wallet = Keypair.fromSecretKey(/* your secret key */);
|
|
71
|
+
|
|
72
|
+
// 1. Fetch current quest
|
|
73
|
+
const quest = await getQuestInfo(connection);
|
|
74
|
+
console.log(quest.question, quest.remainingSlots, quest.timeRemaining);
|
|
75
|
+
|
|
76
|
+
// 2. Check if already answered this round
|
|
77
|
+
if (await hasAnswered(connection, wallet)) {
|
|
78
|
+
console.log("Already answered");
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// 3. Generate ZK proof (throws if answer is wrong)
|
|
82
|
+
const proof = await generateProof("your-answer", quest.answerHash, wallet.publicKey);
|
|
83
|
+
|
|
84
|
+
// 4a. Submit on-chain (requires gas)
|
|
85
|
+
const { signature } = await submitAnswer(connection, wallet, proof.solana);
|
|
86
|
+
|
|
87
|
+
// 4b. Or submit via gasless relay
|
|
88
|
+
const { txHash } = await submitAnswerViaRelay(
|
|
89
|
+
"https://quest-api.nara.build/",
|
|
90
|
+
wallet.publicKey,
|
|
91
|
+
proof.hex
|
|
92
|
+
);
|
|
93
|
+
|
|
94
|
+
// 5. Parse reward from transaction
|
|
95
|
+
const reward = await parseQuestReward(connection, signature);
|
|
96
|
+
if (reward.rewarded) {
|
|
97
|
+
console.log(`${reward.rewardNso} NSO (winner ${reward.winner})`);
|
|
98
|
+
}
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
See [examples/](examples/) for complete SDK usage examples.
|
|
102
|
+
|
|
103
|
+
## CLI
|
|
104
|
+
|
|
105
|
+
### Setup
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
# Create a new wallet
|
|
109
|
+
nara-cli wallet create
|
|
110
|
+
|
|
111
|
+
# Or import from mnemonic / private key
|
|
112
|
+
nara-cli wallet import -m "your twelve word mnemonic phrase ..."
|
|
113
|
+
nara-cli wallet import -k "your-private-key"
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
Wallet is saved to `~/.config/nara/id.json` by default.
|
|
117
|
+
|
|
118
|
+
### Commands
|
|
119
|
+
|
|
120
|
+
```text
|
|
121
|
+
wallet Wallet management (create, import, balance, transfer)
|
|
122
|
+
config Create bonding curve configurations
|
|
123
|
+
pool Create and query token pools
|
|
124
|
+
swap Buy / sell tokens, get quotes
|
|
125
|
+
migrate Check migration eligibility and launch to DAMM V2
|
|
126
|
+
quest On-chain quiz with ZK proof verification
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
Run `nara-cli <command> --help` for details on each command.
|
|
130
|
+
|
|
131
|
+
### Global Options
|
|
132
|
+
|
|
133
|
+
| Option | Description |
|
|
134
|
+
| --------------------- | --------------------------- |
|
|
135
|
+
| `-r, --rpc-url <url>` | RPC endpoint URL |
|
|
136
|
+
| `-w, --wallet <path>` | Path to wallet keypair JSON |
|
|
137
|
+
| `-j, --json` | Output in JSON format |
|
|
138
|
+
|
|
139
|
+
### Quick Example
|
|
140
|
+
|
|
141
|
+
```bash
|
|
142
|
+
# Check balance
|
|
143
|
+
nara-cli wallet balance
|
|
144
|
+
|
|
145
|
+
# Buy tokens
|
|
146
|
+
nara-cli swap buy <TOKEN_ADDRESS> 0.1
|
|
147
|
+
|
|
148
|
+
# Answer a quest
|
|
149
|
+
nara-cli quest get
|
|
150
|
+
nara-cli quest answer "your answer"
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
## License
|
|
154
|
+
|
|
155
|
+
MIT
|
package/bin/nara-cli.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Nara CLI - Command-line interface for the Nara chain
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { Command } from "commander";
|
|
6
|
+
import { registerCommands } from "../src/cli/index";
|
|
7
|
+
|
|
8
|
+
// Create program
|
|
9
|
+
const program = new Command();
|
|
10
|
+
|
|
11
|
+
// Set program metadata
|
|
12
|
+
program
|
|
13
|
+
.name("nara-cli")
|
|
14
|
+
.description("CLI for the Nara chain (Solana-compatible)")
|
|
15
|
+
.version("0.1.0");
|
|
16
|
+
|
|
17
|
+
// Add global options
|
|
18
|
+
program
|
|
19
|
+
.option("-r, --rpc-url <url>", "RPC endpoint URL")
|
|
20
|
+
.option("-w, --wallet <path>", "Path to wallet keypair JSON file")
|
|
21
|
+
.option("-j, --json", "Output in JSON format");
|
|
22
|
+
|
|
23
|
+
// Register all command modules
|
|
24
|
+
registerCommands(program);
|
|
25
|
+
|
|
26
|
+
// Parse arguments and execute
|
|
27
|
+
program.parse(process.argv);
|
|
28
|
+
|
|
29
|
+
// Show help if no command provided
|
|
30
|
+
if (!process.argv.slice(2).length) {
|
|
31
|
+
program.outputHelp();
|
|
32
|
+
}
|