chainstacklabs / raydium-sdk-swap-example-typescript

An example to swap tokens on Solana using the Raydium SDK, TypeScript, and Chainstack
MIT License
99 stars 35 forks source link

code: 'UND_ERR_CONNECT_TIMEOUT' #13

Closed brooke007 closed 1 month ago

brooke007 commented 3 months ago

It's my swapConfig.ts

export const swapConfig = {
  executeSwap: true, // Send tx when true, simulate tx when false
  useVersionedTransaction: true,
  tokenAAmount: 0.001, // Swap 0.01 SOL for USDT in this example
  tokenAAddress: "So11111111111111111111111111111111111111112", // Token to swap for the other, SOL in this case
  tokenBAddress: "Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB", // USDC address
  maxLamports: 1000000, // Micro lamports for priority fee
  direction: "out" as "out", // Swap direction: 'in' or 'out'
  liquidityFile: "https://api.raydium.io/v2/sdk/liquidity/mainnet.json",
  maxRetries: 10,
};

when I run yarn swap, it shows error like title

akegaviar commented 1 month ago

The reason is because mainnet.json is a huge 500 MB file and it takes a lot of time to download it and load it into memory. I updated the project to only use the trimmed version. Check the details here https://github.com/chainstacklabs/raydium-sdk-swap-example-typescript/blob/main/README.md#tldr-quick-run