mnft.registerMachine(RegisterMachine)
Register one or more Machine NFTs to a designated controller. This sends transactions from the Machine Issuer and charges the ERC20 fee from the controller. The Machine NFT contract must be funded before you call this.
machineNft must be the Machine NFT contract created for this issuer by addMachineIssuer; a signer that is not its issuer reverts with User unauthorized. The controller must have an ONCHAINID identity with a verified KYC claim, or the call reverts with NoIdentityFound / UserNotKyxd.
In
@peaq-network/rwa 0.1.0, registerMachine writes a fixed sample DID document for every machine (a BMW X3 vehicle record with placeholder service endpoints). It does not take your machine’s brand, model, or serial number, and salt only changes the sample serial-number suffix. The record is permanent and each machine costs the registration fee. Use agung until the SDK accepts real machine metadata.RegisterMachine Type Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| machineIssuer | Signer | Required | Machine Issuer signer that submits the mint transactions. Must be connected to a provider. |
| machineNft | string | Required | Machine NFT contract address. |
| machineValueHuman | string | Required | Machine value in human-readable units (e.g., "10"). |
| machineControllerAddr | string | Required | EOA address that will control/own the machines. |
| erc20 | string | Required | Fee token address. Must be the native PEAQ precompile, rwa_sdk.getAddresses().erc20.peaq (0x0000000000000000000000000000000000000809); the contracts charge fees in PEAQ only. |
| tokenDecimals | number | Required | ERC20 token decimals. |
| salt | number | Required | Integer the SDK turns into serial-number suffixes salt * count through salt * count + count - 1 in the generated DID document, which fix the machine IDs. Keep these ranges from overlapping across calls to the same Machine NFT contract: a different salt alone is not enough when count changes (salt: 1, count: 2 and salt: 2, count: 1 both produce suffix 2). |
| count | number | Required | Number of machines to register. |
Returns
| Field | Type | Description |
|---|---|---|
| status | issued | Status of the operation. |
| machineNft | string | Machine NFT contract address. |
| machineIssuer | string | Machine Issuer address that submitted the transaction(s). |
| machineController | string | Machine controller/owner address. |
| machineValue | { human: string; units: bigint; tokenDecimals: number; feeToken: string } | Machine value details. |
| count | number | Number of machines issued. |
| machines | { machineId: string; did?: string; receipt?: TransactionReceipt }[] | Per-machine results and receipts. did is the DID document serialized by its protobuf toString(), not the bare DID. Read a machine’s DID with getMachineDid. |
| feesPaid | bigint | ERC20 fees paid by the controller. |
| startingBalance | bigint | Controller ERC20 balance before issuance. |
| endingBalance | bigint | Controller ERC20 balance after issuance. |
| humanTokenDelta | string | Human-readable fee delta. |
Usage
TypeScript
import 'dotenv/config';
import { RWA, Chain, type SDKInit } from "@peaq-network/rwa";
import { JsonRpcProvider, Wallet } from "ethers";
async function main() {
// 0. Create RWA instance and get provider
const provider = new JsonRpcProvider(process.env.HTTPS_BASE_URL);
const init: SDKInit = { chainId: Chain.AGUNG, provider: provider };
const rwa_sdk = new RWA(init);
// 1. Machine Issuer wallet
const machineIssuer = new Wallet(process.env.MACHINE_ISSUER_PRIVATE_KEY!, provider);
// 2. Machine controller (receives NFT and pays ERC20 fee via allowance)
const alice = process.env.ALICE_PUBLIC_ADDRESS!;
// 3. Register MachineNFT(s) for Alice
const result = await rwa_sdk.mnft.registerMachine({
machineIssuer: machineIssuer,
machineNft: process.env.MACHINE_NFT_ADDRESS!,
machineValueHuman: "10",
machineControllerAddr: alice,
erc20: rwa_sdk.getAddresses().erc20.peaq,
tokenDecimals: 18,
salt: Math.floor(Math.random() * 10000),
count: 2
});
console.log('Result', result);
}
main().catch((err) => {
console.error(err);
process.exit(1);
});
JavaScript
import 'dotenv/config';
import { RWA, Chain } from "@peaq-network/rwa";
import { JsonRpcProvider, Wallet } from "ethers";
async function main() {
// 0. Create RWA instance and get provider
const provider = new JsonRpcProvider(process.env.HTTPS_BASE_URL);
const rwa_sdk = new RWA({ chainId: Chain.AGUNG, provider });
// 1. Machine Issuer wallet
const machineIssuer = new Wallet(process.env.MACHINE_ISSUER_PRIVATE_KEY, provider);
// 2. Machine controller (receives NFT and pays ERC20 fee via allowance)
const alice = process.env.ALICE_PUBLIC_ADDRESS;
// 3. Register MachineNFT(s) for Alice
const result = await rwa_sdk.mnft.registerMachine({
machineIssuer: machineIssuer,
machineNft: process.env.MACHINE_NFT_ADDRESS,
machineValueHuman: "10",
machineControllerAddr: alice,
erc20: rwa_sdk.getAddresses().erc20.peaq,
tokenDecimals: 18,
salt: Math.floor(Math.random() * 10000),
count: 2
});
console.log('Result', result);
}
main().catch((err) => {
console.error(err);
process.exit(1);
});
Example outputs
Result {
status: 'issued',
machineNft: '0x5Ca3db1f292f913DDdA8C5385E5391438665463c',
machineIssuer: '0x8BCfa2e9FC4aCa66fCF36Bcf47646E5Fb8d74BA0',
machineController: '0x16cd4D21537eD8F33bE08271A9FA6DCC426709b2',
machineValue: {
human: '10',
units: 10000000000000000000n,
tokenDecimals: 18,
feeToken: '0x...'
},
count: 2,
machines: [
{ machineId: '1262843802665614120367007478296348432923457422026', did: '<serialized DID document>', receipt: TransactionReceipt { ... } },
{ machineId: '880598419457374294774049460835571533031091411284', did: '<serialized DID document>', receipt: TransactionReceipt { ... } }
],
feesPaid: 20000000000000000000n,
startingBalance: 100000000000000000000n,
endingBalance: 80000000000000000000n,
humanTokenDelta: '20.0'
}

