Auto SDK
What is the Auto SDK?
The Auto SDK is a powerful toolkit of JavaScript/TypeScript packages for developers to seamlessly integrate with the Autonomys Network. It provides simple APIs for interacting with the consensus layer, utilizing data storage, managing decentralized identities, and (soon) handling AI3 payments, in addition to general-purpose functions essential for building decentralized applications (dApps)—all in JavaScript and TypeScript—abstracting away the complexities of blockchain and smart contracts.
Key features:
- Modular Architecture: Use only the packages you need.
- Easy to Use: Simplifies blockchain operations with high-level functions.
- Flexible: Suitable for both beginners and experienced blockchain developers.
- Open-source: Built by and for the community.
Why the Auto SDK?
- Simplify Development: Focus on your application’s logic rather than blockchain intricacies.
- Accelerate Time-to-Market: Reduce development time with ready-to-use functions.
- Ensure Compatibility: Stay up-to-date with the latest Autonomys blockchain protocols.
- Enhance Security: Utilize well-tested code for critical operations like identity management.
Packages
The Auto SDK monorepo contains multiple packages, each serving a specific purpose. All packages are published to npm
under the @autonomys
scope:
@autonomys/auto-utils
: Core utility functions for interacting with the Autonomys Network.@autonomys/auto-consensus
: Functions for interacting with the consensus layer.@autonomys/auto-drive
: Tools for preparing, uploading and managing data for on-chain storage.@autonomys/auto-id
: Functions for issuing, renewing, verifying and revoking Autonomys identities (Auto IDs).
Quick Start Guide: Install and Code Example
A short video guide on installing the Auto SDK, along with a simple coding example demonstrating how to retrieve an account balance.
Step-by-step guide
Requirements
Node.js
(version 14 or higher)yarn
ornpm
Installation
Install the packages you need via npm
or yarn
. For example, to install @autonomys/auto-utils
and @autonomys/auto-consensus
:
Using npm
npm install @autonomys/auto-utils @autonomys/auto-consensus
Using yarn
yarn add @autonomys/auto-utils @autonomys/auto-consensus
Cloning the repository and building locally (optional)
If you want to run the SDK packages locally or contribute to the SDK, clone the repository and build the packages from source. Setup instructions:
1. Clone the repository
Open your terminal and run:
git clone https://github.com/autonomys/auto-sdk.git
2. Navigate to the project directory
cd auto-sdk
3. Install dependencies
yarn install
4. Compile all packages
yarn run build
5. Run tests on all packages
yarn run test
Localhost testing (optional)
Test the SDK packages against a local Autonomys node:
1. Verify OS and architecture settings
Edit the scripts/download.sh
file and ensure that lines 3-7 match your current operating system and architecture:
# Change the following variables as needed
# OS to download
OS="macos" # Options: macos | ubuntu | windows
# Architecture to download
ARCHITECTURE="aarch64" # Options: aarch64 | x86_64-skylake | x86_64-v2
2. Run the development script
Execute the following command to start the local node and farmer:
node scripts/run-dev.js
This script will:
- Download the latest version of the node and farmer compatible with your OS and architecture (
scripts/download.sh
). - Start the node and create/insert the keystore (
scripts/run-node.sh
). - Start the farmer (
scripts/run-farmer.sh
). - Register the node as an operator, wait for synchronization, and then terminate the node and farmer (handled within
scripts/run-dev.js
). - Restart the node as an operator (
scripts/run-operator.sh
). - Restart the farmer (
scripts/run-farmer.sh
).
3. Run tests on the local node
bash scripts/localhost-run-test.sh
The tests will automatically detect and execute on the local node and farmer.
Next steps
With the Auto SDK set up locally, you’re ready to start building and testing your blockchain applications. Explore the following pages for code examples and a functions overview.