borsh
Borsh JS
Examples
(De)serializing a Value
import * as borsh from 'borsh';
const encodedU16 = borsh.serialize('u16', 2);
const decodedU16 = borsh.deserialize('u16', encodedU16);
const encodedStr = borsh.serialize('string', 'testing');
const decodedStr = borsh.deserialize('string', encodedStr);(De)serializing an Object
import * as borsh from 'borsh';
const value = {x: 255, y: BigInt(20), z: '123', arr: [1, 2, 3]};
const schema = { struct: { x: 'u8', y: 'u64', 'z': 'string', 'arr': { array: { type: 'u8' }}}};
const encoded = borsh.serialize(schema, value);
const decoded = borsh.deserialize(schema, encoded);API
Schemas
Basic Types
Arrays, Options, Maps, Sets, Enums, and Structs
Type Mappings
Javascript
Borsh
Contributing
Publish
License
Last updated