@unicitylabs/sphere-sdk 0.1.5 → 0.1.6

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 CHANGED
@@ -109,8 +109,8 @@ if (created && generatedMnemonic) {
109
109
  console.log('Save this mnemonic:', generatedMnemonic);
110
110
  }
111
111
 
112
- // Get identity
113
- console.log('Address:', sphere.identity?.l1Address);
112
+ // Get identity (L3 DIRECT address is primary)
113
+ console.log('Address:', sphere.identity?.directAddress);
114
114
 
115
115
  // Check balance
116
116
  const balance = await sphere.payments.getBalance();
@@ -155,6 +155,28 @@ const providers = createBrowserProviders({
155
155
  });
156
156
  ```
157
157
 
158
+ ## Testnet Faucet
159
+
160
+ To get test tokens on testnet, you **must first register a nametag**:
161
+
162
+ ```typescript
163
+ // 1. Create wallet and register nametag
164
+ const { sphere } = await Sphere.init({
165
+ ...createBrowserProviders({ network: 'testnet' }),
166
+ autoGenerate: true,
167
+ nametag: 'myname', // Register @myname
168
+ });
169
+
170
+ // 2. Request tokens from faucet using nametag
171
+ const response = await fetch('https://faucet.testnet.unicity.network/api/claim', {
172
+ method: 'POST',
173
+ headers: { 'Content-Type': 'application/json' },
174
+ body: JSON.stringify({ nametag: '@myname' }),
175
+ });
176
+ ```
177
+
178
+ > **Note:** The faucet requires a registered nametag. Requests without a valid nametag will fail.
179
+
158
180
  ## Multi-Address Support
159
181
 
160
182
  The SDK supports HD (Hierarchical Deterministic) wallets with multiple addresses:
@@ -187,20 +209,22 @@ console.log(addr2.address, addr2.publicKey);
187
209
 
188
210
  ### Identity Properties
189
211
 
212
+ **Important:** L3 (DIRECT address) is the primary address for the Unicity network. L1 address is only used for ALPHA blockchain operations.
213
+
190
214
  ```typescript
191
215
  interface Identity {
192
216
  chainPubkey: string; // 33-byte compressed secp256k1 public key (for L3 chain)
193
- l1Address: string; // L1 address (alpha1...)
194
- directAddress?: string; // L3 DIRECT address (DIRECT://...)
217
+ directAddress?: string; // L3 DIRECT address (DIRECT://...) - PRIMARY ADDRESS
218
+ l1Address: string; // L1 address (alpha1...) - for ALPHA blockchain only
195
219
  ipnsName?: string; // IPNS name for token sync
196
220
  nametag?: string; // Registered nametag (@username)
197
221
  }
198
222
 
199
- // Access identity
200
- console.log(sphere.identity?.l1Address); // alpha1qw3e...
201
- console.log(sphere.identity?.directAddress); // DIRECT://0000be36...
223
+ // Access identity - use directAddress as primary
224
+ console.log(sphere.identity?.directAddress); // DIRECT://0000be36... (PRIMARY)
225
+ console.log(sphere.identity?.nametag); // alice (human-readable)
226
+ console.log(sphere.identity?.l1Address); // alpha1qw3e... (L1 only)
202
227
  console.log(sphere.identity?.chainPubkey); // 02abc123... (33-byte compressed)
203
- console.log(sphere.identity?.nametag); // alice
204
228
  ```
205
229
 
206
230
  ### Address Change Event
@@ -1057,6 +1081,8 @@ function getRelayStatuses() {
1057
1081
 
1058
1082
  Nametags provide human-readable addresses (e.g., `@alice`) for receiving payments.
1059
1083
 
1084
+ > **Important:** Nametags are required to use the testnet faucet. Register a nametag before requesting test tokens.
1085
+
1060
1086
  > **Note:** Nametag minting requires an aggregator API key for proof verification. Configure it via the `oracle.apiKey` option when creating providers. Contact Unicity to obtain an API key.
1061
1087
 
1062
1088
  ### Registering a Nametag
@@ -57,6 +57,7 @@ __export(browser_exports, {
57
57
  readFileAsUint8Array: () => readFileAsUint8Array
58
58
  });
59
59
  module.exports = __toCommonJS(browser_exports);
60
+ var import_buffer2 = require("buffer");
60
61
 
61
62
  // constants.ts
62
63
  var STORAGE_KEYS_GLOBAL = {
@@ -2873,6 +2874,9 @@ function resolveArrayConfig(defaults, replace, additional) {
2873
2874
  }
2874
2875
 
2875
2876
  // impl/browser/index.ts
2877
+ if (typeof globalThis.Buffer === "undefined") {
2878
+ globalThis.Buffer = import_buffer2.Buffer;
2879
+ }
2876
2880
  function resolveIpfsSyncConfig(network, config) {
2877
2881
  if (!config) return void 0;
2878
2882
  const networkConfig = getNetworkConfig(network);