Address Generation
Understanding HD wallet architecture and address derivation in Rach Wallet-as-a-Service.
HD Wallet Architecture
Rach uses Hierarchical Deterministic (HD) wallets based on BIP32/BIP39/BIP44 standards.
Derivation Path Structure
m / purpose' / coin_type' / account' / change / address_indexExample Paths:
- BSC/ETH/POL:
m/44'/60'/0'/0/0,m/44'/60'/0'/0/1, etc. - Tron:
m/44'/195'/0'/0/0,m/44'/195'/0'/0/1, etc. - Solana:
m/44'/501'/0'/0/0,m/44'/501'/0'/0/1, etc.
Network-Specific Details
| Network | Coin Type | Address Format | Derivation Path |
|---|---|---|---|
| BSC | 60 | 0x... (EVM) | m/44'/60'/0'/0/i |
| Ethereum | 60 | 0x... (EVM) | m/44'/60'/0'/0/i |
| Polygon | 60 | 0x... (EVM) | m/44'/60'/0'/0/i |
| Tron | 195 | T... (Base58) | m/44'/195'/0'/0/i |
| Solana | 501 | ... (Base58) | m/44'/501'/0'/0/i |
Address Derivation
Deriving New Addresses
javascript
// Derive address at specific index
async function deriveAddress(walletId, network, index) {
const response = await fetch(
`https://payments-api-dev-966260606560.europe-west2.run.app/api/v1/wallet/customer/${walletId}/derive`,
{
method: 'POST',
headers: {
'X-API-Key': process.env.RACH_API_KEY,
'Content-Type': 'application/json'
},
body: JSON.stringify({ network, index })
}
);
return await response.json();
}
// Generate addresses for deposit segregation
const depositAddress1 = await deriveAddress('wallet_abc', 'BSC', 1);
const depositAddress2 = await deriveAddress('wallet_abc', 'BSC', 2);Use Cases for Multiple Addresses
1. Deposit Segregation
Generate unique deposit address per transaction for tracking:
javascript
async function getDepositAddress(userId, orderId) {
const wallet = await getUserWallet(userId);
const index = await getNextIndex(wallet.wallet_id, 'BSC');
const address = await deriveAddress(wallet.wallet_id, 'BSC', index);
// Store mapping
await db.depositAddresses.create({
wallet_id: wallet.wallet_id,
address: address.address,
index: index,
order_id: orderId,
network: 'BSC'
});
return address.address;
}2. Privacy Enhancement
Use different addresses for different purposes.
3. Accounting Separation
Separate addresses for different business units or customers.
Best Practices
Address Management
- ✅ Track address indices in your database
- ✅ Use gap limit strategy (don't skip indices)
- ✅ Store address-to-order mappings
- ✅ Monitor all derived addresses for deposits
- ✅ Implement address reuse policies
