int
The CandidType
object int
corresponds to the Candid type int, is inferred to be a TypeScript bigint
, and will be decoded into a JavaScript BigInt at runtime.
TypeScript or JavaScript:
import { Canister, int, query } from 'azle/experimental';
export default Canister({
getInt: query([], int, () => {
return 170_141_183_460_469_231_731_687_303_715_884_105_727n;
}),
printInt: query([int], int, (int) => {
console.log(typeof int);
return int;
})
});
Candid:
service : () -> {
getInt : () -> (int) query;
printInt : (int) -> (int) query;
}
dfx:
dfx canister call candid_canister printInt '(170_141_183_460_469_231_731_687_303_715_884_105_727 : int)'
(170_141_183_460_469_231_731_687_303_715_884_105_727 : int)