Skip to main content
Onboarding a machine to the peaq network can be done in several ways. The most direct one is the JavaScript SDK, which creates a DID Document for the machine. Test your implementation on the agung testnet before you deploy to peaq mainnet. Onboarding, verification, and data storage are then proven before real value is involved.

Prerequisites

Before onboarding a machine, you should understand:

Instructions

The JavaScript SDK provides a developer-friendly way to:
  • Create a DID Document for a machine.
  • Define the machine’s cryptographic identity using EcdsaSecp256k1, Ed25519, or Sr25519 based on the wallet that will be used to create signatures.
  • Add service endpoints to link ownership and storage solutions.
  • Store and retrieve DID-related information from the peaq blockchain.

1. Installing ethers & peaq js

To get started, install:
  • ethers - library used for wallet generation and token transfer.
  • peaq network sdk - generates DID Documents and offers peaq storage.
In your local node environment run:
If the install gives you trouble, see the SDK Installation Guide.

2. Creating a Machine Wallet

Each machine onboarded to the peaq network needs its own cryptographic identity, so you create a dedicated wallet that represents it. The wallet lets the machine sign data, authenticate itself, and send transactions. peaq is EVM-compatible, so key management uses the ECDSA (Elliptic Curve Digital Signature Algorithm) scheme and the machine can sign with EVM-standard tools. The example below shows how to generate a new wallet using the ethers npm package:
The ECDSAKeyring class wraps an EVM-compatible wallet. It exposes the machine’s public address, its private key, and a signMessage method used later for signing and authentication.
Never share or expose the machine’s private key. Possession of this key allows anyone to impersonate the machine, sign data, and perform transactions on its behalf. Losing the key means losing access and control over the machine’s on-chain identity.

3. Token Transfer

A machine pays a fee in the network’s native token for every write it makes on chain: registering its DID, storing data on chain, or calling a smart contract. That fee, called gas, pays for computation and storage and keeps spam off the network. Signing a message is done locally on the device, so it needs no gas. After creating the wallet, transfer a small amount of the native token from your admin wallet to the machine wallet. The machine can then transact on its own. If you have no tokens, use the faucet page. The code below demonstrates how to transfer 1 token from an admin account to the machine’s wallet:
This example uses the agung testnet RPC endpoint. Switch to the peaq mainnet endpoint when you onboard real machines. After running this script, your machine wallet holds 1 native token and can execute transactions on the peaq network.

4. Creating a Machine DID Document

With a funded wallet in place, register a Decentralized Identifier (DID) Document for the machine. The DID Document is a verifiable structure that ties the machine’s cryptographic keys to a unique identifier, so the machine can authenticate itself and prove ownership of its data. The example below registers a DID on the agung testnet with the peaq JavaScript SDK. The document contains:
  • Verification Methods - Public keys that let others verify signatures made by the machine.
  • Service Endpoints - Metadata such as the machine’s admin wallet address or off-chain services.
The DID Document links the machine’s address to a verification method derived from its wallet, and records the admin account responsible for it. Because the transaction is sent from the machine’s wallet, the network can prove the machine created this identity itself. For updates, deactivation, and retrieval, see DID Operations.

Putting it all together

The script below runs the complete onboarding flow against the agung testnet:
  1. Creating a machine wallet.
  2. Loading an administrator wallet (with native tokens).
  3. Transferring tokens to the machine wallet.
  4. Registering a DID Document that represents the machine’s on-chain identity.

Summary

Your machine now has a cryptographic identity (an EVM wallet), native tokens to pay for gas, and a DID Document that serves as its verifiable on-chain identity. It can take part in a DePIN: validating credentials, authenticating data, and running tasks on its own. For production:
  • Store private keys securely, for example in encrypted storage or a secure enclave.
  • Do not hardcode secrets into your codebase.
  • Use the peaq mainnet endpoint instead of the agung testnet.
The next step is to store and retrieve data with peaq storage, the on-chain layer machines use to persist information.