The Protocol
Example Code
import { sha256 } from "js-sha256";
import bs58 from "bs58";
const generateLotId = (secret, txHash, vbyteSize, projectName) => {
const combinedString = `${secret}_${txHash}`;
const hash = sha256(combinedString);
const encodedHash = bs58.encode(Buffer.from(hash, "hex"));
const shortened = encodedHash.slice(-6);
const sizeLabel =
vbyteSize >= 5000
? "estate"
: vbyteSize >= 1000
? "large"
: vbyteSize >= 250
? "medium"
: "small";
const lotId = `${shortened}_${vbyteSize}_${sizeLabel}_${projectName
.toLowerCase()
.replace(" ", "-")
.trim()}.lot`;
return lotId;
};
const projectName = "Cool Project";
const secret = "password123!";
// The vBytes for these txs are fake for demo purposes
const blockTransactions = [
{
id: "12a736139936b556436b30909738923f6e89f3eddc0ee243a8b4c44418431ae6",
vBytes: 187,
},
{
id: "a6d9ed33af05dd0d57b7260e233b2b9e3784e6c9dc781c15a271f881c0c763a5",
vBytes: 275,
},
{
id: "4a83a74324f398d53cb3c8d56c77eb7732f12a3f4998e57647d1669db397d123",
vBytes: 2343,
},
{
id: "ed16e145735ce241a9f5e19f9c24f6325e6c6060fb95ccf04603a6fe01ab2392",
vBytes: 7342,
},
];
blockTransactions.forEach((tx) => {
const lotId = generateLotId(secret, tx.id, tx.vBytes, projectName);
console.log(lotId);
});
// Result:
// gQWu7U_187_small_cool-project.lot
// JCacfC_275_medium_cool-project.lot
// x4GiW4_2343_large_cool-project.lot
// R6w67y_7342_estate_cool-project.lotLast updated