nat8
The CandidType
object nat8
corresponds to the Candid type nat8, is inferred to be a TypeScript number
, and will be decoded into a JavaScript Number at runtime.
TypeScript or JavaScript:
import { Canister, nat8, query } from 'azle/experimental';
export default Canister({
getNat8: query([], nat8, () => {
return 255;
}),
printNat8: query([nat8], nat8, (nat8) => {
console.log(typeof nat8);
return nat8;
})
});
Candid:
service : () -> {
getNat8 : () -> (nat8) query;
printNat8 : (nat8) -> (nat8) query;
}
dfx:
dfx canister call candid_canister printNat8 '(255 : nat8)'
(255 : nat8)