Client: accounts and chains
Derive addresses per chain
Primary and multi-format addresses per chain, plus low-level derive helpers.
Overview
Resolve receive addresses from an account or from low-level seed helpers. Prefer account.address in apps; use deriveFromSeed / deriveFromPrivateKey for tooling.
account.address
Signature
js
account.address(chainOrFamily)
account.address(chainOrFamily, true) // all formatsParameters
| Field | Required | Description |
|---|---|---|
| chainOrFamily | Yes | `GrayChainId | ChainFamily` — `"ethereum"` or `"evm"` (same EVM addr). |
| allAddressTypes | No | `true` — return every format as `[{ address, type }]`. |
Response
ts
// default → string (primary receive)
// true → Array<{ address: string; type: string }>
account.address("evm") // → "0x…"
account.address("bitcoin") // → "bc1q…" (native segwit)
account.address("bitcoin", true) // taproot / native_segwit / nested_segwit / legacy
account.address("gram", true) // [{ type: "w5" }, { type: "v4r2" }]
account.address("monero") // primary 4…account.addresses / portfolioAddresses
js
account.addresses()
account.portfolioAddresses(chainId) // all format strings for portfolio relatedAddressesResponse — ChainAddress[]:
ts
[{
chainId: GrayChainId;
address: string; // primary
path: string;
family: ChainFamily;
allAddresses?: Array<{ address: string; type: string }>;
}]exportPrivateKey
js
account.exportPrivateKey(chainOrFamily)| Field | Required | Description |
|---|---|---|
| chainOrFamily | Yes | Use `"evm"` for EVM. `"monero"` returns the spend key; use `account.monero.exportViewKey()` for the view key. |
Response: string ("0x" + 64 hex). Throws on watch-only.
deriveFromSeed
js
deriveFromSeed({ seed, chainId, index?, path? })| Field | Required | Description |
|---|---|---|
| seed | Yes | `Uint8Array` — from `mnemonicToSeed(mnemonic, bip39Passphrase?)`. |
| chainId | Yes | `GrayChainId` |
| index | No | `number` — default `0` |
| path | No | `string` — overrides default path |
ts
type DerivedKey = {
privateKey: Uint8Array; // 32 bytes
publicKey: Uint8Array;
address: string;
path: string;
family: ChainFamily;
};deriveFromPrivateKey
js
deriveFromPrivateKey({ privateKey, chainId })| Field | Required | Description |
|---|---|---|
| privateKey | Yes | `string` |
| chainId | Yes | `GrayChainId` |
Response: DerivedKey (same shape).
Usage
js
import { mnemonicToSeed, deriveFromSeed } from "@gray3/client";
const a = wallet.account(0);
a.address("evm");
a.address("solana");
const [w5, v4] = a.portfolioAddresses("gram");
await gray.portfolio.get({
chainId: "gram",
address: w5,
relatedAddresses: [v4],
});
const seed = mnemonicToSeed(mnemonic, bip39Passphrase);
const key = deriveFromSeed({ seed, chainId: "ethereum", index: 0 });Throws
| Field | Required | Description |
|---|---|---|
| unsupported_capability | No | Chain/family not on wallet or not implemented for derive. |
| invalid_argument | No | Bad seed / key / chainId. |
| unauthorized | No | Export/sign attempted on watch-only where secrets are required. |