Skip to main content

vault.registerIdentity(RegisterIdentity)

Register an ONCHAINID for a user in the vault’s Identity Registry. Must be called by a wallet authorized as an agent/operator for the registry.

RegisterIdentity Type Parameters

ParameterTypeRequiredDescription
vaultDeployerSignerRequiredAuthorized agent of the Identity Registry. Must be connected to a provider.
vaultstringRequiredVault address whose Identity Registry will be updated.
subjectstringRequiredUser’s EOA to be associated with the identity.
subjectIdentitystringRequiredONCHAINID contract address for the user.
countrystringRequiredCountry code for the investor (e.g., '0').

Returns

FieldTypeDescription
statusregisteredStatus of the operation.
vaultstringVault address.
identityRegistrystringIdentity Registry contract address.
subjectstringUser’s EOA associated with the identity.
subjectIdentitystringONCHAINID contract address for the user.
countrystringCountry code.
registeredBystringAddress that submitted the transaction.
receiptTransactionReceiptTransaction receipt of the registration call.

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 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. Vault deployer (must be an authorized agent)
  const vaultDeployer = new Wallet(process.env.ADMIN_PRIVATE_KEY!, provider);

  // 2. Get EOA and identity
  const alice = await rwa_sdk.onchainid.getIdentity({ subject: process.env.ALICE_PUBLIC_ADDRESS! });

  // 3. Register Alice's identity in the vault's Identity Registry
  const result = await rwa_sdk.vault.registerIdentity({
    vaultDeployer: vaultDeployer,
    vault: "0x907229D0A25A5Bb16F0ff3D890f38Eb4Ad52Ea1a",
    subject: process.env.ALICE_PUBLIC_ADDRESS!,
    subjectIdentity: alice.identity,
    country: '0'
  });
  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 provider
  const provider = new JsonRpcProvider(process.env.HTTPS_BASE_URL);
  const rwa_sdk = new RWA({ chainId: Chain.AGUNG, provider });

  // 1. Vault deployer (must be an authorized agent)
  const vaultDeployer = new Wallet(process.env.ADMIN_PRIVATE_KEY, provider);

  // 2. Get EOA and identity
  const alice = await rwa_sdk.onchainid.getIdentity({ subject: process.env.ALICE_PUBLIC_ADDRESS });

  // 3. Register Alice's identity in the vault's Identity Registry
  const result = await rwa_sdk.vault.registerIdentity({
    vaultDeployer: vaultDeployer,
    vault: "0x907229D0A25A5Bb16F0ff3D890f38Eb4Ad52Ea1a",
    subject: process.env.ALICE_PUBLIC_ADDRESS,
    subjectIdentity: alice.identity,
    country: '0'
  });
  console.log("Result", result);
}

main().catch((err) => {
  console.error(err);
  process.exit(1);
});

Example outputs

Result {
  status: 'registered',
  vault: '0x907229D0A25A5Bb16F0ff3D890f38Eb4Ad52Ea1a',
  identityRegistry: '0x...',
  subject: '0x16cd4D21537eD8F33bE08271A9FA6DCC426709b2',
  subjectIdentity: '0x...',
  country: '0',
  registeredBy: '0x8BCfa2e9FC4aCa66fCF36Bcf47646E5Fb8d74BA0',
  receipt: ContractTransactionReceipt {
    ...
  }
}
Notes:
  • Ensure the user does not already have an identity registered for this vault.
  • vaultDeployer must be configured as an agent of the Identity Registry.