Logos Kit

Codec

@logos-kit/codec: byte-exact LEZ 0.3 encoding, program calls and amounts, without BigInt.

@logos-kit/codec encodes and decodes what LEZ puts on the wire: account ids, messages, transactions, program instructions and the testimonial program's records. It matches the Rust engine byte for byte (both are checked against the same test vectors), and it runs in Qt's JavaScript engine: no native BigInt, u128 values are decimal strings.

npm@logos-kit/codecv0.1.1
npm i @logos-kit/codec

Program calls

A ProgramCall is what sendCall proposes: the program, the accounts it touches, and the instruction bytes.

import { ,  } from '@logos-kit/codec'
import type {  } from '@logos-kit/codec'

declare const : , : , : 

const  = (, , '42')
const give = (, , , '250')
const give: ProgramCall

Prop

Type

Amounts

The native token, LOGOS (LGO), has 9 decimals: on the wire and in the SDK its amounts are lepta (1 LGO = 10^9 lepta). formatUnits never rounds, and trims trailing zeros.

import { , , ,  } from '@logos-kit/codec'

('2.5', 9)      // "2500000000": LGO → lepta
('1', 9)       // "0.000000001": lepta → LGO
('1.5', 6)      // "1500000"
('1500000', 6) // "1.5"
('1', '2')             // "3"
('10', '9')        // 1

Accounts and bytes

Export
isAccountId(s), publicAccountId(pubkey), publicPda(program, seed)Account ids (base58)
NATIVE_TOKEN_PROGRAM, TOKEN_PROGRAM, ATA_PROGRAM, PROGRAM_LOADER, builtinProgram(name)Built-in programs
toBase58/fromBase58, toBase64/fromBase64, toHex/fromHex, utf8Bytes
sha256(bytes)Pure-JS SHA-256
Reader, WriterBorsh

Messages and transactions

Export
encodeMessage, decodeMessage, messageHashPublic messages
encodeTransaction, decodeTransaction, transactionHash, sendTransactionParamSigned transactions
defaultMaxFee(gasLimit), DEFAULT_GAS_LIMITFees

Testimonials

Export
TESTIMONIAL_PROGRAMSThe deployed program per chain (lez:testnet and lez:preview)
testimonialPost(…)The post call (the page account included)
decodeTestimonial, decodeTestimonialStatsRecords and stats pages
TESTIMONIAL_MAX_TEXT (280), TESTIMONIAL_MAX_USERNAME (32), TESTIMONIAL_PAGE_SIZE (1000)The program's limits (bytes)

On this page