@stackso/soul-spec-ts
v2.1.2
Published
A specification of actions on the soul protocol
Downloads
519
Keywords
Readme
Soul Spec
soul-spec-ts is a TypeScript-based library that provides specifications for actions on the Soul Protocol (soul.xyz). It provides two essential functions:
getRequiredFieldsForAction(action: ActionType)
- A helper function that returns a list of required fields to generate a message.generateMessage(action: ActionType, data: ActionData)
- The main function to generate the message for the user to sign. It throws an error if the provided data does not meet the requirement.
Getting Started
To get started, you need to install the package using npm:
npm install soul-spec-ts
Then, you can import and use the functions in your TypeScript or JavaScript project:
import { ActionType, getRequiredFieldsForAction, generateMessage } from 'soul-spec-ts';
// optional: check required fields for an action
const action = ActionType.CREATE_SOUL;
const requiredFields = getRequiredFieldsForAction(action);
console.log(requiredFields);
// generate message to sign
const message = generateMessage({
action,
data: {...}, // replace this with actual data
});
console.log(message);
Remember to replace data with your actual data matching the required fields for the chosen action.
Please refer to this file for supported actions: src/actions/ActionType.ts
License
This project is licensed under the terms of the MIT license.