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 i @logos-kit/codecProgram 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')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') // 1Accounts 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, utf8 | Bytes |
sha256(bytes) | Pure-JS SHA-256 |
Reader, Writer | Borsh |
Messages and transactions
| Export | |
|---|---|
encodeMessage, decodeMessage, messageHash | Public messages |
encodeTransaction, decodeTransaction, transactionHash, sendTransactionParam | Signed transactions |
defaultMaxFee(gasLimit), DEFAULT_GAS_LIMIT | Fees |
Testimonials
| Export | |
|---|---|
TESTIMONIAL_PROGRAMS | The deployed program per chain (lez:testnet and lez:preview) |
testimonialPost(…) | The post call (the page account included) |
decodeTestimonial, decodeTestimonialStats | Records and stats pages |
TESTIMONIAL_MAX_TEXT (280), TESTIMONIAL_MAX_USERNAME (32), TESTIMONIAL_PAGE_SIZE (1000) | The program's limits (bytes) |