Setting up the environment

Before you get started with the Abstract SDK, you will need to set up your development environment. This guide will walk you through the process of doing just that.

Info

Experienced with CosmWasm? Skip to the Using The Template section.

Rust

To work with the SDK you will need a Rust toolchain installed on your machine. If you don’t have it installed, you can find installation instructions on the official Rust website.

WASM

Additionally, you will need the WASM compile target installed to build WASM binaries. You will need rustup, which you got when installing Rust on the previous step. To install it the WASM compile target, run:

$ rustup target add wasm32-unknown-unknown
> installing wasm32-unknown-unknown

Docker

Docker is used to create a containerized environment for facilitating reproducible builds. Specifically we’ll be using Cosmwasm Optimizer.

Git

You will also need git installed to clone our template repository. You can find instructions for installing git on your operative system here.

Using the Template

Now we’ll get you set up with the Abstract App template which contains:

  • A scaffold app module with:
    • A basic contract
    • cw-orchestrator interface and deployment script
    • Integration tests
  • A set of just commands that will help you in your development.

Go to our App Template on Github and click on the “Use this template” button to create a new repository based on the template. You can name the repository whatever you want, but we recommend using the name of your module.

Success

To quickly get started, run ./template_setup.sh and install the recommended tools.

Go ahead and read through the readme of the template repository to learn how it is structured. It contains instructions on how to set up your development environment, useful commands you can perform using just, how to test and deploy your app, and more.

Contract file structure

The template contains a scaffold contract that you can use as a starting point for your own contract. The contract is located in the src directory and is structured as follows:

  • contract.rs: Top-level file for your module. It contains the type definition of you module and the const builder that constructs your contract. It also contains a macro that exports your contract’s entry points. You can also specify the contract’s dependencies here.
  • error.rs: Error types that your contract can return.
  • msg.rs: Custom message types that your contract can receive. These messages also have cw-orchestrator macros attached to them which comes in useful when you are writing your integration tests.
  • state.rs: State types that your contract will use to store state to the blockchain.
  • interface.rs: Interface that your contract will use to interact with the cw-orchestrator library.
  • replies/: Reply handlers that your contract will use to handle replies.
  • handlers/: Message handlers that your contract will use to handle the different messages it can receive.

If there’s anything you don’t understand about the template please don’t hesitate to reach out to us on our Discord server.

Tools used in the template

The following Rust tools are used extensively in our template to improve your productivity.

  • Taplo: The CI shipped with the template will perform formatting checks. To ensure you pass the checks, you can install Taplo and use the just format command to format your code and toml files.
  • Nextest: A better cargo test runner.
  • Cargo Limit: Prioritizes errors over warnings in compile output as well as some other small improvements.
  • Cargo Watch: Allows you to automatically re-run compilation when files change. This is useful when you are working on the contracts and want to fix compiler errors one by one.

You can install them by running just install-tools. All the tools are built from the source by Cargo.