Skip to main content

Claim a VM ID

In the PWR Chain ecosystem, Virtual Machines (VMs) play a crucial role in enabling developers to build and deploy decentralized applications (dApps). Each VM is identified by a unique ID, known as the VM ID. As a developer, you need to claim a VM ID to indicate that it is being used by your application and to receive certain benefits.

In this guide, we'll walk you through the process of claiming a VM ID on the PWR Chain using the PWR SDK.

Understanding VM IDs

A VM ID is a unique identifier that represents a specific Virtual Machine on the PWR Chain. It serves as an address for your application, allowing it to interact with the PWR Chain and other applications.

Claiming a VM ID has the following benefits:

  1. Ownership: By claiming a VM ID, you establish ownership of that particular VM. It informs others that the VM is being used by your application and is not available for others to claim.
  2. Transaction Fee Rewards: When you claim a VM ID, you become eligible to receive 15% of the transaction fees generated by transactions sent to your VM. This serves as a reward for developers and helps incentivize the development of dApps on the PWR Chain.

Claiming a VM ID

To claim a VM ID on the PWR Chain, follow these steps:

  1. Create a PWR Wallet: If you haven't already, create a PWR wallet that will be used to claim the VM ID. You can refer to the Wallets in PWR Chain guide for detailed instructions.
  2. Unique VM ID: Choose a unique VM ID, no one has claimed it.
  3. Claim the VM ID: Use the PWR SDK to claim the VM ID by sending a "Claim VM ID" transaction.
const { PWRWallet } = require('@pwrjs/core');

// Setting up your wallet in the SDK
const privateKey = "YOUR_PRIVATE_KEY_HERE";
const wallet = new PWRWallet(privateKey);

async function claim() {
// Add a unique VM ID
const vmId = 102030;

// Claim the VM ID
const txHash = await wallet.claimVmId(vmId);

// Error handling
if (txHash.success) {
console.log("Transaction Hash:", txHash.transactionHash);
} else {
console.log("Error:", txHash.message);
}
}
claim()

Using the wallet's claimVmId method, we claim the VM ID by providing the vmId. The SDK will handle the creation and signing of the "Claim VM ID" transaction.

If the transaction is successfully sent, we receive a response containing the transaction hash. Otherwise, we handle the error accordingly.

Once the transaction is confirmed, the VM ID is successfully claimed, and you become the owner of that VM. You will start receiving 15% of the transaction fees generated by transactions sent to your VM.

Best Practices for Claiming VM IDs

When claiming VM IDs on the PWR Chain, consider the following best practices:

  1. Choose a Unique VM ID: Ensure that the VM ID you generate is unique and not already claimed by another application. Collision of VM IDs can lead to conflicts and unexpected behavior.
  2. Secure Your Private Key: Keep your wallet's private key secure and never share it with anyone.
  3. Monitor Your VM: Regularly monitor your claimed VM for any suspicious activities or unauthorized transactions.
  4. Update Your Application: Keep your application up to date with the latest PWR Chain features and security patches.

By following these best practices and leveraging the PWR SDK's VM ID claiming capabilities, you can securely claim a VM ID for your application on the PWR Chain, establish ownership, and receive transaction fee rewards for your dApp's usage.