Skip to content

Instantly share code, notes, and snippets.

@ilyar
Created November 6, 2025 09:21
Show Gist options
  • Select an option

  • Save ilyar/7a13c637a492ea3653791e0aa3730820 to your computer and use it in GitHub Desktop.

Select an option

Save ilyar/7a13c637a492ea3653791e0aa3730820 to your computer and use it in GitHub Desktop.
// npx ts-node hex-to-boc.ts
import { BitReader, BitString, Builder, Slice } from "@ton/core";
async function main() {
const data = Buffer.from('000000000000000000000000000000000000000000000000000000000000002a', 'hex');
const bs = new BitString(data, 0, data.length * 8);
const r = new BitReader(bs);
const s = new Slice(r, []);
const b = new Builder();
const c = b.storeSlice(s).endCell();
console.log(c.toBoc().toString('base64'));
}
main().catch((error) => {
if (error instanceof Error) {
console.log(error.message);
console.log(error.stack);
} else {
console.log('Unknown error:', error);
}
process.exit(1);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment