Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.peaq.xyz/llms.txt

Use this file to discover all available pages before exploring further.

@peaqos/peaq-os-sdk is the opinionated TypeScript entry point for the Machine Financial Passport flow. Each capability is exposed both as a PeaqosClient instance method and as a standalone function.

Install

npm install @peaqos/peaq-os-sdk viem dotenv
  • Node.js: ≥ 22
  • TypeScript: ≥ 5
  • Peer dependency: viem (>= 2.47.10)
  • Exports: ESM and CJS. No bundler workarounds.
dotenv is optional but recommended: PeaqosClient.fromEnv() reads from process.env, so import "dotenv/config" at the top of your entry file is the simplest way to load .env.

Environment variables

VariableRequiredDefaultPurpose
PEAQOS_RPC_URLYesn/apeaq chain RPC endpoint
PEAQOS_PRIVATE_KEYYesn/aOwner private key (0x + 64 hex)
IDENTITY_REGISTRY_ADDRESSYesn/aIdentity Registry contract
IDENTITY_STAKING_ADDRESSYesn/aIdentity Staking contract
EVENT_REGISTRY_ADDRESSYesn/aEvent Registry contract
MACHINE_NFT_ADDRESSYesn/aMachine NFT contract (LayerZero ONFT)
DID_REGISTRY_ADDRESSYesn/aDID Registry precompile
BATCH_PRECOMPILE_ADDRESSYesn/aBatch precompile for multi-call bonding
MACHINE_ACCOUNT_FACTORY_ADDRESSNon/aMachineAccountFactory. Required only for deploySmartAccount / getSmartAccountAddress.
MACHINE_NFT_ADAPTER_ADDRESSNon/aMachineNFTAdapter (LayerZero ONFT adapter). Required only for bridgeNft when source === "peaq".
PEAQOS_MCR_API_URLNohttp://127.0.0.1:8000MCR API base URL
OWS_PASSPHRASEWallet opsOWS vault passphrase for create/import/export wallet helpers when no explicit passphrase is passed

peaq mainnet contracts

Use these addresses for the PEAQOS_*_ADDRESS variables when pointing at peaq mainnet. All contracts are UUPS upgradeable proxies; treat the addresses as the current proxy pointers.
VariableAddress
IDENTITY_REGISTRY_ADDRESS0xb53Af985765031936311273599389b5B68aC9956
IDENTITY_STAKING_ADDRESS0x11c05A650704136786253e8685f56879A202b1C7
EVENT_REGISTRY_ADDRESS0x43c6c12eecAf4fB3F164375A9c44f8a6Efc139b9
MACHINE_NFT_ADDRESS0x2943F80e9DdB11B9Dd275499C661Df78F5F691F9
DID_REGISTRY_ADDRESS0x0000000000000000000000000000000000000800 (peaq DID precompile)
BATCH_PRECOMPILE_ADDRESS0x0000000000000000000000000000000000000805 (peaq batch precompile)
MACHINE_ACCOUNT_FACTORY_ADDRESS0x4A808d5A90A2c91739E92C70aF19924e0B3D527f
MACHINE_NFT_ADAPTER_ADDRESS0x9AD5408702EC204441A88589B99ADfC2514AFAE6
For agung testnet addresses see Install → Agung testnet contracts. Bridging is mainnet-only: LayerZero has no DVN routes to agung.

Client

PeaqosClient

class PeaqosClient {
  constructor(config: Readonly<PeaqosClientConfig>);

  readonly rpcUrl: string;
  readonly contracts: Readonly<ContractAddresses>;
  readonly apiUrl: string;
  readonly operationalLimits: Readonly<OperationalLimits>;
  readonly publicClient: PublicClient;
  readonly walletClient: WalletClient;

  get address(): Address;

  static fromEnv(): PeaqosClient;
  static fromWallet(
    nameOrId: string,
    passphrase: string | undefined,
    owsSigning: boolean | undefined,
    config: Readonly<Omit<PeaqosClientConfig, "privateKey">>,
    options?: WalletOptions,
  ): Promise<PeaqosClient>;
  static generateKeypair(): Readonly<{ address: Address; privateKey: `0x${string}` }>;

  // Static wallet wrappers (thin pass-throughs to the module-level helpers)
  static createWallet(name: string, passphrase?: string, words?: 12 | 24, options?: WalletOptions): Promise<WalletInfo>;
  static importWallet(name: string, privateKey: string, passphrase?: string, chain?: ImportChain, options?: WalletOptions): Promise<WalletInfo>;
  static importWalletMnemonic(name: string, mnemonic: string, passphrase?: string, index?: number, options?: WalletOptions): Promise<WalletInfo>;
  static listWallets(options?: WalletOptions): Promise<WalletInfo[]>;
  static getWallet(nameOrId: string, options?: WalletOptions): Promise<WalletInfo>;
  static exportWallet(nameOrId: string, passphrase?: string, options?: WalletOptions): Promise<string>;
  static deleteWallet(nameOrId: string, options?: WalletOptions): Promise<void>;

  toJSON(): Record<string, unknown>;
}
config.rpcUrl
string
required
RPC endpoint (non-empty).
config.privateKey
string
required
0x + 64 hex characters.
config.contracts
ContractAddresses
required
All six contract addresses.
config.apiUrl
string
MCR API URL. Defaults to DEFAULT_API_URL.
config.operationalLimits
OperationalLimits
Per-tx and rate-limit caps. All-zero disables limits.
Returns a PeaqosClient instance. toJSON() and util.inspect output redact the private key ("[REDACTED]"). Other RPC endpoints are available. See Public RPC endpoints. Errors: ValidationError: missing/invalid rpcUrl, privateKey, or any contract address.

fromEnv

static fromEnv(): PeaqosClient;
Returns a fully configured PeaqosClient. All required env vars must be set (see Environment variables). Errors: ValidationError: any required env var missing or empty.

fromWallet

static fromWallet(
  nameOrId: string,
  passphrase: string | undefined,
  owsSigning: boolean | undefined,
  config: Readonly<Omit<PeaqosClientConfig, "privateKey">>,
  options?: WalletOptions,
): Promise<PeaqosClient>;
Builds a PeaqosClient from an OWS vault wallet. When owsSigning is true (default), signing routes through OWS: the key is decrypted only per-sign and wiped immediately after. When false, the key is decrypted at construction and signing uses viem directly.
nameOrId
string
required
Wallet name or UUID in the OWS vault.
passphrase
string | undefined
required
Vault passphrase. Pass undefined to fall back to the OWS_PASSPHRASE env var.
owsSigning
boolean | undefined
required
Route signing through OWS. Defaults to true when undefined.
config
Omit<PeaqosClientConfig, 'privateKey'>
required
Client config without privateKey (the wallet provides the signer).
options
WalletOptions
Optional vault configuration (e.g. custom vaultPath).
Errors: PeaqosError: wallet not found, passphrase missing, or OWS signing failure. With owsSigning: false a wrong passphrase throws at construction (eager decrypt). With owsSigning: true a wrong passphrase surfaces on the first sign call. Key material is never decrypted at construction.

Wallets (OWS)

Wallet lifecycle helpers (createWallet, importWallet, importWalletMnemonic, listWallets, getWallet, exportWallet, deleteWallet, plus the extractPeaqAddress utility) back the Open Wallet Standard integration: mnemonic-backed encrypted vault, multi-chain accounts (peaq, Base, Ethereum, Solana, Bitcoin, etc.). Lifecycle helpers are available as module-level imports and as static methods on PeaqosClient; the PeaqosClient.fromWallet factory wires a vault wallet directly into a client (OWS-native signing by default). The JS package bundles @open-wallet-standard/core as a regular dependency; no separate peer install is required. The raw-key constructor and fromEnv flow keep working unchanged. Full reference on the Wallets page.

generateKeypair

static generateKeypair(): Readonly<{
  address: Address;
  privateKey: `0x${string}`;
}>;
Returns a frozen object with a fresh secp256k1 privateKey and its derived address. No chain interaction. The private key never touches disk.

OWS wallet lifecycle

OWS wallet helpers are available as static PeaqosClient methods and standalone functions. They derive multi-chain accounts, keep wallet material in an encrypted OWS vault, and return public WalletInfo metadata.
static createWallet(name: string, passphrase?: string, words?: 12 | 24, options?: WalletOptions): Promise<WalletInfo>;
static importWallet(name: string, privateKey: string, passphrase?: string, chain?: ImportChain, options?: WalletOptions): Promise<WalletInfo>;
static importWalletMnemonic(name: string, mnemonic: string, passphrase?: string, index?: number, options?: WalletOptions): Promise<WalletInfo>;
static listWallets(options?: WalletOptions): Promise<WalletInfo[]>;
static getWallet(nameOrId: string, options?: WalletOptions): Promise<WalletInfo>;
static exportWallet(nameOrId: string, passphrase?: string, options?: WalletOptions): Promise<string>;
static deleteWallet(nameOrId: string, options?: WalletOptions): Promise<void>;
static fromWallet(nameOrId: string, passphrase: string | undefined, owsSigning: boolean | undefined, config: Omit<PeaqosClientConfig, "privateKey">, options?: WalletOptions): Promise<PeaqosClient>;
OWS wallet helpers are bundled with @peaqos/peaq-os-sdk. createWallet, importWallet, importWalletMnemonic, exportWallet, and fromWallet require a passphrase argument or OWS_PASSPHRASE. options.vaultPath can point at a custom vault directory. fromWallet can sign through OWS (owsSigning=true, default) so key material is decrypted only for the signing operation.
WalletInfo
object
Frozen object with id, name, createdAt, keyType, peaqAddress, and accounts. Each account has accountId, address, chainId, network, and derivationPath.
exportWallet returns mnemonic or private-key material, and fromWallet consumes a vault passphrase. Keep these in local administrative tooling; do not expose them through robot control channels.

Accessors

All accessors are read-only. The private key is held in an ECMAScript #private field: never exposed through the public surface and redacted in JSON.stringify and util.inspect.
AccessorTypeDescription
addressAddressChecksummed owner address derived from privateKey
rpcUrlstringConfigured RPC endpoint
contractsReadonly<ContractAddresses>Frozen contract address map
apiUrlstringMCR API base URL
operationalLimitsReadonly<OperationalLimits>Per-tx + rate-limit caps
publicClientPublicClient (viem)Read-only chain client
walletClientWalletClient (viem)Signer-bound chain client

Registration

registerMachine

Registers the caller’s own address as a machine. Reads minBond from the IdentityRegistry contract (currently 1 PEAQ) and sends that value with the transaction.
async registerMachine(): Promise<number>;
machineId
number
The newly allocated machine ID, decoded from the Registered event in the transaction receipt.

registerFor

Registers a machine on behalf of another address. The caller becomes the proxy operator and supplies the current minBond (read from the IdentityRegistry contract) as msg.value.
async registerFor(machineAddress: `0x${string}`): Promise<number>;
machineAddress
0x${string}
required
Machine EOA. The client’s signing address becomes the operator and pays the bond.
machineId
number
The newly allocated machine ID for the proxied machine.

Gas Station

1

Setup 2FA

Call setupFaucet2FA to enroll the owner.
2

Confirm 2FA

Call confirmFaucet2FA with a TOTP from the authenticator.
3

Fund

Call fundFromGasStation to send gas to a machine wallet.

setupFaucet2FA

Enrolls an owner address for 2FA with the Gas Station. Returns a QR code URL (expires after ~2 minutes).
async setupFaucet2FA(
  ownerAddress: string,
  faucetBaseUrl: string,
  format?: FaucetQrFormat,
): Promise<FaucetSetupResponse>;
ownerAddress
string
required
Owner to enroll (SS58 or hex).
faucetBaseUrl
string
required
Gas Station base URL.
format
'svg' | 'png'
QR format. Defaults to "svg".
FaucetSetupResponse
object
Errors: ValidationError on empty args. RuntimeError for INVALID_OWNER_ADDRESS, INVALID_PAYLOAD, QR_GENERATION_FAILED, unexpected envelope, or HTTP failure. See errors.

confirmFaucet2FA

Confirms 2FA enrollment with a fresh TOTP code.
async confirmFaucet2FA(
  ownerAddress: string,
  faucetBaseUrl: string,
  twoFactorCode: string,
): Promise<void>;
ownerAddress
string
required
Owner address being confirmed.
faucetBaseUrl
string
required
Gas Station base URL.
twoFactorCode
string
required
Fresh 6-digit TOTP.
Returns void on successful activation. Errors: ValidationError on any empty argument. RuntimeError for INVALID_2FA, 2FA_NOT_CONFIGURED, 2FA_LOCKED, unexpected envelope, or transport failure.

fundFromGasStation

Sends gas tokens to a machine wallet. Returns a discriminated union on status.
async fundFromGasStation(
  params: FundFromGasStationParams,
  faucetBaseUrl: string,
): Promise<FaucetFundResponse>;
params.ownerAddress
string
required
2FA-enrolled owner (SS58 or hex).
params.targetWalletAddress
string
required
Machine EOA to fund.
params.chainId
string
required
Faucet-configured chain identifier (e.g., "peaq").
params.twoFactorCode
string
required
Current TOTP.
params.requestId
string
UUID idempotency key. Auto-generated if omitted.
FaucetFundResponse
FaucetFundSuccessResponse | FaucetFundSkippedResponse

NFT & DID

Machine NFT minting, token-ID lookup, and the two canonical DID attribute writers. The DID writes batch six (machine) or two (proxy) attributes into a single atomic batchAll transaction via the peaq Batch precompile.

mintNft

Mints a Machine NFT on the MachineNFT contract for a registered, bonded machine. Returns the transaction hash.
async mintNft(
  machineId: number,
  recipient: `0x${string}`,
): Promise<Hex>;
machineId
number
required
Registered machine ID. Must be a positive integer.
recipient
0x${string}
required
Address that will own the minted NFT.

tokenIdOf

Reads the NFT token ID assigned to a registered machine via a view call.
async tokenIdOf(machineId: number): Promise<number>;
machineId
number
required
Registered machine ID. Must be a positive integer.
tokenId
number
The NFT token ID, or 0 if no NFT has been minted for this machine.

writeMachineDIDAttributes

Atomically writes the six canonical Machine DID attributes (machineId, nftTokenId, operator, documentation_url, data_api, data_visibility) to the caller’s DID via a single batched transaction.
async writeMachineDIDAttributes(
  params: WriteMachineDIDParams,
): Promise<Hex>;
params.machineId
number
required
Registered machine ID.
params.nftTokenId
number
required
NFT token ID assigned to the machine.
params.operatorDid
string
required
Operator DID reference. May be an empty string. ASCII, ≤ 2560 bytes.
params.documentationUrl
string
required
Non-empty ASCII URL, ≤ 2560 bytes.
params.dataApi
string
required
Non-empty ASCII URL for the machine’s data API, ≤ 2560 bytes.
params.dataVisibility
'public' | 'private' | 'onchain'
required
Visibility setting.

writeProxyDIDAttributes

Atomically writes the two canonical Proxy DID attributes (machineId, machines) to the caller’s DID.
async writeProxyDIDAttributes(
  params: WriteProxyDIDParams,
): Promise<Hex>;
params.proxyMachineId
number
required
The proxy operator’s registered machine ID.
params.machineIds
readonly number[]
required
Non-empty list of positive machine IDs managed by this proxy. The JSON-encoded array must be ≤ 2560 bytes.

readAttribute

Reads a single DID attribute directly from the peaq DID precompile. Most consumers should prefer the /machine/{did} API, which composes the full attribute set; this helper is the on-chain escape hatch.
async function readAttribute(
  client: PeaqosClient,
  did: Address,
  name: string,
): Promise<DIDAttributeResult>;
did
Address
required
The DID account address whose attribute is being read (typically a machine address, but any DID-bearing EOA works).
name
string
required
Attribute key, e.g. "machineId", "data_visibility", "machines".
DIDAttributeResult
object
{ name: string; value: string; validity: number; created: bigint }. validity is 0 when the attribute has no expiry. Throws RuntimeError if the attribute does not exist on the precompile.

encodeAddAttribute

Encodes ABI call data for the DID precompile’s addAttribute(didAccount, name, value, validFor) function. Useful when constructing smart-account executeBatch calls that touch the DID precompile alongside other contracts. writeMachineDIDAttributes and writeProxyDIDAttributes use this helper internally; reach for it directly only when composing custom batch flows.
function encodeAddAttribute(
  didAccount: Address,
  name: string,
  value: string,
  validFor: number,
): Hex;
didAccount
Address
required
Address of the DID account being written. On-chain this must equal msg.sender of the resulting precompile call.
name
string
required
Attribute name. ASCII only, ≤ 64 bytes.
value
string
required
Attribute value. ASCII only, ≤ 2560 bytes.
validFor
number
required
Validity period in blocks. 0 means no expiry. Must be a non-negative integer in the uint32 range.
Hex
string
ABI-encoded call data. Throws ValidationError if any constraint is violated.

Smart accounts

ERC-4337 smart accounts deployed via the MachineAccountFactory. Requires the client to be constructed with a machineAccountFactory address (or the MACHINE_ACCOUNT_FACTORY_ADDRESS env var via fromEnv).

deploySmartAccount

Deploys a smart account via MachineAccountFactory.createAccount and returns the deployed address.
async deploySmartAccount(
  params: DeploySmartAccountParams,
): Promise<Address>;
params.owner
Address
required
EOA that will own the smart account.
params.machine
Address
required
Machine EOA the account is scoped to.
params.salt
number
required
Non-negative CREATE2 salt.

getSmartAccountAddress

Read-only equivalent: computes the CREATE2 address for the given (owner, machine, salt) without deploying. Returns the same address deploySmartAccount would produce.
async getSmartAccountAddress(
  params: DeploySmartAccountParams,
): Promise<Address>;
Same parameters as deploySmartAccount. No transaction, no gas.

Bridge

Supported routes: peaq ↔ Base. Additional peaqOS chains are added as peer contracts deploy. See Machine NFT cross-chain portability.
LayerZero v2 Machine NFT bridging between peaq and Base. Requires the machineNftAdapter address (or MACHINE_NFT_ADAPTER_ADDRESS) when sending from peaq. The SDK’s source / destination literal union expands as peer contracts deploy on new chains.

bridgeNft

Bridges a Machine NFT from source to destination. When source === "base", baseRpcUrl and baseNftAddress are required so the SDK can build a per-call viem client for the Base side. On the peaq→Base path the SDK runs an ERC-721 approval pre-flight: it checks MachineNFT.getApproved(tokenId) and submits a one-shot approve(adapter, tokenId) if the token isn’t already cleared for the adapter. The Base→peaq path uses burn-and-unlock and needs no approval. Either way, callers don’t handle approvals themselves.
async bridgeNft(params: BridgeNftParams): Promise<Hex>;
params.tokenId
number
required
Positive NFT id to bridge.
params.source
'peaq' | 'base'
required
Origin chain.
params.destination
'peaq' | 'base'
required
Target chain (must differ from source).
params.recipient
Address
required
Destination-chain recipient.
params.extraOptions
Hex
Raw LayerZero v2 extraOptions bytes. Defaults to "0x" (the contract’s enforced options).
params.baseRpcUrl
string
Base RPC URL. Required only when source === "base".
params.baseNftAddress
Address
MachineNFTBase address on Base. Required only when source === "base".
txHash
Hex
The source-chain transaction hash.

waitForBridgeArrival

Static method that polls the destination chain’s MachineNFT.ownerOf(tokenId) every 10 seconds until a non-zero owner returns or the timeout elapses. No PeaqosClient instance required.
static async waitForBridgeArrival(
  params: WaitForBridgeArrivalParams,
): Promise<boolean>;
params.dstRpcUrl
string
required
Destination-chain RPC endpoint.
params.dstNftAddress
Address
required
MachineNFT contract address on the destination.
params.tokenId
number
required
The NFT id expected to arrive.
params.timeout
number
Wait budget in seconds. Defaults to 300 (5 min).
params.signal
AbortSignal
Optional abort signal. When aborted, the poll stops immediately with a RuntimeError code ABORTED.

Events (Qualify)

submitEvent

Submits a single event to EventRegistry. Validates and normalizes the payload, then calls the contract. Returns the transaction hash and the computed dataHash.
async submitEvent(
  params: SubmitEventParams,
): Promise<{ txHash: Hex; dataHash: Hex }>;
Param shape matches validateSubmitEventParams below. value is an ISO 4217 minor-unit integer (cents for USD/HKD, whole units for JPY/KRW/VND, thousandths for BHD). currency is required on revenue events (^[A-Z0-9]{3,10}$) and must be "" on activity events; the SDK applies a smart default (revenue → "USD", activity → "") when omitted on submitEvent. batchSubmitEvents is strict: every event must carry currency explicitly.

batchSubmitEvents

Submits multiple events atomically through the peaq Batch precompile. All events land in the same transaction: all succeed or all revert.
async batchSubmitEvents(
  events: ReadonlyArray<SubmitEventParams>,
): Promise<Hex[]>;
events
readonly SubmitEventParams[]
required
Non-empty list of event payloads. Each element is validated individually before submission.
txHashes
Hex[]
One transaction hash per input event. All hashes are identical (same batch tx).

validateSubmitEventParams

function validateSubmitEventParams(params: SubmitEventParams): void;
machineId
number
required
Machine ID returned by registerMachine / registerFor.
eventType
0 | 1
required
0 revenue, 1 activity.
value
number
required
Non-negative ISO 4217 minor-unit integer. Cents for USD/HKD, whole units for JPY/KRW/VND, thousandths for BHD. Activity events: any non-negative integer or 0.
currency
string
Revenue: 3-10 uppercase alphanumeric (e.g. "USD", "HKD", "JPY"). Activity: must be "". Omit to apply the SDK smart default (revenue → "USD", activity → ""); batchSubmitEvents requires it explicitly.
timestamp
number
required
Unix seconds.
rawData
Uint8Array | null
required
Off-chain payload hashed into dataHash.
trustLevel
0 | 1 | 2
required
0 self-reported, 1 on-chain verifiable, 2 hardware-signed.
sourceChainId
number
required
Originating chain. Use SUPPORTED_CHAIN_IDS.peaq for local.
sourceTxHash
Hex | null
required
Cross-chain tx hash when applicable.
metadata
Uint8Array
required
Arbitrary bytes stored on-chain alongside the event. Use empty bytes when no metadata is needed.
Returns void. Throws ValidationError on any invariant violation.

computeDataHash

function computeDataHash(rawData: Uint8Array): Hex;
rawData
Uint8Array
required
Off-chain payload bytes to hash.
Returns a keccak256 hash as 0x + 64 hex characters.

checkOperationalLimits

function checkOperationalLimits(
  params: { machineId: number; value: number },
  limits: OperationalLimits,
  tracker: EventTracker | null,
): void;
params
{ machineId: number; value: number }
required
Machine ID and event value.
limits
OperationalLimits
required
Configured maxValuePerTx, rateLimitMaxEvents, rateLimitWindowSeconds.
tracker
EventTracker | null
required
Current rate-tracking state for the machine. Pass null if you are not tracking window state. EventTracker is { machineId: number; count: number; windowStart: number }.
Returns void. Throws ValueCapExceeded or RateLimitExceeded on limit violation.

Queries

Read-only helpers backed by the off-chain MCR API server (client.apiUrl). Each function validates the DID, issues a single GET, and returns a frozen, shape-checked response. All three accept an optional GetJsonOptions with timeoutMs (default 30 000 ms) and a caller AbortSignal.

queryMcr

Fetches the Machine Credit Rating for a machine DID. See GET /mcr/{did}.
async function queryMcr(
  client: PeaqosClient,
  did: string,
  options?: GetJsonOptions,
): Promise<MCRResponse>;
did
string
required
Machine DID. Must start with did:peaq:0x.
options.timeoutMs
number
Request budget in ms. Defaults to 30 000.
options.signal
AbortSignal
Caller abort signal. Either signal aborting wins.
MCRResponse
object
Frozen object with camelCase fields: did, machineId, mcrScore (number, 0–100), mcr ("AAA" | "AA" | "A" | "BBB" | "BB" | "B" | "NR" | "Provisioned"), mcrDegraded (boolean: true when ≥1 scored event used a stale or unavailable FX source), bondStatus ("bonded" | "unbonded"), negativeFlag (boolean: true when the machine has been flagged for negative behaviour; consumers should down-rank or alert independently of the numeric score), eventCount, revenueEventCount, activityEventCount, revenueTrend ("up" | "stable" | "down" | "insufficient"), totalRevenue (whole USD as float, not cents), averageRevenuePerEvent (whole USD as float), lastUpdated (unix seconds or null).
The MCR API returns mcr_score: null while a machine is still Provisioned or has rating NR. The JS SDK coerces this to 0 so mcrScore is always a number.

queryMachine

Fetches the full machine profile (NFT Metadata JSON v1.0) for a DID. The SDK strictly validates the response against MachineProfileResponse and throws BAD_RESPONSE for any missing or malformed required field. See GET /machine/{did}.
async function queryMachine(
  client: PeaqosClient,
  did: string,
  options?: GetJsonOptions,
): Promise<MachineProfileResponse>;
did
string
required
Machine DID. Must start with did:peaq:0x.
options
GetJsonOptions
Optional timeoutMs (default 30 000) and caller signal.
MachineProfileResponse
object
Frozen, strictly-validated machine profile. Top-level fields: schema_version (string) and name (string). The peaqos sub-object always carries machine_id, did, operator, mcr, mcr_score, bond_status, negative_flag, event_count, data_visibility, and documentation_url. Visibility-dependent extras: data_api, event_data, partner_data, partner_data_error. The SDK throws BAD_RESPONSE if the server returns anything that fails the schema guard. See GET /machine/{did} for full field semantics.

queryOperatorMachines

Fetches the fleet of machines managed by a proxy operator. Each machine summary carries its DID, machine ID, score, rating tier, and negativeFlag; the response also includes pagination metadata. See GET /operator/{did}/machines.
async function queryOperatorMachines(
  client: PeaqosClient,
  did: string,
  options?: GetJsonOptions,
): Promise<OperatorMachinesResponse>;
did
string
required
Operator DID. Must start with did:peaq:0x.
options
GetJsonOptions
Optional timeoutMs (default 30 000) and caller signal.
OperatorMachinesResponse
object
Frozen object with operatorDid, a frozen machines array, and a pagination object. Each machine entry exposes did, machineId, mcrScore (number, 0–100; null coerced to 0), mcr rating, and negativeFlag (boolean: true when the machine has been flagged for negative behaviour). pagination carries offset, limit, and total (all non-negative integers).

Error classes

See errors for the full hierarchy and the 20-code faucet table.
import {
  PeaqosError,
  RuntimeError,
  ValidationError,
  ValueCapExceeded,
  RateLimitExceeded,
} from "@peaqos/peaq-os-sdk";

Type exports

import type {
  // Client
  PeaqosClientConfig,
  ContractAddresses,
  OperationalLimits,

  // Events
  SubmitEventParams,
  MachineEvent,
  EventType,
  TrustLevel,
  EventTracker,

  // Identity
  DataVisibility,
  BondStatus,

  // API responses
  MCRResponse,
  MachineProfileResponse,
  OperatorMachinesResponse,
  MCRRating,
  RevenueTrend,

  // DID
  WriteMachineDIDParams,
  WriteProxyDIDParams,
  DIDWriteAttribute,
  DIDAttributeResult,

  // Wallet
  WalletInfo,
  AccountInfo,
  KeyType,
  ImportChain,
  WalletOptions,

  // Query options
  GetJsonOptions,

  // Methods
  DeploySmartAccountParams,
  BridgeNftParams,
  WaitForBridgeArrivalParams,

  // Faucet
  FaucetErrorCode,
  FaucetFundResponse,
  FaucetFundSkippedResponse,
  FaucetFundSuccessResponse,
  FaucetQrFormat,
  FaucetSetupResponse,
  FundFromGasStationParams,

  // OWS signing
  OwsSigningErrorCode,

  // Error constructor options
  RuntimeErrorOptions,
  ValidationErrorArgs,
} from "@peaqos/peaq-os-sdk";

// Enums
import { MachineStatus } from "@peaqos/peaq-os-sdk";

Constants

import {
  EVENT_TYPE_REVENUE,        // 0
  EVENT_TYPE_ACTIVITY,       // 1

  TRUST_SELF_REPORTED,       // 0
  TRUST_ON_CHAIN_VERIFIABLE, // 1
  TRUST_HARDWARE_SIGNED,     // 2
} from "@peaqos/peaq-os-sdk";
import {
  DID_ATTR_MACHINE_ID,
  DID_ATTR_NFT_TOKEN_ID,
  DID_ATTR_OPERATOR,
  DID_ATTR_DOCUMENTATION_URL,
  DID_ATTR_DATA_API,
  DID_ATTR_DATA_VISIBILITY,
  DID_ATTR_MACHINES,

  DID_MAX_NAME_BYTES,  // 64
  DID_MAX_VALUE_BYTES, // 2560
} from "@peaqos/peaq-os-sdk";
import {
  SUPPORTED_CHAIN_IDS,  // { peaq: 3338, ethereum: 1, base: 8453, polygon: 137, arbitrum: 42161, optimism: 10 }
  LAYER_ZERO_EIDS,      // { peaq: 30302, base: 30184 }
  DEFAULT_API_URL,      // "http://127.0.0.1:8000"
} from "@peaqos/peaq-os-sdk";
import {
  IMPORT_CHAIN_EVM,       // "evm" (default)
  IMPORT_CHAIN_SOLANA,    // "solana"
  IMPORT_CHAIN_BITCOIN,   // "bitcoin"
  IMPORT_CHAIN_COSMOS,    // "cosmos"
  IMPORT_CHAIN_TRON,      // "tron"
  IMPORT_CHAIN_TON,       // "ton"
  IMPORT_CHAIN_SUI,       // "sui"
  IMPORT_CHAIN_XRPL,      // "xrpl"
  IMPORT_CHAIN_SPARK,     // "spark"
  IMPORT_CHAIN_FILECOIN,  // "filecoin"

  KEY_TYPE_MNEMONIC,      // "mnemonic"
  KEY_TYPE_PRIVATE_KEY,   // "private_key"

  OWS_PASSPHRASE_ENV,         // "OWS_PASSPHRASE"
  DEFAULT_MCR_HTTP_TIMEOUT_MS, // 30_000
} from "@peaqos/peaq-os-sdk";
IMPORT_CHAIN_* is the union behind the ImportChain type alias used by importWallet. KEY_TYPE_* matches the KeyType field on WalletInfo.
import {
  OWS_ERROR_WALLET_NOT_FOUND,     // "WALLET_NOT_FOUND"
  OWS_ERROR_INVALID_PASSPHRASE,   // "INVALID_PASSPHRASE"
  OWS_ERROR_INVALID_INPUT,        // "INVALID_INPUT"
  OWS_ERROR_POLICY_DENIED,        // "POLICY_DENIED"
  OWS_ERROR_CHAIN_NOT_SUPPORTED,  // "CHAIN_NOT_SUPPORTED"
} from "@peaqos/peaq-os-sdk";
Surface area for the OWS-native signing path used by PeaqosClient.fromWallet(..., owsSigning: true). The matching OwsSigningErrorCode type is the union of all five string-literal codes.