@4mica/sdk 1.1.0 → 1.1.1
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 +25 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -25,12 +25,30 @@ yarn add @4mica/sdk
|
|
|
25
25
|
|
|
26
26
|
Node.js 18+ is required.
|
|
27
27
|
|
|
28
|
+
## Networks
|
|
29
|
+
|
|
30
|
+
| Shorthand | CAIP-2 | Core API URL |
|
|
31
|
+
|---|---|---|
|
|
32
|
+
| `ethereum-sepolia` | `eip155:11155111` | `https://ethereum.sepolia.4mica.xyz/` |
|
|
33
|
+
| `base-sepolia` | `eip155:84532` | `https://base.sepolia.4mica.xyz/` |
|
|
34
|
+
|
|
35
|
+
The default network is Ethereum Sepolia. Use `.network()` or the `4MICA_NETWORK` environment
|
|
36
|
+
variable to switch networks.
|
|
37
|
+
|
|
38
|
+
```ts
|
|
39
|
+
import { NETWORKS } from "@4mica/sdk";
|
|
40
|
+
|
|
41
|
+
console.log(NETWORKS["base-sepolia"].caip2); // "eip155:84532"
|
|
42
|
+
console.log(NETWORKS["base-sepolia"].rpcUrl); // "https://base.sepolia.4mica.xyz/"
|
|
43
|
+
```
|
|
44
|
+
|
|
28
45
|
## Initialization and Configuration
|
|
29
46
|
|
|
30
47
|
The SDK requires a signing key and can use sensible defaults for the rest:
|
|
31
48
|
|
|
32
49
|
- `walletPrivateKey` (**required** unless `signer` is provided): private key used for signing
|
|
33
|
-
- `
|
|
50
|
+
- `network` (optional): select a network by shorthand or CAIP-2 id. Defaults to `ethereum-sepolia`.
|
|
51
|
+
- `rpcUrl` (optional): override the core API URL directly (for self-hosted deployments).
|
|
34
52
|
- `ethereumHttpRpcUrl` (optional): Ethereum JSON-RPC endpoint; fetched from core if omitted
|
|
35
53
|
- `contractAddress` (optional): Core4Mica contract address; fetched from core if omitted
|
|
36
54
|
- `adminApiKey` (optional): API key for admin RPCs
|
|
@@ -49,7 +67,7 @@ import { Client, ConfigBuilder } from "@4mica/sdk";
|
|
|
49
67
|
|
|
50
68
|
async function main() {
|
|
51
69
|
const cfg = new ConfigBuilder()
|
|
52
|
-
.
|
|
70
|
+
.network("base-sepolia") // or "ethereum-sepolia" (default)
|
|
53
71
|
.walletPrivateKey("0x...")
|
|
54
72
|
.build();
|
|
55
73
|
|
|
@@ -68,12 +86,14 @@ Set environment variables (example `.env`):
|
|
|
68
86
|
|
|
69
87
|
```bash
|
|
70
88
|
4MICA_WALLET_PRIVATE_KEY="0x..."
|
|
71
|
-
|
|
89
|
+
4MICA_NETWORK="base-sepolia" # shorthand or CAIP-2 id
|
|
90
|
+
# or override URL directly:
|
|
91
|
+
# 4MICA_RPC_URL="https://base.sepolia.4mica.xyz/"
|
|
72
92
|
4MICA_ETHEREUM_HTTP_RPC_URL="http://localhost:8545"
|
|
73
93
|
4MICA_CONTRACT_ADDRESS="0x..."
|
|
74
94
|
4MICA_ADMIN_API_KEY="ak_..."
|
|
75
95
|
4MICA_BEARER_TOKEN="Bearer <access_token>"
|
|
76
|
-
4MICA_AUTH_URL="https://
|
|
96
|
+
4MICA_AUTH_URL="https://ethereum.sepolia.4mica.xyz/"
|
|
77
97
|
4MICA_AUTH_REFRESH_MARGIN_SECS="60"
|
|
78
98
|
```
|
|
79
99
|
|
|
@@ -81,7 +101,7 @@ If you want to set them inline for a single command, use `env` since most shells
|
|
|
81
101
|
variable names that start with a digit:
|
|
82
102
|
|
|
83
103
|
```bash
|
|
84
|
-
env 4MICA_WALLET_PRIVATE_KEY="0x..."
|
|
104
|
+
env 4MICA_WALLET_PRIVATE_KEY="0x..." 4MICA_NETWORK="base-sepolia" node app.js
|
|
85
105
|
```
|
|
86
106
|
|
|
87
107
|
Then in code:
|