Skip to main content

Retrieving User Account IDs

The process of retrieving a user's account ID using the edeXa ERC721 SDK is an essential step for managing Non-Fungible Tokens (NFTs) related to ownership and transfers. This guide outlines how to utilize the getAccount method efficiently.


Overview of the getAccount Method

The getAccount method is specifically designed to obtain the account ID associated with a specific user. This ID plays a crucial role in various token operations, facilitating unique identification within the blockchain network.


Prerequisites

  • Installation of the edeXa ERC721 SDK in your project.
  • An authentication token obtained through the SDK's authentication method. This token is necessary to authorize your requests.

Sample Code Snippet

Here is a JavaScript code snippet demonstrating the use of the getAccount method:

import { ERC721, Network } from 'edeXa-sdk';
async function getAccount() {
const settings = {
network: Network.SANDBOX, // Use Network.MAINNET for production
};
const erc721 = new ERC721({
...settings,
authorization: `Bearer ${token}`, // Substitute `${token}` with your actual authentication token
});

const dataToGetAccount = {
userId: 'Enter the UUID of the user', // UUID from the user enrollment process
chaincode: 'Optional smart contract name', // Managing tokens' smart contract name, if applicable
channel: 'Optional blockchain channel name', // Blockchain channel name, if applicable
};

try {
const getAccountResponse = await erc721.getAccount(dataToGetAccount);
// Handle success
} catch (error) {
// Handle error
}
}

Request Parameters

ParameterRequiredTypeDescriptionDefault
userIdYesStringThe uuid of the user for whom to retrieve the account ID
chaincodeOptionalStringThe name of the smart contract managing the tokensDefault chaincode
channelOptionalStringThe name of the channel in the blockchain networkDefault channel

Response Structure

Upon successful retrieval, the getAccount method returns a response in the following format:

KeyTypeDescription
usernameStringThe username (account ID) of the user