Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add goat plugin #736

Merged
merged 6 commits into from
Dec 1, 2024
Merged

feat: add goat plugin #736

merged 6 commits into from
Dec 1, 2024

Conversation

0xaguspunk
Copy link
Contributor

Relates to:

#735
#644

Risks

Low

Background

What does this PR do?

Goat is an open-source framework for connecting AI agents to any onchain app.

This PR demonstrates how to integrate Goat with Eliza, enabling AI agents to execute a wide range of onchain actions with minimal effort. Using Goat’s plugin system, developers can enable agents to:

  • Mint NFTs on Zora
  • Swap tokens on Uniswap
  • Place bets on Polymarket
    all with just a single line of code.

The framework supports multichain by either defining actions for a specific set of chains or dynamically selecting chains per action.

This concrete example simply enables transferring and checking the balance for USDC and ETH on the Base network.

What kind of change is this?

Features (non-breaking change which adds functionality)

Why are we doing this? Any context or related work?

Enable to easily add more onchain capabilities by leveraging Goat.

Documentation changes needed?

My changes do not require a change to the project documentation.

Testing

Where should a reviewer start?

  1. Go to plugin-goat

Detailed testing steps

  1. Make sure you have an EVM_PRIVATE_KEY, EVM_PUBLIC_KEY and EVM_PROVIDER_URL for Base set
  2. Add plugin-goat to the dependencies of the package.json from the agent dir
  3. Import it in agent/src/index.ts, exchange it for the evmPlugin
  4. Run the agent and prompt it with: What's the USDC balance of 0x18Bead774f927Af586F86F6d054C269416E163DD
  5. Should give you the balance of 0x18Bead774f927Af586F86F6d054C269416E163DD

To test actions on Base Sepolia simply:

  1. Go to plugin-goat/src/index.ts and change
chain: {
    type: "evm",
    id: base.id,
}, 

to

chain: {
    type: "evm",
    id: sepolia.id, // including the viem import
}, 
  1. Go to the plugin-goat/src/wallet.ts file and do the same
  2. Make sure EVM_PROVIDER_URL works for Sepolia
  3. Run the agent!

Discord username

aguspunk

@0xaguspunk 0xaguspunk changed the title add goat plugin feat: add goat plugin Dec 1, 2024
Copy link
Collaborator

@monilpat monilpat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM outside of addressing comments great work :)

runtime: IAgentRuntime,
context: string
): Promise<unknown> {
return generateObject({
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would recommend generateObjectV2 instead as it is much more deterministic

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Neat! 😄 Just moved to that!! Thanks for the rec 🙏


const walletClient = createWalletClient({
account: privateKeyToAccount(privateKey as `0x${string}`),
chain: base,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be hardcoded or can we configure it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It could be added as an .env variable but we would need a map from string to viem object which would still require you to change the code if you want to use a chain that is not contemplated in the map.

I centralized the definition inside provider.ts to make it easier to update 😄

Would that work?

@0xaguspunk
Copy link
Contributor Author

@monilpat I moved to generateObjectV2 and added a wallet provider. Let me know if this works 🙌

Thank you for the review!

@0xaguspunk 0xaguspunk requested a review from monilpat December 1, 2024 10:01
@lalalune lalalune mentioned this pull request Dec 1, 2024
@lalalune lalalune merged commit 8d3ed88 into elizaOS:main Dec 1, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants