@aut-labs/sdk
v0.0.224-dev
Published
The TS/JS SDK package aims to make it easy for frontends/backends to integrate with Aut Smart Contracts
Downloads
836
Readme
AutSDK
AutSDK is a software development kit that provides a programming interface to interact with the Āut ecosystem. It allows developers to interact with AutID, DAOExpanderRegistry, HubRegistry, DAOTypes, PluginRegistry, ModuleRegistry, and many other contract iterfaces.
To learn more about Āut Product Suite, Protocols & Contracts, see Āut Docs
Table of Contents
- Installation
- Getting Started
- API Reference
- Biconomy (deprected)
Installation
To install the AutSDK package, you can use npm or yarn:
npm install @aut-labs/sdk
or
yarn add @aut-labs/sdk
Getting Started
To get started with AutSDK, you need to instantiate the SDK and initialize it with the necessary configurations.
Usage Example
import AutSDK, {
AutSDKConfig,
AutID,
DAOExpanderRegistry,
HubRegistry,
DAOTypes,
PluginRegistry,
ModuleRegistry,
IPFSClient,
} from "@aut-labs/sdk";
const autSDKConfig: AutSDKConfig = {
nftStorageApiKey: "YOUR_NFT_STORAGE_API_KEY",
};
const autIDAddress = "AUTID_ADDRESS";
const daoExpanderRegistryAddress = "DAO_EXPANDER_REGISTRY_ADDRESS";
const hubRegistryAddress = "HUB_REGISTRY_ADDRESS";
const daoTypesAddress = "DAOTYPES_ADDRESS";
const daoExpanderAddress = "DAO_EXPANDER_ADDRESS";
const pluginRegistryAddress = "PLUGIN_REGISTRY_ADDRESS";
const moduleRegistryAddress = "MODULE_REGISTRY_ADDRESS";
const sdk = new AutSDK(autSDKConfig);
const provider = new providers.Web3Provider(transport, network);
const readOnlyProvider = new providers.JsonRpcProvider(
"json-rpc-url",
network
);
const signer = provider.getSigner();
const readOnlySigner = readOnlyProvider.getSigner();
sdk.init({
signer,
readOnlySigner,
}, {
autIDAddress,
daoExpanderRegistryAddress,
hubRegistryAddress,
daoTypesAddress,
daoExpanderAddress,
pluginRegistryAddress,
moduleRegistryAddress,
});
After instantiating and initializing the SDK, you can use the different services provided by the SDK, including AutID, DAOExpanderRegistry, HubRegistry, DAOTypes, PluginRegistry, ModuleRegistry.
To learn more about Product Suite, Protocols & Contracts, see Āut Docs
API Reference
AutID
getAutID
Returns the AutID for the given query parameters.
const sdk = AutSDK.getInstance();
const query: AutIDQuery = {
username: string,
holderAddress?: string,
tokenId?: number,
};
const autID: HolderData = await sdk.autID.getAutID(query);
mint
Mints a new AutID.
const sdk = AutSDK.getInstance();
const username: string = "john";
const role: number = 1;
const commitment: number = 100;
const daoExpanderAddr: string = "0x12345";
const network: string = "mumbai";
const avatarBase64: string = "ipfs-metadata-url";
const response: SDKContractGenericResponse<string> = await sdk.autID.mint(
username,
role,
commitment,
daoExpanderAddr,
network,
avatarBase64
);
DAOExpanderRegistry
deployDAOExpander
Deploys a new DAOExpander.
const sdk = AutSDK.getInstance();
const newDAO: SDKContractGenericResponse<string> = await sdk.daoExpanderRegistry.deployDAOExpander();
HubRegistry
deployHub
Deploys a new Hub.
const sdk = AutSDK.getInstance();
const newHub: SDKContractGenericResponse<string> = await sdk.hubRegistry.deployHub();
PluginRegistry
addPluginToDAO
Adds a plugin to a DAO.
const sdk = AutSDK.getInstance();
const request = {
pluginDefinitionId: PluginDefinitionType,
daoAddress: string,
questOnboardingPluginAddress: string,
offchainVerifier: string,
};
const response: SDKContractGenericResponse<boolean> = await sdk.pluginRegistry.addPluginToDAO(request);
getAllPluginDefinitions
Returns all the plugin definitions.
const sdk = AutSDK.getInstance();
const response: SDKContractGenericResponse<PluginDefinition[]> = await sdk.pluginRegistry.getAllPluginDefinitions();
getAllPluginDefinitionsByDAO
Returns all the plugin definitions associated with a DAO.
const sdk = AutSDK.getInstance();
const daoAddress: string = "0x12345";
const response: SDKContractGenericResponse<PluginDefinition[]> = await sdk.pluginRegistry.getAllPluginDefinitionsByDAO(daoAddress);
getPluginDefinitionByDAO
Returns the plugin definition for a specific DAO.
const sdk = AutSDK.getInstance();
const daoAddress: string = "0x12345";
const response: SDKContractGenericResponse<PluginDefinition> = await sdk.pluginRegistry.getPluginDefinitionByDAO(daoAddress);
getPluginDefinitionByType
Returns the plugin definition for a specific plugin type and DAO.
const sdk = AutSDK.getInstance();
const daoAddress: string = "0x12345";
const type: PluginDefinitionType = PluginDefinitionType.OnboardingJoinDiscordTaskPlugin;
const response: SDKContractGenericResponse<string> = await sdk.pluginRegistry.getPluginDefinitionByType(daoAddress, type);
DAOExpander
addAdmin
Adds an admin to the DAOExpander.
const sdk = AutSDK.getInstance();
const address: string = "0x12345";
const response: SDKContractGenericResponse<boolean> = await sdk.daoExpander.addAdmin(address);
removeAdmin
Removes an admin from the DAOExpander.
const sdk = AutSDK.getInstance();
const address: string = "0x12345";
const response: SDKContractGenericResponse<boolean> = await sdk.daoExpander.removeAdmin(address);
activateModule
Activates a module in the DAOExpander.
const sdk = AutSDK.getInstance();
const moduleId: number = 1;
const response: SDKContractGenericResponse<boolean> = await sdk.daoExpander.activateModule(moduleId);
isModuleActivated
Checks if a module is activated in the DAOExpander.
const sdk = AutSDK.getInstance();
const moduleId: number = 1;
const response: SDKContractGenericResponse<boolean> = await sdk.daoExpander.isModuleActivated(moduleId);
Hub
activateModule
Activates a module in the Hub.
const sdk = AutSDK.getInstance();
const moduleId: number = 1;
const response: SDKContractGenericResponse<boolean> = await sdk.hub.activateModule(moduleId);
isModuleActivated
Checks if a module is activated in the Hub.
const sdk = AutSDK.getInstance();
const moduleId: number = 1;
const response: SDKContractGenericResponse<boolean> = await sdk.hub.isModuleActivated(moduleId);
OnboardingByQuest
activateQuest
Activates a quest.
const sdk = AutSDK.getInstance();
const questId: number = 1;
const response: SDKContractGenericResponse<boolean> = await sdk.questOnboarding.activateQuest(questId);
applyForAQuest
Applies for a quest.
const sdk = AutSDK.getInstance();
const questId: number = 1;
const response: SDKContractGenericResponse<boolean> = await sdk.questOnboarding.applyForAQuest(questId);
withdrawFromAQuest
Withdraws from a quest.
const sdk = AutSDK.getInstance();
const questId: number = 1;
const response: SDKContractGenericResponse<boolean> = await sdk.questOnboarding.withdrawFromAQuest(questId);
getAllQuests
Returns all the quests.
const sdk = AutSDK.getInstance();
const response: SDKContractGenericResponse<Quest[]> = await sdk.questOnboarding.getAllQuests();
getQuestById
Returns a quest by its ID.
const sdk = AutSDK.getInstance();
const questId: number = 1;
const response: SDKContractGenericResponse<Quest> = await sdk.questOnboarding.getQuestById(questId);
createQuest
Creates a new quest.
const sdk = AutSDK.getInstance();
const quest: Quest = {
title: "New Quest",
description: "Quest description",
reward: 100,
tasks: [],
};
const response: SDKContractGenericResponse<Quest> = await sdk.questOnboarding.createQuest(quest);
updateQuest
Updates an existing quest.
const sdk = AutSDK.getInstance();
const quest: Quest = {
id: 1,
title: "New Quest",
description: "Quest description",
reward: 100,
tasks: [],
};
const response: SDKContractGenericResponse<Quest> = await sdk.questOnboarding.updateQuest(quest);
getTaskById
Returns a task by its ID.
const sdk = AutSDK.getInstance();
const taskAddress: string = "0x12345";
const taskId: number = 1;
const response: SDKContractGenericResponse<Task> = await sdk.questOnboarding.getTaskById(taskAddress, taskId);
getAllTasksAndSubmissionsByQuest
Returns all the tasks and submissions for a quest.
const sdk = AutSDK.getInstance();
const questId: number = 1;
const response: SDKContractGenericResponse<{
tasks: Task[];
submissions: Submission[];
}> = await sdk.questOnboarding.getAllTasksAndSubmissionsByQuest(questId);
getAllTasksByQuest
Returns all the tasks for a quest.
const sdk = AutSDK.getInstance();
const questId: number = 1;
const userAddress: string = "0x12345";
const response: SDKContractGenericResponse<Task[]> = await sdk.questOnboarding.getAllTasksByQuest(questId, userAddress);
getAllTasksForAllQuests
Returns all the tasks for all quests.
const sdk = AutSDK.getInstance();
const filterQuests: Quest[] = [];
const response: SDKContractGenericResponse<Task[]> = await sdk.questOnboarding.getAllTasksForAllQuests(filterQuests);
createTask
Creates a new task for a quest.
const sdk = AutSDK.getInstance();
const task: Task = {
title: "New Task",
description: "Task description",
reward: 10,
pluginData: [],
isRequired: true,
};
const questId: number = 1;
const pluginTokenId: number = 1;
const response: SDKContractGenericResponse<Task> = await sdk.questOnboarding.createTask(
task,
questId,
pluginTokenId
);
removeTasks
Removes tasks from a quest.
const sdk = AutSDK.getInstance();
const tasks: Task[] = [];
const questId: number = 1;
const pluginId: number = 1;
const response: SDKContractGenericResponse<Task[]> = await sdk.questOnboarding.removeTasks(
tasks,
questId,
pluginId
);
submitTask
Submits a task with its plugin data.
const sdk = AutSDK.getInstance();
const task: Task = {
title: "Task Title",
description: "Task Description",
reward: 10,
pluginData: [],
isRequired: true,
};
const taskPluginAddress: string = "0x12345";
const pluginDefinitionId: PluginDefinitionType = PluginDefinitionType.OnboardingJoinDiscordTaskPlugin;
const response: SDKContractGenericResponse<Task> = await sdk.questOnboarding.submitTask(
task,
taskPluginAddress,
pluginDefinitionId
);
finalizeFor
Finalizes a submission for a task.
const sdk = AutSDK.getInstance();
const submission: Task = {
title: "Submission Title",
description: "Submission Description",
reward: 10,
pluginData: [],
isRequired: true,
};
const taskPluginAddress: string = "0x12345";
const pluginDefinitionId: PluginDefinitionType = PluginDefinitionType.OnboardingJoinDiscordTaskPlugin;
const response: SDKContractGenericResponse<Task | void> = await sdk.questOnboarding.finalizeFor(
submission,
taskPluginAddress,
pluginDefinitionId
);
Biconomy (deprecated)
AutSDK also supports biconomy for gasless transactions.
import AutSDK, {
AutSDKConfig,
AutID,
DAOExpanderRegistry,
HubRegistry,
DAOTypes,
PluginRegistry,
ModuleRegistry,
IPFSClient,
} from "@aut-labs/sdk";
const autSDKConfig: AutSDKConfig = {
nftStorageApiKey: "YOUR_NFT_STORAGE_API_KEY",
};
const autIDAddress = "AUTID_ADDRESS";
const daoExpanderRegistryAddress = "DAO_EXPANDER_REGISTRY_ADDRESS";
const hubRegistryAddress = "HUB_REGISTRY_ADDRESS";
const daoTypesAddress = "DAOTYPES_ADDRESS";
const daoExpanderAddress = "DAO_EXPANDER_ADDRESS";
const pluginRegistryAddress = "PLUGIN_REGISTRY_ADDRESS";
const moduleRegistryAddress = "MODULE_REGISTRY_ADDRESS";
const sdk = new AutSDK(autSDKConfig);
const provider = new providers.Web3Provider(transport, network);
const readOnlyProvider = new providers.JsonRpcProvider(
"json-rpc-url",
network
);
const signer = provider.getSigner();
const readOnlySigner = readOnlyProvider.getSigner();
const biconomy = new SDKBiconomyWrapper({
enableDebugMode: true,
apiKey: "biconomy-api-key",
contractAddresses: ["address1, address2"]
});
sdk.init({
signer,
readOnlySigner,
},
{
autIDAddress,
daoExpanderRegistryAddress,
hubRegistryAddress,
daoTypesAddress,
daoExpanderAddress,
pluginRegistryAddress,
moduleRegistryAddress,
},
biconomy
);