🚧Issuance example
Last updated
function encodeBitcoinVarInt(value) {
if (value < 0xfd) {
return [value];
} else if (value <= 0xffff) {
return [0xfd, value & 0xff, (value >> 8) & 0xff];
} else if (value <= 0xffffffff) {
return [0xfe, value & 0xff, (value >> 8) & 0xff, (value >> 16) & 0xff, (value >> 24) & 0xff];
} else {
return [
0xff,
value & 0xff,
(value >> 8) & 0xff,
(value >> 16) & 0xff,
(value >> 24) & 0xff,
(value >> 32) & 0xff,
(value >> 40) & 0xff,
(value >> 48) & 0xff,
(value >> 56) & 0xff,
];
}
}
function encodeBitcoinVarIntTuple(tuple) {
const encodedBytes = tuple.map(encodeBitcoinVarInt).flat();
// Convert the bytes to a hexadecimal string
const hexString = encodedBytes.map(byte => byte.toString(16).padStart(2, '0')).join('');
return hexString;
}0 => 00
1 => 01
21000000 => fe406f4001
[0, 1, 21000000] => 0001fe406f4001// Some code
const bb26 = require("base26");
const text = 'rune';
const formatOrdinalBase26 = (text) => {
const result = (2099999997689999 + 1 - bb26.from(text));
return result;
};
RUNE => 2099999997359067 => ffdbf3de59dbf3de59
18 => 12
[RUNE, 18] => ffdbf3de59dbf3de5912OP_RETURN 52 0001fe406f4001 ffdbf3de59dbf3de5912