Abstract-SDK
This crate provides a set of modular APIs for developers to use in their CosmWasm smart-contracts.
Getting started
To get started with the Abstract SDK you first need to understand the basic features that we provide and how you can use those features to create composable smart-contract APIs.
Features
Abstract features are traits that can be implemented on a struct. Depending on the use-case that struct can represent a smart-contract or it can be a simple struct that just implements a single feature. Each feature unlocks a function on the object which allows you to retrieve some information. By composing these features it is possible to write advanced APIs that are automatically implemented on objects that support its required features.
APIs
The Abstract APIs are objects that can only be retrieved if a contract or feature-object implements the required features/api traits. If the trait constraints for the Adapter is met it is automatically implemented on the object and allows you to retrieve the Adapter object.
Example
The Bank
Adapter allows developers to transfer assets from and to the Account through their module object. We now want to use this Adapter to create a Splitter
API that splits the transfer of some amount of funds between a set of receivers.
use ;
use AnsAsset;
use ;
// Trait to retrieve the Splitter object
// Depends on the ability to transfer funds
// Implement for every object that can transfer funds
The API can then be used by any contract that implements its required traits, in this case the TransferInterface
.
# use ;
# use ;
# use AnsHost;
# use ;
#
#
#
#
use TransferInterface;
Abstract Base
To use an API either construct a feature object
or use an Abstract base contract as the starting-point of your application.
The available base contracts are:
Kind | Migratable | Installable |
---|---|---|
App | ✅ | ✅ |
Adapter | ❌ | ✅ |
Each base supports a set of endpoints that can accept custom handlers. These handlers can be added to the base using a static builder pattern. All the available endpoints are discussed here.
Usage
Add abstract-sdk
to your Cargo.toml
by running: