The Abstract App Module Template is a starting point for developing composable smart-contracts, or "Apps" on the Abstract platform. An App is instantiated for each Account individually and is migratable. Apps are allowed to perform actions on Abstract Accounts and can integrate with other Apps and Adapters installed on the Account. To learn more about Abstract Accounts, please see the abstract accounts documentation. To read more about apps, please see the app module documentation.
Learn more about the requirements for developing Abstract apps in the getting started documentation.
To get started, clone this repository and run the following command:
chmod +x ./template-setup.sh
./template-setup.sh
The setup will suggest you to install a few tools that are used in the template. You can skip this step if you already have them installed or if you're not planning on using them.
This repository comes with a justfile
, which is a handy task runner that helps with building, testing, and publishing your Abstract app module.
To fully make use of the justfile
, you need to install a few tools first. You can do this by simply running just install-tools
. See tools used the template for more information.
Here are some of the tasks available in the justfile
:
install-tools
: Install all the tools needed to run the tasks.build
: Build everything with all features.test
: Run all tests.watch-test
: Watch the codebase and run tests on changes.fmt
: Format the codebase (including .toml).lint
: Lint-check the codebase.lintfix
: Fix linting errors automatically.watch
: Watch the codebase and runcargo check
on changes.check
: Check the codebase for issues.publish {{chain-id}}
: Publish the App to a network.wasm
: Optimize the contract.schema
: Generate the json schemas for the contractts-codegen
: Generate the typescript client code for the contractts-publish
: Publish the typescript client code to npmpublish-schemas
: Publish the schemas by creating a PR on the Abstract schemas repository.
You can see the full list of tasks available by running just --list
.
You can test the module using the different provided methods.
- Integration testing: We provide an integration testing setup here. You should use this to set up your environment and test the different execution and query entry-points of your module. Once you are satisfied with the results you can try publishing it to a real chain.
- Local Daemon: Once you have confirmed that your module works as expected you can spin up a local node and deploy Abstract + your app onto the chain. You can do this by running the test-local example, which uses a locally running juno daemon to deploy to. You can setup local juno using
just juno-local
command. At this point you can also test your front-end with the contracts.
Once testing is done you can attempt an actual deployment on test and mainnet.
Before attempting to publish your app you need to add your mnemonic to the .env
file. Don't use a mnemonic that has mainnet funds for this.
You can now use just publish {{chain-id}}
to run the examples/publish.rs
script. The script will publish the app to the networks that you provided. Make sure you have enough funds in your wallet on the different networks you aim to publish on.
Before proceeding you need to install the required dependencies for the typescript client code generation.
cd packages/typescript
npm install
To generate the typescript client code for the contract you can run just ts-codegen
. This will generate the code in the typescript/src
directory. You can then import the generated code in your frontend application.
To publish the Typescript sdk, first change the name and version in the typescript/package.json
file. Then run just ts-publish
. This will publish the sdk to npm.
To publish your module schemas, we provide the publish-schemas
command, which creates a pull request on the Abstract schemas repository.
just publish-schemas <namespace> <name> <version>
namespace
: Your module's namespacename
: Your module's nameversion
: Your module's version. Note that if you only include the minor version (e.g.,0.1
), you don't have to reupload the schemas for every patch version.
The command will automatically clone the Abstract Schemas repository, create a new branch with the given namespace, name, and version, and copy the schemas and metadata from your module to the appropriate directory.
For this command to work properly, please make sure that your metadata.json
file is located at the root of your module's directory. This file is necessary for the Abstract Frontend to correctly interpret and display information about your module.
Example:
just publish-schemas my-namespace my-module 0.1
In the example above, my-namespace
is the namespace, my-module
is the module's name, and 0.1
is the minor version. If you create a patch for your module (e.g., 0.1.1
), you don't need to run publish-schemas
again unless the schemas have changed.
We welcome contributions to the Abstract App Module Template! To contribute, fork this repository and submit a pull request with your changes. If you have any questions or issues, please open an issue in the repository and we will be happy to assist you.