Skip to content

Instantly share code, notes, and snippets.

@longngn
Created March 10, 2022 17:47
Show Gist options
  • Save longngn/a9766049a978b7459d460f489ef0dc23 to your computer and use it in GitHub Desktop.
Save longngn/a9766049a978b7459d460f489ef0dc23 to your computer and use it in GitHub Desktop.
// Given the assetName of LBE NFT, return the booster rate from 110% to 200%
function getBoosterRate(nftName) {
if (nftName.length !== 32) {
throw new Error('NFT name must have 32 chars')
}
let sum = 0
// only the first 30 chars of NFT name is tied to the wallet
// we calculate booster rate from the first 30 chars
for (let i = 0; i < 30; i++) {
sum += nftName.charCodeAt(i)
}
return 110 + (sum % 10) * 10
}
console.log(getBoosterRate("ZY8B1n0vVm6+11geNb7b8QASBfs9Jz05"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment