Skip to main content
An authorized signer turns a machine’s monetization on or off with a signed toggle, and anyone can read the current state. The SDK builds the byte-exact canonical message, signs it, and handles the coded error envelope, so you never assemble the message by hand. State is stored off-chain in the MCR server; no on-chain transaction is made. Opting in requires the machine to be bonded and not deactivated (server-enforced). Opting out is always allowed. The read is public and doubles as the pre-provisioning check.

Economics 2.0

The configuration is a deployment ID. The SDK resolves the MCR URL (https://mcr.peaq.xyz for peaq-mainnet), chain ID, MachineRegistry address, and protocol version from the same deployment record that activation uses; callers cannot supply or override any of them.
For a machine homed on Solana (guide) both SDKs carry the owner-signed path (solanaSigner / solana_signer in MonetizationConfig, a five-line message with home_chain: 5, plain Ed25519 signMessage, body with signer_pubkey), but Solana-homed writes are refused. When solanaSigner / solana_signer is set, the SDK first reads the machine’s home chain (a compatibility GET and a profile GET) and refuses a Solana-homed write with MonetizationValidationError (JS) / ValidationError (Python) code SOLANA_MONETIZATION_UNVERIFIED before anything is signed. Without a Solana signer the SDK does not check the home chain and sends the EIP-191 write. Reads work for every home. Details: SDK JS, SDK Python.

Machine key

Reads take the machine as a full-width uint256 (bigint in JS, int in Python) or as did:peaq:<canonical decimal machine id>; optIn / opt_in and optOut / opt_out take the numeric machineId / machine_id, the DID form goes into their separate key argument. Address-form DIDs (did:peaq:0x…), decimal strings in JS, leading zeros, signs, and exponents are rejected locally before any HTTP. There is no lookup from a 1.0 address DID to a 2.0 machine ID.

Who may sign

The machine’s current MachineRegistry owner or DID controller. A legacy machine-wallet key or a 1.0 EventRegistry operator key is not authorized (403 UNAUTHORIZED_SIGNER). The canonical message binds registry: <MachineRegistry address, lowercased> and chain_id: 3338.

Configuration

The resolved values are readable (api_base, registry, chain_id, api_version in Python) but not settable. apiBase, registry, and chainId as constructor fields are gone; passing them is a TypeError in Python and a type error in TypeScript.

Compatibility check

Before every read and write the SDK fetches GET {apiBase}/.well-known/peaq-monetization and requires the exact protocol version (tokenomics-2.0-monetization-v1, exported as TOKENOMICS_MONETIZATION_API_VERSION), the canonical decimal chain ID, and the lowercased MachineRegistry address from the selected deployment. A write runs this check before invoking the signer. Missing, malformed, or mismatched signals raise MonetizationCompatibilityError (code MONETIZATION_API_INCOMPATIBLE). Not cached, cannot be bypassed.

Retries, deadline, cancellation

Python passes these through GetMonetizationOptions and SetMonetizationOptions.

The response

Errors

Re-sending the identical signed request surfaces STALE_SIGNATURE; re-signing the same state with a newer timestamp succeeds, so the toggle is idempotent to retry.

From the terminal

The CLI wraps this surface as peaqos monetize opt-in | opt-out | status; all signing and HTTP stay in the SDK.