@rhinestone/module-sdk
v0.1.28
Published
A TypeScript library for using Smart Account Modules in Applications
Downloads
2,752
Readme
Module SDK
A TypeScript library for using smart account modules in applications
The Module SDK allows you to:
- Easily install and uninstall modules for any ERC-7579 account
- Interact with and use modules using a simple and consistent API
- Can be used alongside existing account SDKs such as permissionless.js, Biconomy, Zerodev and many more
- Use core modules, such as:
- Auto Savings: Automatically allocate a set percentage of any incoming token to a target vault
- ColdStorage Hook: Restrict all transactions with a timelock and only allow funds to be sent to a single address
- Deadman Switch: Recover an account after a specified inactive period
- Hook Multiplexer: Combine multiple hooks into one with fine-grained control over when they are called
- Multi Factor: Use multiple validators in combination as a multi-factor authentication system
- Ownable Executor: Allow an account to control a subaccount and pay for its transaction fees
- Ownable Validator: Authenticate on your account with multiple ECDSA keys
- Registry Hook: Query the Module Registry before installing and using modules
- Scheduled Orders: Execute swaps on a specified schedule
- Scheduled Transfers: Transfer funds on a specified schedule
- Social Recovery: Recover your account using a set of guardians
In-depth documentation is available at docs.rhinestone.wtf.
Using the ModuleSDK
Installation
Install viem as a peer dependency and then install the Module SDK:
npm install viem @rhinestone/module-sdk
pnpm install viem @rhinestone/module-sdk
yarn add viem @rhinestone/module-sdk
bun install viem @rhinestone/module-sdk
Quick Start
// Import the required functions
import {
installModule,
getModule,
getAccount,
getClient,
getMultiFactorValidator,
} from '@rhinestone/module-sdk'
// Create a client for the current network
const client = getClient({
rpcUrl: 'https://rpc.ankr.com/eth ',
})
// Create the module object if you are using a custom module
const moduleToInstall = getModule({
module: moduleAddress,
data: initData,
type: moduleType,
})
// Or use one of the existing modules
moduleToInstall = getMultiFactorValidator({
threshold: 2,
validators: [
{
packedValidatorAndId: '0x123...',
data: '0x123...',
},
{
packedValidatorAndId: '0x456...',
data: '0x123...',
},
],
})
// Create the account object
const account = getAccount({
address: '0x123...',
type: 'erc7579-implementation',
})
// Get the executions required to install the module
const executions = await installModule({
client,
account,
moduleToInstall,
})
// Install the module on your account, using your existing account SDK
// note: this is an example, you should use your own account SDK
accountSDK.execute(executions)
Using this repo
To install dependencies, run:
pnpm install
To build the sdk, run:
pnpm build
To run tests, run:
pnpm test
Contributing
For feature or change requests, feel free to open a PR, start a discussion or get in touch with us.