Created
December 30, 2025 15:32
-
-
Save xstelea/7ae4a89bc2fd9909660a7881d3aacd7c to your computer and use it in GitHub Desktop.
derive virtual badge from ed21559 public key
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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