Skip to content

Candid

JavaScript and TypeScript module to work with Candid interfaces

import { IDL } from '@icp-sdk/core/candid';
const MyType = IDL.Record({
name: IDL.Text,
age: IDL.Nat8,
});
const encoded = IDL.encode([MyType], [{ name: 'John', age: 30 }]);
const decoded = IDL.decode([MyType], encoded);
console.log(decoded); // [{ name: 'John', age: 30 }]