Skip to content

Instantly share code, notes, and snippets.

@xstelea
Created December 30, 2025 15:32
Show Gist options
  • Select an option

  • Save xstelea/7ae4a89bc2fd9909660a7881d3aacd7c to your computer and use it in GitHub Desktop.

Select an option

Save xstelea/7ae4a89bc2fd9909660a7881d3aacd7c to your computer and use it in GitHub Desktop.
derive virtual badge from ed21559 public key
import { blake2b } from '@noble/hashes/blake2b';
import { bytesToHex, hexToBytes } from '@noble/hashes/utils';
const publicKeyHex = '554a6db54c09d609deabf5b234ab3627cdd182ebf0d60baa070ba4ba2e8e5b7a';
function deriveNftLocalId(publicKeyHex: string): string {
const publicKeyBytes = hexToBytes(publicKeyHex);
const hash = blake2b(publicKeyBytes, { dkLen: 32 }); // Blake2b-256
const last26Bytes = hash.slice(-26); // Last 26 bytes
return bytesToHex(last26Bytes);
}
const nftLocalId = deriveNftLocalId(publicKeyHex);
// Ed25519 virtual signature badge resource addresses
const ED25519_BADGE = {
mainnet: 'resource_rdx1nfxxxxxxxxxxsgnture9xxxxxxxxx004007650489xxxxxxxxxxu85e5y',
stokenet: 'resource_tdx_2_1nfxxxxxxxxxxsgnture9xxxxxxxxx004007650489xxxxxxxxxseuu08',
};
console.log(`NFT Local ID: ${nftLocalId}`);
console.log(`\nMainnet:`);
console.log(`NonFungibleGlobalId("${ED25519_BADGE.mainnet}:[${nftLocalId}]")`);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment