CertifiedData
The Internet Computer allows canister smart contracts to store a small amount of data during update method processing so that during query call processing, the canister can obtain a certificate about that data.
This module provides a low-level interface to this API, aimed at advanced users and library implementors. See the Internet Computer interface specification and corresponding documentation for how to use this to make query calls to your canister tamperproof.
Function set
func set(data : Blob) : ()
Set the certified data.
Must be called from an update method, else traps. Must be passed a blob of at most 32 bytes, else traps.
Example:
import CertifiedData "mo:base/CertifiedData";
import Blob "mo:base/Blob";
// Must be in an update call
let array : [Nat8] = [1, 2, 3];
let blob = Blob.fromArray(array);
CertifiedData.set(blob);
Function getCertificate
func getCertificate() : ?Blob
Gets a certificate.
Returns null
if no certificate is available, e.g. when processing an
update call or inter-canister call. This returns a non-null
value only
when processing a query call.
Example:
import CertifiedData "mo:base/CertifiedData";
// Must be in a query call
CertifiedData.getCertificate();