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

I got an error when using the trade method to buy or sell tokens #178

Open
q735041553 opened this issue Jan 10, 2025 · 0 comments
Open

I got an error when using the trade method to buy or sell tokens #178

q735041553 opened this issue Jan 10, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@q735041553
Copy link

q735041553 commented Jan 10, 2025

Describe the bug
I got an error when using the trade method to buy or sell tokens.

My code is this

import { PublicKey } from "@solana/web3.js";
import {SolanaAgentKit} from "solana-agent-kit";
import {mainPrivateKey, openaiApiKey, rpcUrl} from "./config.js";

const client = new SolanaAgentKit(
    mainPrivateKey,
    rpcUrl,
    openaiApiKey
);
const signature = await client.trade(
    new PublicKey("So11111111111111111111111111111111111111112"), // SOL
    100000, // 100000 Fartgoat
    new PublicKey("BhKTb3L8yDKBY3erBiiYWfvyEUddzBWJnvELCsiYpump"), // USDC
    100 // 1% slippage
);

console.log("Token Mint Address:", signature);

Expected behavior
It should exchange tokens.

Screenshots
image

Additional context
An error occurred.

@q735041553 q735041553 added the bug Something isn't working label Jan 10, 2025
@sendaifun sendaifun deleted a comment from q735041553 Jan 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants
@q735041553 and others