Token Plugin
The Token Plugin provides functionality for interacting with ERC20 tokens on supported chains. It allows you to transfer tokens and check balances directly from your Tarobase policies.
Overview
The Token Plugin is a built-in plugin that enables token-related operations within Tarobase policies. It currently supports basic token transfers and will soon support balance checks and allowance management to be usable in rules, triggers, and front-end code via the Tarobase SDK.
Available Functions
transferWholeTokens
Transfers whole token amounts, automatically handling decimal conversion based on the token's decimals.
Parameters:
- tokenAddress: The address of the ERC20 token contract
- sender: The address sending the tokens
- recipient: The address receiving the tokens
- amount: The amount of whole tokens to transfer (e.g. 1 for 1 full token)
transfer
Transfers token amounts specified in the token's smallest unit (e.g. wei for tokens with 18 decimals).
Parameters:
- tokenAddress: The address of the ERC20 token contract
- sender: The address sending the tokens
- recipient: The address receiving the tokens
- amount: The amount in smallest units to transfer
Supported Networks
- base_testnet
Coming Soon
The following features are planned for future releases for usage in both policy rules and from the Tarobase SDK:
- getBalance: Check token balances
- getAllowance: Check spending allowances
- getDecimals: Retrieve how many decimals a token has
Important Notes
- The sender must approve the Tarobase contract to spend tokens before transfers - The plugin automatically detects if the user needs more allowance, and will request that exact amount of allowance prior to the following request.
- Token amounts in transferWholeTokens are automatically converted based on the token's decimals
- All transfers emit an additional TransferSuccessful event on-chain
Future Development and Open Source
The Token Plugin is part of Tarobase's plugin system which will be made open source in the near future. This will allow developers to extend and enhance the plugin's functionality, create custom token-related features, and contribute improvements back to the community. Stay tuned for updates on when the plugin system becomes available for open source contributions.