@qorechain/evm 0.3.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 ADDED
@@ -0,0 +1,96 @@
1
+ # @qorechain/evm
2
+
3
+ A thin, type-safe adapter over [viem](https://viem.sh) for the **QoreChain EVM
4
+ Engine**. It does not reimplement an EVM client — `viem` is a peer dependency —
5
+ it adds QoreChain-specific conveniences: a chain-aware client factory with EVM
6
+ chain-id auto-detection, ERC-20 helpers, contract deploy/call wrappers, and
7
+ typed bindings for QoreChain's EVM precompiles.
8
+
9
+ ## Install
10
+
11
+ `viem` is a peer dependency, so install it alongside this package:
12
+
13
+ ```bash
14
+ pnpm add @qorechain/evm viem
15
+ # or: npm install @qorechain/evm viem
16
+ ```
17
+
18
+ ## Quickstart
19
+
20
+ ### Connect
21
+
22
+ The numeric EVM chain id is **auto-detected** at connect time via `eth_chainId`.
23
+ You can also pass `chainId` explicitly to skip detection.
24
+
25
+ ```ts
26
+ import { createEvmClient } from "@qorechain/evm";
27
+
28
+ const client = await createEvmClient({
29
+ rpcUrl: "http://localhost:8545", // or pass an endpoints object: { endpoints: { evmRpc, evmWs } }
30
+ });
31
+
32
+ console.log("chain id:", await client.getChainId());
33
+ ```
34
+
35
+ The native currency defaults to `QOR` with **18 decimals** (the EVM convention).
36
+ This is the EVM-side representation and is distinct from the Cosmos `uqor` base
37
+ denomination (10^6). Override with `{ decimals }` if your node differs; confirm
38
+ the canonical value against your target node.
39
+
40
+ ### Read an ERC-20 balance
41
+
42
+ ```ts
43
+ import { erc20 } from "@qorechain/evm";
44
+
45
+ const token = "0x...";
46
+ const holder = "0x...";
47
+
48
+ const balance = await erc20.balanceOf(client.publicClient, token, holder);
49
+ const meta = await erc20.metadata(client.publicClient, token); // { name, symbol, decimals }
50
+ ```
51
+
52
+ ### Sign and send
53
+
54
+ Pair with `@qorechain/sdk`'s `deriveEvmAccount(mnemonic)`, which returns the
55
+ `privateKey`:
56
+
57
+ ```ts
58
+ import { evmAccountFromPrivateKey, writeContract, ERC20_ABI } from "@qorechain/evm";
59
+
60
+ const account = evmAccountFromPrivateKey("0x..."); // privateKey from deriveEvmAccount
61
+ const wallet = client.getWalletClient(account);
62
+
63
+ const hash = await writeContract(wallet, {
64
+ address: token,
65
+ abi: ERC20_ABI,
66
+ functionName: "transfer",
67
+ args: ["0xrecipient", 1_000n],
68
+ });
69
+ ```
70
+
71
+ ### Call a precompile
72
+
73
+ QoreChain exposes on-chain precompiles for post-quantum verification, AI-based
74
+ risk/anomaly checks, and live consensus parameters. These are available on
75
+ QoreChain network nodes; on a default or community node a call may return a
76
+ "not available" error.
77
+
78
+ ```ts
79
+ import { precompiles } from "@qorechain/evm";
80
+
81
+ const params = await precompiles.rlConsensusParams(client.publicClient);
82
+ // { blockTime, baseGasPrice, validatorSetSize, epoch }
83
+
84
+ const { valid } = { valid: await precompiles.pqcVerify(client.publicClient, {
85
+ pubkey: "0x...",
86
+ signature: "0x...",
87
+ message: "0x...",
88
+ }) };
89
+ ```
90
+
91
+ The precompile addresses and interface ABIs are also exported directly:
92
+ `PRECOMPILE_ADDRESSES`, `IQORE_PQC_ABI`, `IQORE_AI_ABI`, `IQORE_CONSENSUS_ABI`.
93
+
94
+ ## License
95
+
96
+ Apache-2.0