Skip to content

Commit e611008

Browse files
niconiconiclaude
andcommitted
update testnet deployments to new contract, improve DX
- Testnet contract address changed to 0x428c850be686E933DD641eE43574BA35f550c94c (same as mainnet) - Add tUSDT pool to both Sepolia and BSC Testnet (verified on-chain) - Update max amounts to uint128 max from new contract - README Quick Start uses SEPOLIA_TESTNET preset instead of placeholder URLs - Add chain preset reference table to README - Improve seed validation error message with HKDF context - Add JSDoc to WalletSessionInput.seed Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 7151d8b commit e611008

File tree

4 files changed

+55
-22
lines changed

4 files changed

+55
-22
lines changed

README.md

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,30 +25,35 @@ pnpm add @ocash/sdk
2525
## Quick Start
2626

2727
```ts
28-
import { createSdk } from '@ocash/sdk';
28+
import { createSdk, SEPOLIA_TESTNET } from '@ocash/sdk';
2929

30-
// See demos/node/ocash.config.example.json for testnet URLs
3130
const sdk = createSdk({
32-
chains: [
33-
{
34-
chainId: 11155111,
35-
entryUrl: '<ENTRY_SERVICE_URL>',
36-
ocashContractAddress: '<CONTRACT_ADDRESS>',
37-
relayerUrl: '<RELAYER_URL>',
38-
merkleProofUrl: '<MERKLE_PROOF_URL>',
39-
tokens: [],
40-
},
41-
],
31+
chains: [SEPOLIA_TESTNET],
4232
onEvent: console.log,
4333
});
4434

4535
await sdk.core.ready();
4636
await sdk.wallet.open({ seed: 'your-secret-seed-phrase' });
4737
await sdk.sync.syncOnce();
4838

49-
const balance = await sdk.wallet.getBalance({ chainId, assetId });
39+
const balance = await sdk.wallet.getBalance({
40+
chainId: SEPOLIA_TESTNET.chainId,
41+
assetId: SEPOLIA_TESTNET.tokens![0]!.id,
42+
});
5043
```
5144

45+
Pre-configured chain presets exported from `@ocash/sdk`:
46+
47+
| Preset | Chain | Chain ID |
48+
| --- | --- | --- |
49+
| `ETH_MAINNET` | Ethereum | 1 |
50+
| `BSC_MAINNET` | BNB Chain | 56 |
51+
| `BASE_MAINNET` | Base | 8453 |
52+
| `SEPOLIA_TESTNET` | Sepolia | 11155111 |
53+
| `BSC_TESTNET` | BSC Testnet | 97 |
54+
55+
Also available: `MAINNET_CHAINS` and `TESTNET_CHAINS` arrays.
56+
5257
## Entry Points
5358

5459
| Import | Environment | Extra |

src/crypto/keyManager.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const HKDF_INFO = 'OCash.KeyGen';
1111
* Derive a 32-byte seed from a human string using HKDF-SHA256.
1212
*/
1313
const deriveSeed = (seed: string, nonce?: string): `0x${string}` => {
14-
if (seed.length < 16) throw new Error('Seed must be at least 16 characters');
14+
if (seed.length < 16) throw new Error('Seed must be at least 16 characters. Any passphrase, hex string, or random bytes will work — it is run through HKDF-SHA256 internally.');
1515
const ikm = utf8ToBytes(seed);
1616
const info = utf8ToBytes(nonce ? `${HKDF_INFO}:${nonce}` : HKDF_INFO);
1717
const okm = hkdf(sha256, ikm, undefined, info, 32);

src/deployments.ts

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -117,13 +117,13 @@ export const BASE_MAINNET: ChainConfigInput = {
117117

118118
/**
119119
* OCash testnet deployment — Sepolia (Chain ID 11155111).
120-
* Pool: SepoliaETH.
120+
* Pools: SepoliaETH, tUSDT.
121121
*/
122122
export const SEPOLIA_TESTNET: ChainConfigInput = {
123123
chainId: 11155111,
124124
rpcUrl: 'https://sepolia.drpc.org',
125125
entryUrl: 'https://api.2.o.cash',
126-
ocashContractAddress: '0x103B9fa1355709832DEB7ff3760017f3cc49A000',
126+
ocashContractAddress: '0x428c850be686E933DD641eE43574BA35f550c94c',
127127
relayerUrl: 'https://relayer.sepolia.2.o.cash',
128128
merkleProofUrl: 'https://freezer.sepolia.2.o.cash',
129129
tokens: [
@@ -136,21 +136,33 @@ export const SEPOLIA_TESTNET: ChainConfigInput = {
136136
freezerPk: ['4669474039172149691654565526011752760208335185174811747074129322851928951709', '13559226903331282409026052744251929479054127336193904689356637527155192056962'],
137137
depositFeeBps: 0,
138138
withdrawFeeBps: 25,
139-
transferMaxAmount: '400000000000000000',
140-
withdrawMaxAmount: '400000000000000000',
139+
transferMaxAmount: '340282366920938463463374607431768211455',
140+
withdrawMaxAmount: '340282366920938463463374607431768211455',
141+
},
142+
{
143+
id: '14880450956444241072894828158264802787637197896840919915927253631318375660820',
144+
symbol: 'tUSDT',
145+
decimals: 18,
146+
wrappedErc20: '0xa88C08409342E95e5A05CB95f5EcC267E1F4f102',
147+
viewerPk: ['16705602615272268567003522975712421097082383063417679753060534780702444376151', '14514464143093266825290311242522740387541372997639894559538766466467730361203'],
148+
freezerPk: ['12575519572146277363559222067073217394207912146376135522069598095499837742570', '20535825957543427476664044300935290889134231934616628729189553228696621211842'],
149+
depositFeeBps: 0,
150+
withdrawFeeBps: 25,
151+
transferMaxAmount: '340282366920938463463374607431768211455',
152+
withdrawMaxAmount: '340282366920938463463374607431768211455',
141153
},
142154
],
143155
};
144156

145157
/**
146158
* OCash testnet deployment — BSC Testnet (Chain ID 97).
147-
* Pool: tBNB.
159+
* Pools: tBNB, tUSDT.
148160
*/
149161
export const BSC_TESTNET: ChainConfigInput = {
150162
chainId: 97,
151163
rpcUrl: 'https://data-seed-prebsc-1-s1.bnbchain.org:8545',
152164
entryUrl: 'https://api.2.o.cash',
153-
ocashContractAddress: '0x103B9fa1355709832DEB7ff3760017f3cc49A000',
165+
ocashContractAddress: '0x428c850be686E933DD641eE43574BA35f550c94c',
154166
relayerUrl: 'https://relayer.bsctestnet.2.o.cash',
155167
merkleProofUrl: 'https://freezer.bsctestnet.2.o.cash',
156168
tokens: [
@@ -163,8 +175,20 @@ export const BSC_TESTNET: ChainConfigInput = {
163175
freezerPk: ['4669474039172149691654565526011752760208335185174811747074129322851928951709', '13559226903331282409026052744251929479054127336193904689356637527155192056962'],
164176
depositFeeBps: 0,
165177
withdrawFeeBps: 25,
166-
transferMaxAmount: '1200000000000000000',
167-
withdrawMaxAmount: '1200000000000000000',
178+
transferMaxAmount: '340282366920938463463374607431768211455',
179+
withdrawMaxAmount: '340282366920938463463374607431768211455',
180+
},
181+
{
182+
id: '691101997437781201062208285139214150313744022627571716486227682674885189667',
183+
symbol: 'tUSDT',
184+
decimals: 18,
185+
wrappedErc20: '0xa7Ae7a38EB9929753Deb8B100627D2bfa060eC91',
186+
viewerPk: ['16705602615272268567003522975712421097082383063417679753060534780702444376151', '14514464143093266825290311242522740387541372997639894559538766466467730361203'],
187+
freezerPk: ['12575519572146277363559222067073217394207912146376135522069598095499837742570', '20535825957543427476664044300935290889134231934616628729189553228696621211842'],
188+
depositFeeBps: 0,
189+
withdrawFeeBps: 25,
190+
transferMaxAmount: '340282366920938463463374607431768211455',
191+
withdrawMaxAmount: '340282366920938463463374607431768211455',
168192
},
169193
],
170194
};

src/types.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -772,6 +772,10 @@ export interface MerkleApi {
772772

773773
/** Wallet open session parameters. */
774774
export interface WalletSessionInput {
775+
/**
776+
* Secret seed for key derivation (min 16 characters).
777+
* Any passphrase, hex string, or raw bytes — internally run through HKDF-SHA256.
778+
*/
775779
seed: string | Uint8Array;
776780
accountNonce?: number;
777781
}

0 commit comments

Comments
 (0)