Skip to content
Merged
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
5 changes: 5 additions & 0 deletions typescript/.changeset/fruity-heads-visit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@coinbase/agentkit": patch
---

Fixed unit issues in balance/transfer actions; Added new action to get frequently used token addresses by symbol
4 changes: 4 additions & 0 deletions typescript/agentkit/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,10 @@ const agent = createReactAgent({
<td width="200"><code>transfer</code></td>
<td width="768">Transfers a specified amount of ERC-20 tokens to a destination address.</td>
</tr>
<tr>
<td width="200"><code>get_erc20_token_address</code></td>
<td width="768">Gets the contract address for frequently used ERC20 tokens on different networks by token symbol.</td>
</tr>
</table>
</details>
<details>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { BridgeTokenSchema, CheckDepositStatusSchema } from "./schemas";
import { EvmWalletProvider } from "../../wallet-providers";
import { isAcrossSupportedTestnet } from "./utils";
import { privateKeyToAccount } from "viem/accounts";
import { abi as ERC20_ABI } from "../erc20/constants";
import { erc20Abi as ERC20_ABI } from "viem";
/**
* Configuration options for the SafeWalletProvider.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,8 @@ It takes the following inputs:
- slippageBps: (Optional) Maximum allowed slippage in basis points (100 = 1%)
Important notes:
- The contract address for native ETH is "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"
- Use fromAmount units exactly as provided, do not convert to wei or any other units.
- Use fromAmount units exactly as provided, do not convert to wei or any other units
- Never assume token or address, they have to be provided as inputs. If only token symbol is provided, use the get_token_address tool if available to get the token address first
`,
schema: SwapSchema,
})
Expand Down Expand Up @@ -221,6 +222,7 @@ Important notes:
- The contract address for native ETH is "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"
- If needed, it will automatically approve the permit2 contract to spend the fromToken
- Use fromAmount units exactly as provided, do not convert to wei or any other units.
- Never assume token or address, they have to be provided as inputs. If only token symbol is provided, use the get_token_address tool if available to get the token address first
`,
schema: SwapSchema,
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ It takes the following inputs:
- slippageBps: (Optional) Maximum allowed slippage in basis points (100 = 1%)
Important notes:
- The contract address for native ETH is "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"
- Use fromAmount units exactly as provided, do not convert to wei or any other units.
- Use fromAmount units exactly as provided, do not convert to wei or any other units
- Never assume token or address, they have to be provided as inputs. If only token symbol is provided, use the get_token_address tool if available to get the token address first
`,
schema: SwapSchema,
})
Expand Down Expand Up @@ -206,7 +207,8 @@ It takes the following inputs:
Important notes:
- The contract address for native ETH is "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"
- If needed, it will automatically approve the permit2 contract to spend the fromToken
- Use fromAmount units exactly as provided, do not convert to wei or any other units.
- Use fromAmount units exactly as provided, do not convert to wei or any other units
- Never assume token or address, they have to be provided as inputs. If only token symbol is provided, use the get_token_address tool if available to get the token address first
`,
schema: SwapSchema,
})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Address } from "viem";
import { abi as ERC20_ABI } from "../erc20/constants";
import { erc20Abi as ERC20_ABI } from "viem";

export const SUPPORTED_NETWORKS = ["base-mainnet", "base-sepolia"];

Expand Down
7 changes: 7 additions & 0 deletions typescript/agentkit/src/action-providers/erc20/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ erc20/
├── constants.ts # Constants for ERC20 provider
├── schemas.ts # Token action schemas
├── index.ts # Main exports
├── utils.ts # Utility functions
└── README.md # This file
```

Expand All @@ -26,6 +27,12 @@ erc20/
- Constructs and sends the transfer transaction
- Returns the **transaction hash** upon success

- `get_erc20_token_address`: Get the contract address for a token symbol

- Takes a token symbol (e.g. USDC, EURC, CBBTC) as input
- Returns the **contract address** for the token on the current network
- Provides available token symbols if the requested symbol is not found

## Adding New Actions

To add new ERC20 actions:
Expand Down
226 changes: 37 additions & 189 deletions typescript/agentkit/src/action-providers/erc20/constants.ts
Original file line number Diff line number Diff line change
@@ -1,194 +1,5 @@
import { Coinbase } from "@coinbase/coinbase-sdk";

export const abi = [
{
type: "event",
name: "Approval",
inputs: [
{
indexed: true,
name: "owner",
type: "address",
},
{
indexed: true,
name: "spender",
type: "address",
},
{
indexed: false,
name: "value",
type: "uint256",
},
],
},
{
type: "event",
name: "Transfer",
inputs: [
{
indexed: true,
name: "from",
type: "address",
},
{
indexed: true,
name: "to",
type: "address",
},
{
indexed: false,
name: "value",
type: "uint256",
},
],
},
{
type: "function",
name: "allowance",
stateMutability: "view",
inputs: [
{
name: "owner",
type: "address",
},
{
name: "spender",
type: "address",
},
],
outputs: [
{
type: "uint256",
},
],
},
{
type: "function",
name: "approve",
stateMutability: "nonpayable",
inputs: [
{
name: "spender",
type: "address",
},
{
name: "amount",
type: "uint256",
},
],
outputs: [
{
type: "bool",
},
],
},
{
type: "function",
name: "balanceOf",
stateMutability: "view",
inputs: [
{
name: "account",
type: "address",
},
],
outputs: [
{
type: "uint256",
},
],
},
{
type: "function",
name: "decimals",
stateMutability: "view",
inputs: [],
outputs: [
{
type: "uint8",
},
],
},
{
type: "function",
name: "name",
stateMutability: "view",
inputs: [],
outputs: [
{
type: "string",
},
],
},
{
type: "function",
name: "symbol",
stateMutability: "view",
inputs: [],
outputs: [
{
type: "string",
},
],
},
{
type: "function",
name: "totalSupply",
stateMutability: "view",
inputs: [],
outputs: [
{
type: "uint256",
},
],
},
{
type: "function",
name: "transfer",
stateMutability: "nonpayable",
inputs: [
{
name: "recipient",
type: "address",
},
{
name: "amount",
type: "uint256",
},
],
outputs: [
{
type: "bool",
},
],
},
{
type: "function",
name: "transferFrom",
stateMutability: "nonpayable",
inputs: [
{
name: "sender",
type: "address",
},
{
name: "recipient",
type: "address",
},
{
name: "amount",
type: "uint256",
},
],
outputs: [
{
type: "bool",
},
],
},
] as const;

export const BaseTokenToAssetId = new Map([
["0xcbB7C0000aB88B473b1f5aFd9ef808440eed33Bf", Coinbase.assets.Cbbtc],
["0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", Coinbase.assets.Usdc],
Expand All @@ -200,3 +11,40 @@ export const BaseSepoliaTokenToAssetId = new Map([
["0x036CbD53842c5426634e7929541eC2318f3dCF7e", Coinbase.assets.Usdc],
["0x808456652fdb597867f38412077A9182bf77359F", Coinbase.assets.Eurc],
]);

// Token symbol to address mappings for frequently used tokens
export const TOKEN_ADDRESSES_BY_SYMBOLS = {
"base-mainnet": {
USDC: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
EURC: "0x60a3E35Cc302bFA44Cb288Bc5a4F316Fdb1adb42",
CBBTC: "0xcbB7C0000aB88B473b1f5aFd9ef808440eed33Bf",
CBETH: "0x2Ae3F1Ec7F1F5012CFEab0185bfc7aa3cf0DEc22",
WETH: "0x4200000000000000000000000000000000000006",
ZORA: "0x1111111111166b7FE7bd91427724B487980aFc69",
AERO: "0x940181a94a35a4569e4529a3cdfb74e38fd98631",
BNKR: "0x22af33fe49fd1fa80c7149773dde5890d3c76f3b",
CLANKER: "0x1bc0c42215582d5a085795f4badbac3ff36d1bcb",
},
"base-sepolia": {
USDC: "0x036CbD53842c5426634e7929541eC2318f3dCF7e",
EURC: "0x808456652fdb597867f38412077A9182bf77359F",
CBBTC: "0xcbB7C0006F23900c38EB856149F799620fcb8A4a",
WETH: "0x4200000000000000000000000000000000000006",
},
"ethereum-mainnet": {
USDC: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
EURC: "0x1abaea1f7c830bd89acc67ec4af516284b1bc33c",
CBBTC: "0xcbB7C0000aB88B473b1f5aFd9ef808440eed33Bf",
WETH: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
CBETH: "0xBe9895146f7AF43049ca1c1AE358B0541Ea49704",
},
"polygon-mainnet": {
USDC: "0x3c499c542cef5e3811e1192ce70d8cc03d5c3359",
},
"arbitrum-mainnet": {
USDC: "0xaf88d065e77c8cc2239327c5edb3a432268e5831",
},
"optimism-mainnet": {
USDC: "0x0b2c639c533813f4aa9d7837caf62653d097ff85",
},
} as const;
Loading
Loading