INNER CODE UNIT · TypeScript

base58

blueshift-gg/doppler · packages/core/index.ts:121

function base58(bytes: Uint8Array): string {
  let zeros = 0;
  while (zeros < bytes.length && bytes[zeros] === 0) zeros++;

  let n = 0n;
  for (let i = zeros; i < bytes.length; i++) n = (n << 8n) | BigInt(bytes[i]!);

  let out = '';
  while (n > 0n) {
    out = ALPHABET[Number(n % 58n)] + out;
    n /= 58n;
  }
  return '1'.repeat(zeros) + out;
}

type Slot = { name: string; type: Ty; len: number; offset: number };

/** `unitPrice` is micro-lamports per compute unit; the fee is `5000` per signature plus `ceil(unitPrice * units / 1e6)`. */

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…