SDK Reference
The Actions SDK provides a set of tools and utilities to create, validate, and deploy Actions. This section provides an overview of the key components of the SDK.
1.5.1 Types and Interfaces
The SDK exports various types and interfaces from the actions-spec
package. These are crucial for defining the structure of Actions and ensuring type safety in TypeScript projects. Some of the key types include:
Action
: The main interface for defining an ActionLinkedAction
: Represents actions that can be linked to the main ActionTxAction
,TxMultiAction
,TransferAction
: Specific types of LinkedActionsActionInput
: Defines user inputs for ActionsTypedActionParameter
: Represents different types of action parametersActionError
: Defines the structure for error responsesActionSuccessResponse
: Defines the structure for success responses
To use these types in your project:
1.5.2 Constants
The SDK provides several useful constants:
chainId
: An object mapping network names to their chain IDs.globalInputs
: Constant values for global inputs.erc20FunctionSignatures
: Mapping of ERC20 function names to their signatures.erc721FunctionSignatures
: Mapping of ERC721 function names to their signatures.
These constants can be useful for creating standardized Actions that interact with common contract types or need to reference specific blockchain networks.
1.5.3 Functions
The SDK provides two main functions for working with Actions:
validateAction(action: Action): { valid: boolean; errors: string[] | null }
This function validates an Action object against the Actions specification. It uses JSON Schema validation with the Ajv library to ensure the Action object conforms to the defined schema.
Usage:
deployToIpfs(action: Action, pinataCredentials: PinataCredentials): Promise<string | Error>
This function deploys an Action to IPFS using Pinata as the pinning service. It returns a Promise that resolves to the IPFS hash of the deployed Action.
Usage:
These functions provide the core functionality needed to work with Actions, from creation and validation to deployment on IPFS.
Last updated