generateIdentifier
When to Use
When to Use It?
Example; Creating a new token account with generateIdentifier and setting info
// Step 1: Generate a new token identifier with custom options
const pendingAccount = builder.generateIdentifier('TOKEN', {
owner: user.account, // Assign the initial owner of the token
symbol: 'DEMO', // Token symbol
decimals: 2, // Number of decimal places
metadata: {
category: 'Real World Asset',
createdBy: 'Demo Script'
}
});
// Step 2: Prepare base64-encoded metadata (for demonstration)
const assetInfo = {
assetType: 'Real World Asset',
issuer: 'Demo Organization',
issuedAt: new Date().toISOString()
};
const metadata_base64 = Buffer.from(JSON.stringify(assetInfo)).toString('base64');
// Step 3: Attach info and default permissions to the new token account
builder.setInfo({
name: 'DEMORWA',
description: 'Demo Token for Real World Asset',
metadata: metadata_base64, // base64-encoded JSON with asset info + signature
defaultPermission: newKeetaNet.lib.Permissions(['ACCESS'], [])
}, {
account: pendingAccount.account // The account you're attaching this info to
});
Last updated