-
Notifications
You must be signed in to change notification settings - Fork 163
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for paymasters in zk stack networks
- Loading branch information
1 parent
f32d00a
commit d4fad06
Showing
8 changed files
with
209 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
OPENAI_API_KEY= | ||
WALLET_PRIVATE_KEY= | ||
PAYMASTER_ADDRESS= | ||
RPC_PROVIDER_URL= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Vercel AI Abstract Example | ||
|
||
## Setup | ||
|
||
Copy the `.env.template` and populate with your values. | ||
|
||
``` | ||
cp .env.template .env | ||
``` | ||
|
||
## Usage | ||
|
||
``` | ||
npx ts-node index.ts | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { openai } from "@ai-sdk/openai"; | ||
import { generateText } from "ai"; | ||
|
||
import { http } from "viem"; | ||
import { createWalletClient } from "viem"; | ||
import { privateKeyToAccount } from "viem/accounts"; | ||
import { abstractTestnet } from "viem/chains"; | ||
|
||
import { getOnChainTools } from "@goat-sdk/adapter-vercel-ai"; | ||
import { PEPE, USDC, erc20 } from "@goat-sdk/plugin-erc20"; | ||
|
||
import { sendETH } from "@goat-sdk/core"; | ||
import { viem } from "@goat-sdk/wallet-viem"; | ||
|
||
require("dotenv").config(); | ||
|
||
const account = privateKeyToAccount( | ||
process.env.WALLET_PRIVATE_KEY as `0x${string}` | ||
); | ||
|
||
const walletClient = createWalletClient({ | ||
account: account, | ||
transport: http(process.env.RPC_PROVIDER_URL), | ||
chain: abstractTestnet, | ||
}); | ||
|
||
(async () => { | ||
const tools = await getOnChainTools({ | ||
wallet: viem(walletClient, { | ||
defaultPaymaster: process.env.PAYMASTER_ADDRESS as `0x${string}`, | ||
}), | ||
plugins: [sendETH(), erc20({ tokens: [USDC, PEPE] })], | ||
}); | ||
|
||
const result = await generateText({ | ||
model: openai("gpt-4o-mini"), | ||
tools: tools, | ||
maxSteps: 5, | ||
prompt: "Send 1 USDC to 0x016c0803FFC6880a9a871ba104709cDBf341A90a", | ||
}); | ||
|
||
console.log(result.text); | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"name": "goat-examples-vercel-ai-abstract", | ||
"version": "0.1.0", | ||
"description": "", | ||
"private": true, | ||
"scripts": { | ||
"test": "vitest run --passWithNoTests" | ||
}, | ||
"author": "", | ||
"license": "MIT", | ||
"dependencies": { | ||
"@ai-sdk/openai": "^1.0.4", | ||
"@goat-sdk/adapter-vercel-ai": "workspace:*", | ||
"@goat-sdk/core": "workspace:*", | ||
"@goat-sdk/plugin-erc20": "workspace:*", | ||
"@goat-sdk/wallet-viem": "workspace:*", | ||
"ai": "^4.0.3", | ||
"dotenv": "^16.4.5", | ||
"viem": "2.21.49" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"extends": "../../../tsconfig.base.json", | ||
"compilerOptions": { | ||
"outDir": "dist" | ||
}, | ||
"include": ["index.ts"], | ||
"exclude": ["node_modules", "dist"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.