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

fetches the address of lens post creator #190

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added .turbo/cookies/1.cookie
Empty file.
Empty file added .turbo/cookies/10.cookie
Empty file.
Empty file added .turbo/cookies/11.cookie
Empty file.
Empty file added .turbo/cookies/12.cookie
Empty file.
Empty file added .turbo/cookies/13.cookie
Empty file.
Empty file added .turbo/cookies/2.cookie
Empty file.
Empty file added .turbo/cookies/3.cookie
Empty file.
Empty file added .turbo/cookies/4.cookie
Empty file.
Empty file added .turbo/cookies/5.cookie
Empty file.
Empty file added .turbo/cookies/6.cookie
Empty file.
Empty file added .turbo/cookies/7.cookie
Empty file.
Empty file added .turbo/cookies/8.cookie
Empty file.
Empty file added .turbo/cookies/9.cookie
Empty file.
Empty file.
62 changes: 31 additions & 31 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
{
"private": true,
"name": "goat-repo",
"version": "0.1.0",
"scripts": {
"build": "pnpm turbo build",
"prepare": "husky"
},
"devDependencies": {
"husky": "^9.1.7"
},
"engines": {
"node": ">=20.12.2 <23",
"npm": "please-use-pnpm",
"pnpm": ">=9",
"yarn": "please-use-pnpm"
},
"homepage": "https://github.com/crossmint/goat",
"repository": {
"type": "git",
"url": "git+https://github.com/crossmint/goat.git"
},
"license": "MIT",
"bugs": {
"url": "https://github.com/crossmint/goat/issues"
},
"keywords": [
"ai",
"agents",
"web3"
],
"packageManager": "[email protected]"
"private": true,
"name": "goat-repo",
"version": "0.1.0",
"scripts": {
"build": "turbo run build",
"prepare": "husky"
},
"devDependencies": {
"husky": "^9.1.7"
},
"engines": {
"node": ">=20.12.2 <23",
"npm": "please-use-pnpm",
"pnpm": ">=9",
"yarn": "please-use-pnpm"
},
"homepage": "https://github.com/crossmint/goat",
"repository": {
"type": "git",
"url": "git+https://github.com/crossmint/goat.git"
},
"license": "MIT",
"bugs": {
"url": "https://github.com/crossmint/goat/issues"
},
"keywords": [
"ai",
"agents",
"web3"
],
"packageManager": "[email protected]"
}
1 change: 1 addition & 0 deletions typescript/examples/vercel-ai/abstract/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { abstractTestnet } from "viem/chains";

import { getOnChainTools } from "@goat-sdk/adapter-vercel-ai";
import { PEPE, USDC, erc20 } from "@goat-sdk/plugin-erc20";
import {} from "../../../packages/plugins/lens";

import { sendETH } from "@goat-sdk/wallet-evm";
import { viem } from "@goat-sdk/wallet-viem";
Expand Down
3 changes: 3 additions & 0 deletions typescript/examples/vercel-ai/lens/.env.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
WALLET_PRIVATE_KEY=
ALCHEMY_LENS_RPC_URL=
OPENAI_API_KEY=
102 changes: 102 additions & 0 deletions typescript/examples/vercel-ai/lens/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
# goat-examples-vercel-ai-uniswap

## 0.1.6

### Patch Changes

- Updated dependencies [50180d4]
- @goat-sdk/[email protected]
- @goat-sdk/[email protected]
- @goat-sdk/[email protected]
- @goat-sdk/[email protected]

## 0.1.5

### Patch Changes

- Updated dependencies [1906022]
- @goat-sdk/[email protected]

## 0.1.4

### Patch Changes

- Updated dependencies [778440b]
- @goat-sdk/[email protected]
- @goat-sdk/[email protected]
- @goat-sdk/[email protected]
- @goat-sdk/[email protected]

## 0.1.3

### Patch Changes

- Updated dependencies [279dfcd]
- @goat-sdk/[email protected]
- @goat-sdk/[email protected]
- @goat-sdk/[email protected]
- @goat-sdk/[email protected]

## 0.1.2

### Patch Changes

- Updated dependencies [6c03f61]
- @goat-sdk/[email protected]
- @goat-sdk/[email protected]
- @goat-sdk/[email protected]
- @goat-sdk/[email protected]

## 0.1.1

### Patch Changes

- Updated dependencies [608f9f1]
- @goat-sdk/[email protected]

## 0.1.0

### Minor Changes

- d3d9a7d: Upgrade to new plugin architecture

### Patch Changes

- Updated dependencies [d3d9a7d]
- @goat-sdk/[email protected]
- @goat-sdk/[email protected]
- @goat-sdk/[email protected]
- @goat-sdk/[email protected]

## 0.0.3

### Patch Changes

- Updated dependencies [a66ceec]
- @goat-sdk/[email protected]
- @goat-sdk/[email protected]
- @goat-sdk/[email protected]
- @goat-sdk/[email protected]

## 0.0.2

### Patch Changes

- 16271ab: Simplify core architecture
- Updated dependencies [16271ab]
- @goat-sdk/[email protected]
- @goat-sdk/[email protected]
- @goat-sdk/[email protected]
- @goat-sdk/[email protected]

## 0.0.1

### Patch Changes

- cad06c0: uniswap package and example
- Updated dependencies [cad06c0]
- Updated dependencies [ad45f94]
- @goat-sdk/[email protected]
- @goat-sdk/[email protected]
- @goat-sdk/[email protected]
- @goat-sdk/[email protected]
34 changes: 34 additions & 0 deletions typescript/examples/vercel-ai/lens/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Vercel AI Uniswap Example

## Setup

Create an `.env` file by copying the `.env.template` and populating with your values.

```
cp .env.template .env
```

`UNISWAP_API_KEY` and `UNISWAP_BASE_URL` will be populated in the next step.

## Usage

1. Create an API key for Uniswap's Trading API by visiting [this page](https://hub.uniswap.org/) and following the instructions. Also obtain the url from the API key creation page.

2. Run the script with your prompt!

```
npx ts-node index.ts
```

Some examples:

* Prompt it to swap 1 ETH for USDC

## Actions it supports

- `Get Quote`: Get a quote for a swap
- `Get Swap Transaction`: Get the transaction details for a swap
- `Send Transaction`: Send a transaction
- `Check Approval`: Check if the wallet has enough approval for a token and returns the transaction to approve the token. The approval must takes place before the swap transaction.

Want support for more actions? [Open an issue](https://github.com/goat-sdk/goat-sdk/issues) and let us know!
25 changes: 25 additions & 0 deletions typescript/examples/vercel-ai/lens/chain.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { defineChain } from "viem";

export const lens_testnet = /*#__PURE__*/ defineChain({
Copy link
Contributor

Choose a reason for hiding this comment

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

You can also use the lens package to import the network without having to define it :)

https://dev-preview.lens.xyz/docs/network/getting-started/viem

id: 37111,
name: "Lens Testnet",
network: "Lens Network Sepolia Testnet",
nativeCurrency: {
name: "GRASS",
symbol: "GSS",
decimals: 18,
},
rpcUrls: {
default: {
http: ["https://rpc.testnet.lens.dev"],
},
},
blockExplorers: {
default: {
name: "Lens Explorer",
url: "https://block-explorer.testnet.lens.dev",
apiUrl: "https://block-explorer-api.staging.lens.dev",
},
},
testnet: false,
});
36 changes: 36 additions & 0 deletions typescript/examples/vercel-ai/lens/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { openai } from "@ai-sdk/openai";
import { generateText } from "ai";

import { http } from "viem";
import { createWalletClient } from "viem";
import { privateKeyToAccount } from "viem/accounts";
import { lens_testnet } from "./chain";
import { getOnChainTools } from "@goat-sdk/adapter-vercel-ai";
import { lens } from "@goat-sdk/plugin-lens";
import { viem } from "@goat-sdk/wallet-viem";

require("dotenv").config();

const account = privateKeyToAccount(`0x${process.env.WALLET_PRIVATE_KEY}`);

const walletClient = createWalletClient({
account: account,
transport: http(`${process.env.ALCHEMY_LENS_RPC_URL}`),
chain: lens_testnet,
});

(async () => {
const tools = await getOnChainTools({
wallet: viem(walletClient),
plugins: [lens()],
});

const result = await generateText({
model: openai("gpt-4o"),
tools: tools,
maxSteps: 5,
prompt: "Get the creator of post https://hey.xyz/posts/0x033026-0x0580 and tip him 1 token",
});

console.log(result.text);
})();
21 changes: 21 additions & 0 deletions typescript/examples/vercel-ai/lens/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "goat-examples-vercel-ai-lens",
"version": "0.1.6",
"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-lens": "workspace:*",
"@goat-sdk/wallet-viem": "workspace:*",
"ai": "^4.0.3",
"dotenv": "^16.4.5",
"viem": "2.21.49"
}
}
8 changes: 8 additions & 0 deletions typescript/examples/vercel-ai/lens/tsconfig.json
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"]
}
4 changes: 3 additions & 1 deletion typescript/examples/vercel-ai/uniswap/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ import { viem } from "@goat-sdk/wallet-viem";

require("dotenv").config();

const account = privateKeyToAccount(process.env.WALLET_PRIVATE_KEY as `0x${string}`);
const account = privateKeyToAccount(
process.env.WALLET_PRIVATE_KEY as `0x${string}`
);

const walletClient = createWalletClient({
account: account,
Expand Down
8 changes: 8 additions & 0 deletions typescript/packages/plugins/lens/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# @goat-sdk/plugin-opensea

## 0.1.1

### Patch Changes

- Updated dependencies [50180d4]
- @goat-sdk/[email protected]
30 changes: 30 additions & 0 deletions typescript/packages/plugins/lens/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Goat Lens Plugin 🐐 - TypeScript

Lens plugin for [Goat 🐐](https://ohmygoat.dev). Allows you to fetch the wallet address of lens creator based on their post

## Installation

```
npm install @goat-sdk/plugin-lens
```

## Usage

```typescript
import { opensea } from "@goat-sdk/plugin-lens";

const plugin = lens({});
```

## Working example

## Goat

<div align="center">
Go out and eat some grass.

[Docs](https://ohmygoat.dev) | [Examples](https://github.com/goat-sdk/goat/tree/main/typescript/examples) | [Discord](https://discord.gg/2F8zTVnnFz)</div>

## Goat 🐐

Goat 🐐 (Great Onchain Agent Toolkit) is an open-source library enabling AI agents to interact with blockchain protocols and smart contracts via their own wallets.
Loading