Skip to content
Draft
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
2 changes: 1 addition & 1 deletion typescript/agentkit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
"axios": "^1.9.0",
"bs58": "^4.0.1",
"canonicalize": "^2.1.0",
"clanker-sdk": "^4.1.18",
"clanker-sdk": "^4.1.23",
"decimal.js": "^10.5.0",
"ethers": "^6.13.5",
"graphql-request": "^7.2.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import { CreateAction } from "../actionDecorator";
import { EvmWalletProvider } from "../../wallet-providers";
import { ClankTokenSchema } from "./schemas";
import { createClankerClient } from "./utils";
import { encodeFunctionData } from "viem";

/**
* ClankerActionProvider provides actions for clanker operations.
Expand All @@ -25,8 +25,7 @@
* Clanker action provider
*
* @description
* This action deploys a clanker token using the Clanker sdk
* It automatically includes the coin in the Clanker ecosystem
* This action deploys a clanker token using the Clanker SDK
*
* @param walletProvider - The wallet provider instance for blockchain interactions
* @param args - Clanker arguments (modify these to fine tune token deployment, like initial quote token and rewards config)
Expand All @@ -35,7 +34,7 @@
@CreateAction({
name: "clank_token",
description: `
his tool will launch a Clanker token using the Clanker SDK.
This action deploys a clanker token using the Clanker SDK.
It takes the following inputs:
- tokenName: The name of the deployed token
- tokenSymbol: The symbol of the deployed token
Expand All @@ -58,7 +57,8 @@
return `Can't Clank token; network ${networkId} is not supported`;
}

const clanker = await createClankerClient(walletProvider, networkId);
const { Clanker } = await import("clanker-sdk/v4");
const clanker = new Clanker({ publicClient: walletProvider.getPublicClient() });

const lockDuration = args.lockDuration_Days * 24 * 60 * 60;
const vestingDuration = args.vestingDuration_Days * 24 * 60 * 60;
Expand All @@ -67,13 +67,17 @@
name: args.tokenName,
symbol: args.tokenSymbol,
image: args.image,
metadata: {
socialMediaUrls: args.socialMediaUrls,
description: args.description,
},
...(args.socialMediaUrls || args.description
? {
metadata: {
...(args.socialMediaUrls && { socialMediaUrls: args.socialMediaUrls }),
...(args.description && { description: args.description }),
},
}
: {}),
context: {
interface: args.interface,
id: args.id,
...(args.id && { id: args.id }),
},
tokenAdmin: walletProvider.getAddress() as `0x${string}`,
vault: {
Expand All @@ -84,23 +88,68 @@
chainId: Number(network.chainId) as 8453 | 84532 | 42161 | undefined,
};

const deployTransaction = await clanker.getDeployTransaction(tokenConfig);
console.log("deployTransaction", deployTransaction);
console.log("tokenConfig", deployTransaction.args[0].tokenConfig);

// Encode the function data properly for sendTransaction
const data = encodeFunctionData({
abi: deployTransaction.abi,
functionName: deployTransaction.functionName,
args: deployTransaction.args,
});

try {
const res = await clanker.deploy(tokenConfig);
const gas = await walletProvider.getPublicClient().estimateContractGas({
...deployTransaction,
account: walletProvider.getAddress() as `0x${string}`,
});
console.log("estimateContractGas:", gas);
} catch (error) {
console.log("error in estimateContractGas", error);
}

if ("error" in res) {
return `There was an error deploying the clanker token: ${res}`;
}
try {
const gas = await walletProvider.getPublicClient().estimateGas({
account: walletProvider.getAddress() as `0x${string}`,
to: deployTransaction.address,
value: deployTransaction.value,
data: data,
});
console.log("estimateGas:", gas);
} catch (error) {
console.log("error in estimateGas", error);
}

try {
const txHash = await walletProvider.sendTransaction({
to: deployTransaction.address,
data,
value: deployTransaction.value,
});

const { txHash } = res;
const receipt = await walletProvider.waitForTransactionReceipt(txHash);
console.log("receipt", receipt);

const confirmed = await res.waitForTransaction();
if ("error" in confirmed) {
return `There was an error confirming the clanker token deployment: ${confirmed}`;
}
if (receipt.status === "reverted" || receipt.status === "failed")

Check failure on line 134 in typescript/agentkit/src/action-providers/clanker/clankerActionProvider.ts

View workflow job for this annotation

GitHub Actions / lint-typescript

Delete `·`
return `The transaction reverted: ${receipt.status}`;

const { address } = confirmed;
// Extract token address from logs
// The token address is in the first Transfer event from null address (token minting)
const transferEventSignature =
"0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef";
const nullAddress = "0x0000000000000000000000000000000000000000000000000000000000000000";

return `Clanker token deployed at ${address}! View the transaction at ${txHash}, or view the token page at https://clanker.world/clanker/${address}`;
const tokenLog = receipt.logs.find(
log => log.topics[0] === transferEventSignature && log.topics[1] === nullAddress,
);

const tokenAddress = tokenLog?.address;
if (tokenAddress) {
return `Clanker token deployed at address ${tokenAddress}! View the transaction at ${txHash}. View the token page at https://clanker.world/clanker/${tokenAddress}`;
}

return `Clanker token deployed! View the transaction at ${txHash}`;
} catch (error) {
return `There was an error deploying the clanker token: ${error}`;
}
Expand All @@ -112,13 +161,10 @@
* @param network - The network to check support for
* @returns True if the network is supported
*/
supportsNetwork(network: Network): boolean {
return (
network.networkId === "base-mainnet" ||
network.networkId === "base-sepolia" ||
network.networkId === "arbitrum-mainnet"
);
}
supportsNetwork = (network: Network) =>
network.networkId === "base-mainnet" ||
network.networkId === "base-sepolia" ||
network.networkId === "arbitrum-mainnet";
}

/**
Expand Down
4 changes: 2 additions & 2 deletions typescript/agentkit/src/action-providers/clanker/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ export const ClankTokenSchema = z
.describe('System the token was deployed via. Defaults to "CDP AgentKit".'),
id: z
.string()
.default("")
.optional()
.describe(
"User id of the poster on the social platform the token was deployed from. Used for provenance and will be verified by aggregators.",
"User id of the poster on the social platform the token was deployed from (optional). Used for provenance and will be verified by aggregators.",
),
})
.strip()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ export class CdpSmartWalletProvider extends EvmWalletProvider implements WalletP

// Append transaction logs if available
if (receipt.status === "complete") {
const receiptTx = await this.#publicClient.getTransactionReceipt({
const receiptTx = await this.#publicClient.waitForTransactionReceipt({
hash: receipt.transactionHash as Hex,
});
if (receiptTx.logs) return { ...receipt, logs: receiptTx.logs };
Expand Down
2 changes: 2 additions & 0 deletions typescript/examples/langchain-cdp-chatbot/chatbot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
CdpSolanaWalletProvider,
splActionProvider,
x402ActionProvider,
clankerActionProvider,
} from "@coinbase/agentkit";
import { getLangChainTools } from "@coinbase/agentkit-langchain";
import { HumanMessage } from "@langchain/core/messages";
Expand Down Expand Up @@ -124,6 +125,7 @@ async function initializeAgent() {
erc20ActionProvider(),
erc721ActionProvider(),
x402ActionProvider(),
clankerActionProvider(),
]
: isSolanaWalletProvider(walletProvider)
? [splActionProvider()]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
walletActionProvider,
wethActionProvider,
x402ActionProvider,
clankerActionProvider,
} from "@coinbase/agentkit";
import { getLangChainTools } from "@coinbase/agentkit-langchain";
import { HumanMessage } from "@langchain/core/messages";
Expand Down Expand Up @@ -119,6 +120,7 @@ async function initializeAgent() {
cdpApiActionProvider(),
cdpSmartWalletActionProvider(),
x402ActionProvider(),
clankerActionProvider(),
],
});

Expand Down
Loading
Loading