Skip to content
Docs

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 formats

Parameters

FieldRequiredDescription
chainOrFamilyYes`GrayChainId | ChainFamily` — `"ethereum"` or `"evm"` (same EVM addr).
allAddressTypesNo`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 relatedAddresses

Response — ChainAddress[]:

ts
[{
  chainId: GrayChainId;
  address: string;      // primary
  path: string;
  family: ChainFamily;
  allAddresses?: Array<{ address: string; type: string }>;
}]

exportPrivateKey

js
account.exportPrivateKey(chainOrFamily)
FieldRequiredDescription
chainOrFamilyYesUse `"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? })
FieldRequiredDescription
seedYes`Uint8Array` — from `mnemonicToSeed(mnemonic, bip39Passphrase?)`.
chainIdYes`GrayChainId`
indexNo`number` — default `0`
pathNo`string` — overrides default path
ts
type DerivedKey = {
  privateKey: Uint8Array;  // 32 bytes
  publicKey: Uint8Array;
  address: string;
  path: string;
  family: ChainFamily;
};

deriveFromPrivateKey

js
deriveFromPrivateKey({ privateKey, chainId })
FieldRequiredDescription
privateKeyYes`string`
chainIdYes`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

FieldRequiredDescription
unsupported_capabilityNoChain/family not on wallet or not implemented for derive.
invalid_argumentNoBad seed / key / chainId.
unauthorizedNoExport/sign attempted on watch-only where secrets are required.