Expand description

The SDK for integrating Certified Asset Provenance (CAP) into an Internet Computer canister.

⚠️ Currently the SDK is in version 1.0.0-alpha1 ⚠️

It does not support the full Cap specification, which may cause panics if your canister is not updated when Cap is fully released.

All methods which may suffer from issues are documented.

Additional Developer Resources

There are developer resources such as diagrams, additional documentation, and examples in the cap-sdk respository.

⚠️ Updating your canister ⚠️

⚠️ There is a specific flow you need to follow when upgrading your canister that depends on Cap to ensure no Cap configuration is lost accidentally.

TODO, write example

Structs

Contains data about the cap environment.

Allows creating details for an event.

The response given from a get_transactions call.

A Cap event with typed details.

A typed indefinite event.

Enums

An error returned during a transaction query failure.

An error returned when there was an error getting transactions.

An error returned during a transaction insertion failure.

Traits

Convinience trait for accepting multiple types for a transaction page argument.

Allows a type to be used as a source for an IndefiniteEvent.

Allows a type to be decoded from an Event or IndefiniteEvent.

Functions

Combines all the backup logic required for Cap in a safe way. It’s recommended to use this method instead of the old CapEnv::to_archive.

Force a flush of pending transactions to Cap.

Gets the transaction with the given id.

Gets a transaction for the given page.

Gets the transaction with the given id.

Handshakes with Cap. This either grabs important metadata or creates the root bucket for this contract and gives it creation_cycles cycles.

Inserts a transaction into the contract’s history.

Insert many transactions using one write to Cap.

Like insert_sync, but allows you to insert more than one transaction at a time.

Insert a transaction into Cap without needing an await, this method guarantees finality of the transactions and can handle insertion errors that might happen on the root bucket. (e.g if the root bucket has gone out of cycles)

Return the array of pending transactions. Can be used in a pre-upgrade hook.

Restore the transactions, it keeps the previous pending transactions as well.