Plugins
GOAT plugins are extensions that enable your agent to interact with various blockchain protocols.
Instead of having a generic function to execute arbitrary transactions, plugins provide specific tools for common protocols to reduce the risk of hallucinations.
Key Benefits
- Modularity: Easily add or remove functionalities.
- Reusability: Leverage community-built plugins.
- Customization: Design plugins to meet the unique needs.
Chain Compatibility
Plugins can be EVM/Solana specific or chain-agnostic. If a plugin is chain-specific it will fail to compile when being used with a wallet of a different chain.
See all available plugins here.
Plugin Architecture
Plugins extend the PluginBase
class defined in the core package:
Plugins get passed a WalletClient that can be chain-specific or chain-agnostic.
The WalletClient abstracts the underlying wallet implementation and provides a common interface to:
- Get wallet information
- Sign messages
- Send transactions
This allows plugins to:
- Work with any wallet implementation that implements the WalletClient interface, from key pairs to smart wallets.
- Focus on the specific communication with the protocol without worrying about handling transactions, message signing, etc. for each wallet implementation.
Creating your own GOAT plugin
Building a custom GOAT plugin is straightforward. Below, we’ll walk you through creating a plugin that signs messages with “BAAAA” 🐐 prefixed to them.
Define the plugin interface
Start by defining your plugin extending the PluginBase class.
Since we are just signing messages, we will create a chain-agnostic plugin that works both on EVM and Solana chains.
Add tools to the plugin
There are two ways to add tools to the plugin:
- Using the
getTools
andcreateTool
functions - Using the
@Tool
decorator on our own class
Option 1: Using the getTools
and createTool
functions
We will start by implementing the getTools
method in our plugin class.
Inside the method, we will return an array of tools created using the createTool
function.
Option 2: Using the @Tool
decorator
The @Tool
decorator is a way to create tools in a more declarative way.
You can create a class and decorate its methods with the @Tool
decorator to create tools.
The tool methods will receive the wallet client as the first argument and the parameters as the second argument.
Once we have our class we now need to import it in our plugin class.
Add the plugin to the agent
Next steps
- Share your plugin with others!
- Open a PR to add it to the plugins registry in the GOAT SDK.