@qorechain/sdk 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 +152 -0
- package/dist/index.cjs +1252 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +1532 -0
- package/dist/index.d.ts +1532 -0
- package/dist/index.js +1191 -0
- package/dist/index.js.map +1 -0
- package/package.json +65 -0
package/README.md
ADDED
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
# @qorechain/sdk
|
|
2
|
+
|
|
3
|
+
Official TypeScript SDK for building decentralized applications on the QoreChain
|
|
4
|
+
network — a quantum-safe, triple-VM Layer 1 with native, EVM, and SVM accounts.
|
|
5
|
+
|
|
6
|
+
## Install
|
|
7
|
+
|
|
8
|
+
```sh
|
|
9
|
+
npm install @qorechain/sdk
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## Quickstart
|
|
13
|
+
|
|
14
|
+
### Connect
|
|
15
|
+
|
|
16
|
+
`createClient()` targets the public testnet (chain id `qorechain-diana`) by
|
|
17
|
+
default. The defaults point at localhost, so pass `endpoints` to talk to a real
|
|
18
|
+
node.
|
|
19
|
+
|
|
20
|
+
```ts
|
|
21
|
+
import { createClient } from "@qorechain/sdk";
|
|
22
|
+
|
|
23
|
+
const client = createClient(); // testnet, localhost defaults
|
|
24
|
+
|
|
25
|
+
const remote = createClient({
|
|
26
|
+
endpoints: {
|
|
27
|
+
rest: "https://rest.testnet.example", // Cosmos REST (LCD)
|
|
28
|
+
rpc: "https://rpc.testnet.example", // consensus RPC (for signing)
|
|
29
|
+
evmRpc: "https://evm.testnet.example", // EVM + qor_ JSON-RPC
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Mainnet (chain id `qorechain-vladi`) is live; target it with
|
|
35
|
+
`createClient({ network: "mainnet", endpoints })`, overriding the localhost
|
|
36
|
+
defaults with your node URLs.
|
|
37
|
+
|
|
38
|
+
### Accounts
|
|
39
|
+
|
|
40
|
+
One mnemonic derives native (`qor1…`), EVM (`0x…`), and SVM (base58) accounts.
|
|
41
|
+
|
|
42
|
+
```ts
|
|
43
|
+
import {
|
|
44
|
+
generateMnemonic,
|
|
45
|
+
deriveNativeAccount,
|
|
46
|
+
deriveEvmAccount,
|
|
47
|
+
deriveSvmAccount,
|
|
48
|
+
} from "@qorechain/sdk";
|
|
49
|
+
|
|
50
|
+
const mnemonic = generateMnemonic();
|
|
51
|
+
const native = await deriveNativeAccount(mnemonic); // native.address → "qor1..."
|
|
52
|
+
const evm = await deriveEvmAccount(mnemonic); // evm.address → "0x..."
|
|
53
|
+
const svm = await deriveSvmAccount(mnemonic); // svm.address → base58
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### Read on-chain state
|
|
57
|
+
|
|
58
|
+
```ts
|
|
59
|
+
const balances = await client.rest.getAllBalances(native.address);
|
|
60
|
+
const tokenomics = await client.qor.getTokenomicsOverview();
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### Send a transfer
|
|
64
|
+
|
|
65
|
+
```ts
|
|
66
|
+
import { directSignerFromPrivateKey, toBase } from "@qorechain/sdk";
|
|
67
|
+
|
|
68
|
+
const account = await deriveNativeAccount(mnemonic);
|
|
69
|
+
const signer = await directSignerFromPrivateKey(account.privateKey, "qor");
|
|
70
|
+
const tx = await client.connectTx(signer);
|
|
71
|
+
|
|
72
|
+
const fee = await client.fees.estimate(); // or "fast" | "normal" | "slow"
|
|
73
|
+
const result = await tx.bankSend(
|
|
74
|
+
"qor1recipientaddress...",
|
|
75
|
+
[{ denom: "uqor", amount: toBase("1.5") }],
|
|
76
|
+
{ fee },
|
|
77
|
+
);
|
|
78
|
+
console.log(result.transactionHash);
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### Quantum-safe signing
|
|
82
|
+
|
|
83
|
+
QoreChain supports post-quantum cryptography via ML-DSA-87 (Dilithium-5) and a
|
|
84
|
+
hybrid posture. The key/sign/verify primitives are available today through
|
|
85
|
+
`generatePqcKeypair`, `pqcSign`, `pqcVerify`, and the pluggable `PqcSigner` /
|
|
86
|
+
`HybridSigner`. Hybrid transaction submission is being finalized for the live
|
|
87
|
+
network.
|
|
88
|
+
|
|
89
|
+
```ts
|
|
90
|
+
import { generatePqcKeypair, pqcSign, pqcVerify } from "@qorechain/sdk";
|
|
91
|
+
|
|
92
|
+
const keypair = generatePqcKeypair();
|
|
93
|
+
const message = new TextEncoder().encode("hello");
|
|
94
|
+
const signature = pqcSign(keypair.secretKey, message);
|
|
95
|
+
const ok = pqcVerify(keypair.publicKey, message, signature);
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### CosmWasm contracts
|
|
99
|
+
|
|
100
|
+
Interact with CosmWasm contracts via thin wrappers over
|
|
101
|
+
`@cosmjs/cosmwasm-stargate`. `client.cosmwasm()` opens a read-only client at the
|
|
102
|
+
`rpc` endpoint; for writes, connect a `SigningCosmWasmClient` with an offline
|
|
103
|
+
signer.
|
|
104
|
+
|
|
105
|
+
```ts
|
|
106
|
+
import {
|
|
107
|
+
connectCosmWasmSigner,
|
|
108
|
+
queryContractSmart,
|
|
109
|
+
getContractInfo,
|
|
110
|
+
instantiate,
|
|
111
|
+
execute,
|
|
112
|
+
} from "@qorechain/sdk";
|
|
113
|
+
|
|
114
|
+
// Reads
|
|
115
|
+
const cw = await client.cosmwasm();
|
|
116
|
+
const info = await getContractInfo(cw, "qor1contract...");
|
|
117
|
+
const state = await queryContractSmart(cw, "qor1contract...", { get_count: {} });
|
|
118
|
+
|
|
119
|
+
// Writes
|
|
120
|
+
const signing = await connectCosmWasmSigner("https://rpc.testnet.example", signer);
|
|
121
|
+
const inst = await instantiate(signing, sender, codeId, { count: 0 }, "my-contract", {
|
|
122
|
+
fee: "auto",
|
|
123
|
+
});
|
|
124
|
+
await execute(signing, sender, inst.contractAddress, { increment: {} }, "auto");
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### Cross-VM messages
|
|
128
|
+
|
|
129
|
+
QoreChain routes calls across its native, EVM, and CosmWasm execution
|
|
130
|
+
environments. The EVM→native direction (e.g. an EVM contract triggering a native
|
|
131
|
+
AMM swap) is performed on-chain through the cross-VM bridge precompile exposed in
|
|
132
|
+
the `@qorechain/evm` package. From this SDK you can read message state:
|
|
133
|
+
|
|
134
|
+
```ts
|
|
135
|
+
const pending = await client.crossvm.pending();
|
|
136
|
+
const message = await client.crossvm.message("42");
|
|
137
|
+
const params = await client.crossvm.params();
|
|
138
|
+
|
|
139
|
+
// Or track a message by id over the EVM JSON-RPC namespace:
|
|
140
|
+
const status = await client.qor.getCrossVmMessage("42");
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
## Network reference
|
|
144
|
+
|
|
145
|
+
- Mainnet chain id: `qorechain-vladi` (live).
|
|
146
|
+
- Testnet chain id: `qorechain-diana` (live).
|
|
147
|
+
- Token: `QOR` / `uqor` (10^6 base units per QOR).
|
|
148
|
+
- Default endpoints point at localhost — override them to reach a real node.
|
|
149
|
+
|
|
150
|
+
## License
|
|
151
|
+
|
|
152
|
+
Apache-2.0
|