{"id":25860502,"url":"https://github.com/yumecode11/pumpfun-sdk-devnet-support-open-source","last_synced_at":"2025-07-16T10:38:34.862Z","repository":{"id":278189338,"uuid":"934811348","full_name":"yumecode11/pumpfun-sdk-devnet-support-open-source","owner":"yumecode11","description":"pumpfun sdk ( mainnet + devnet support ) : This is sdk which is designed for maintainence product in mainnet and test it on devnet ","archived":false,"fork":false,"pushed_at":"2025-02-18T12:56:34.000Z","size":146,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-01T22:35:02.115Z","etag":null,"topics":["bot","devnet","mainnet","market","pumpfun","pumpfun-sdk","rpc","sdk","trade","trend"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yumecode11.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-02-18T12:50:13.000Z","updated_at":"2025-02-21T11:00:48.000Z","dependencies_parsed_at":"2025-02-18T13:50:59.625Z","dependency_job_id":null,"html_url":"https://github.com/yumecode11/pumpfun-sdk-devnet-support-open-source","commit_stats":null,"previous_names":["yumecode11/pumpfun-sdk-devnet","yumecode11/pumpfun-sdk-devnet-support-open-source"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yumecode11%2Fpumpfun-sdk-devnet-support-open-source","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yumecode11%2Fpumpfun-sdk-devnet-support-open-source/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yumecode11%2Fpumpfun-sdk-devnet-support-open-source/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yumecode11%2Fpumpfun-sdk-devnet-support-open-source/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yumecode11","download_url":"https://codeload.github.com/yumecode11/pumpfun-sdk-devnet-support-open-source/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241435130,"owners_count":19962400,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bot","devnet","mainnet","market","pumpfun","pumpfun-sdk","rpc","sdk","trade","trend"],"created_at":"2025-03-01T22:35:13.963Z","updated_at":"2025-03-01T22:35:14.828Z","avatar_url":"https://github.com/yumecode11.png","language":"TypeScript","readme":"# PumpFunSDK README Mainnet + Devnet Surpport\n\nYou can test your pumpfun tool on devnet. if you wanna publish it as product , you only have to change RPC\n\n## Important\n\nNever click links in this repository leaving github, never click links in Issues, don't run code that others post without reading it, this software is provided \"as is,\" without warranty.\n\n## Overview\n\nThe `PumpDotFunSDK` is designed to interact with the Pump.fun decentralized application. It provides methods for creating, buying, and selling tokens using the Solana blockchain. The SDK handles the necessary transactions and interactions with the Pump.fun program.\n\n## Installation\n\n`\nnpm i pumpdotfun-sdk\n`\n\n## Usage Example\n\nFirst you need to create a `.env` file and set your RPC URL like in the `.env.example`\n\nThen you need to fund an account with atleast 0.004 SOL that is generated when running the command below\n\n`\nnpx ts-node example/basic/index.ts\n`\n\n```typescript\nimport dotenv from \"dotenv\";\nimport { Connection, Keypair, LAMPORTS_PER_SOL } from \"@solana/web3.js\";\nimport { DEFAULT_DECIMALS, PumpFunSDK } from \"pumpdotfun-sdk\";\nimport NodeWallet from \"@coral-xyz/anchor/dist/cjs/nodewallet\";\nimport { AnchorProvider } from \"@coral-xyz/anchor\";\nimport {\n  getOrCreateKeypair,\n  getSPLBalance,\n  printSOLBalance,\n  printSPLBalance,\n} from \"./util\";\n\ndotenv.config();\n\nconst KEYS_FOLDER = __dirname + \"/.keys\";\nconst SLIPPAGE_BASIS_POINTS = 100n;\n\nconst getProvider = () =\u003e {\n  if (!process.env.HELIUS_RPC_URL) {\n    throw new Error(\"Please set HELIUS_RPC_URL in .env file\");\n  }\n\n  const connection = new Connection(process.env.HELIUS_RPC_URL || \"\");\n  const wallet = new NodeWallet(new Keypair());\n  return new AnchorProvider(connection, wallet, { commitment: \"finalized\" });\n};\n\nconst createAndBuyToken = async (sdk, testAccount, mint) =\u003e {\n  const tokenMetadata = {\n    name: \"TST-7\",\n    symbol: \"TST-7\",\n    description: \"TST-7: This is a test token\",\n    filePath: \"example/basic/random.png\",\n  };\n\n  const createResults = await sdk.createAndBuy(\n    testAccount,\n    mint,\n    tokenMetadata,\n    BigInt(0.0001 * LAMPORTS_PER_SOL),\n    SLIPPAGE_BASIS_POINTS,\n    {\n      unitLimit: 250000,\n      unitPrice: 250000,\n    }\n  );\n\n  if (createResults.success) {\n    console.log(\"Success:\", `https://pump.fun/${mint.publicKey.toBase58()}`);\n    printSPLBalance(sdk.connection, mint.publicKey, testAccount.publicKey);\n  } else {\n    console.log(\"Create and Buy failed\");\n  }\n};\n\nconst buyTokens = async (sdk, testAccount, mint) =\u003e {\n  const buyResults = await sdk.buy(\n    testAccount,\n    mint.publicKey,\n    BigInt(0.0001 * LAMPORTS_PER_SOL),\n    SLIPPAGE_BASIS_POINTS,\n    {\n      unitLimit: 250000,\n      unitPrice: 250000,\n    }\n  );\n\n  if (buyResults.success) {\n    printSPLBalance(sdk.connection, mint.publicKey, testAccount.publicKey);\n    console.log(\"Bonding curve after buy\", await sdk.getBondingCurveAccount(mint.publicKey));\n  } else {\n    console.log(\"Buy failed\");\n  }\n};\n\nconst sellTokens = async (sdk, testAccount, mint) =\u003e {\n  const currentSPLBalance = await getSPLBalance(\n    sdk.connection,\n    mint.publicKey,\n    testAccount.publicKey\n  );\n  console.log(\"currentSPLBalance\", currentSPLBalance);\n\n  if (currentSPLBalance) {\n    const sellResults = await sdk.sell(\n      testAccount,\n      mint.publicKey,\n      BigInt(currentSPLBalance * Math.pow(10, DEFAULT_DECIMALS)),\n      SLIPPAGE_BASIS_POINTS,\n      {\n        unitLimit: 250000,\n        unitPrice: 250000,\n      }\n    );\n\n    if (sellResults.success) {\n      await printSOLBalance(sdk.connection, testAccount.publicKey, \"Test Account keypair\");\n      printSPLBalance(sdk.connection, mint.publicKey, testAccount.publicKey, \"After SPL sell all\");\n      console.log(\"Bonding curve after sell\", await sdk.getBondingCurveAccount(mint.publicKey));\n    } else {\n      console.log(\"Sell failed\");\n    }\n  }\n};\n\nconst main = async () =\u003e {\n  try {\n    const provider = getProvider();\n    const sdk = new PumpFunSDK(provider);\n    const connection = provider.connection;\n\n    const testAccount = getOrCreateKeypair(KEYS_FOLDER, \"test-account\");\n    const mint = getOrCreateKeypair(KEYS_FOLDER, \"mint\");\n\n    await printSOLBalance(connection, testAccount.publicKey, \"Test Account keypair\");\n\n    const globalAccount = await sdk.getGlobalAccount();\n    console.log(globalAccount);\n\n    const currentSolBalance = await connection.getBalance(testAccount.publicKey);\n    if (currentSolBalance === 0) {\n      console.log(\"Please send some SOL to the test-account:\", testAccount.publicKey.toBase58());\n      return;\n    }\n\n    console.log(await sdk.getGlobalAccount());\n\n    let bondingCurveAccount = await sdk.getBondingCurveAccount(mint.publicKey);\n    if (!bondingCurveAccount) {\n      await createAndBuyToken(sdk, testAccount, mint);\n      bondingCurveAccount = await sdk.getBondingCurveAccount(mint.publicKey);\n    }\n\n    if (bondingCurveAccount) {\n      await buyTokens(sdk, testAccount, mint);\n      await sellTokens(sdk, testAccount, mint);\n    }\n  } catch (error) {\n    console.error(\"An error occurred:\", error);\n  }\n};\n\nmain();\n```\n\n\n### PumpDotFunSDK Class\n\nThe `PumpDotFunSDK` class provides methods to interact with the PumpFun protocol. Below are the method signatures and their descriptions.\n\n\n#### createAndBuy\n\n```typescript\nasync createAndBuy(\n  creator: Keypair,\n  mint: Keypair,\n  createTokenMetadata: CreateTokenMetadata,\n  buyAmountSol: bigint,\n  slippageBasisPoints: bigint = 500n,\n  priorityFees?: PriorityFee,\n  commitment: Commitment = DEFAULT_COMMITMENT,\n  finality: Finality = DEFAULT_FINALITY\n): Promise\u003cTransactionResult\u003e\n```\n\n- Creates a new token and buys it.\n- **Parameters**:\n  - `creator`: The keypair of the token creator.\n  - `mint`: The keypair of the mint account.\n  - `createTokenMetadata`: Metadata for the token.\n  - `buyAmountSol`: Amount of SOL to buy.\n  - `slippageBasisPoints`: Slippage in basis points (default: 500).\n  - `priorityFees`: Priority fees (optional).\n  - `commitment`: Commitment level (default: DEFAULT_COMMITMENT).\n  - `finality`: Finality level (default: DEFAULT_FINALITY).\n- **Returns**: A promise that resolves to a `TransactionResult`.\n\n#### buy\n\n```typescript\nasync buy(\n  buyer: Keypair,\n  mint: PublicKey,\n  buyAmountSol: bigint,\n  slippageBasisPoints: bigint = 500n,\n  priorityFees?: PriorityFee,\n  commitment: Commitment = DEFAULT_COMMITMENT,\n  finality: Finality = DEFAULT_FINALITY\n): Promise\u003cTransactionResult\u003e\n```\n\n- Buys a specified amount of tokens.\n- **Parameters**:\n  - `buyer`: The keypair of the buyer.\n  - `mint`: The public key of the mint account.\n  - `buyAmountSol`: Amount of SOL to buy.\n  - `slippageBasisPoints`: Slippage in basis points (default: 500).\n  - `priorityFees`: Priority fees (optional).\n  - `commitment`: Commitment level (default: DEFAULT_COMMITMENT).\n  - `finality`: Finality level (default: DEFAULT_FINALITY).\n- **Returns**: A promise that resolves to a `TransactionResult`.\n\n#### sell\n\n```typescript\nasync sell(\n  seller: Keypair,\n  mint: PublicKey,\n  sellTokenAmount: bigint,\n  slippageBasisPoints: bigint = 500n,\n  priorityFees?: PriorityFee,\n  commitment: Commitment = DEFAULT_COMMITMENT,\n  finality: Finality = DEFAULT_FINALITY\n): Promise\u003cTransactionResult\u003e\n```\n\n- Sells a specified amount of tokens.\n- **Parameters**:\n  - `seller`: The keypair of the seller.\n  - `mint`: The public key of the mint account.\n  - `sellTokenAmount`: Amount of tokens to sell.\n  - `slippageBasisPoints`: Slippage in basis points (default: 500).\n  - `priorityFees`: Priority fees (optional).\n  - `commitment`: Commitment level (default: DEFAULT_COMMITMENT).\n  - `finality`: Finality level (default: DEFAULT_FINALITY).\n- **Returns**: A promise that resolves to a `TransactionResult`.\n\n#### addEventListener\n\n```typescript\naddEventListener\u003cT extends PumpFunEventType\u003e(\n  eventType: T,\n  callback: (event: PumpFunEventHandlers[T], slot: number, signature: string) =\u003e void\n): number\n```\n\n- Adds an event listener for the specified event type.\n- **Parameters**:\n  - `eventType`: The type of event to listen for.\n  - `callback`: The callback function to execute when the event occurs.\n- **Returns**: An identifier for the event listener.\n\n#### removeEventListener\n\n```typescript\nremoveEventListener(eventId: number): void\n```\n\n- Removes the event listener with the specified identifier.\n- **Parameters**:\n  - `eventId`: The identifier of the event listener to remove.\n\n### Running the Examples\n\n#### Basic Example\n\nTo run the basic example for creating, buying, and selling tokens, use the following command:\n\n```bash\nnpx ts-node example/basic/index.ts\n```\n\n#### Event Subscription Example\n\nThis example demonstrates how to set up event subscriptions using the PumpFun SDK.\n\n#### Script: `example/events/events.ts`\n\n```typescript\nimport dotenv from \"dotenv\";\nimport { Connection, Keypair } from \"@solana/web3.js\";\nimport { PumpFunSDK } from \"pumpdotfun-sdk\";\nimport NodeWallet from \"@coral-xyz/anchor/dist/cjs/nodewallet\";\nimport { AnchorProvider } from \"@coral-xyz/anchor\";\n\ndotenv.config();\n\nconst getProvider = () =\u003e {\n  if (!process.env.HELIUS_RPC_URL) {\n    throw new Error(\"Please set HELIUS_RPC_URL in .env file\");\n  }\n\n  const connection = new Connection(process.env.HELIUS_RPC_URL || \"\");\n  const wallet = new NodeWallet(new Keypair());\n  return new AnchorProvider(connection, wallet, { commitment: \"finalized\" });\n};\n\nconst setupEventListeners = async (sdk) =\u003e {\n  const createEventId = sdk.addEventListener(\"createEvent\", (event, slot, signature) =\u003e {\n    console.log(\"createEvent\", event, slot, signature);\n  });\n  console.log(\"Subscribed to createEvent with ID:\", createEventId);\n\n  const tradeEventId = sdk.addEventListener(\"tradeEvent\", (event, slot, signature) =\u003e {\n    console.log(\"tradeEvent\", event, slot, signature);\n  });\n  console.log(\"Subscribed to tradeEvent with ID:\", tradeEventId);\n\n  const completeEventId = sdk.addEventListener(\"completeEvent\", (event, slot, signature) =\u003e {\n    console.log(\"completeEvent\", event, slot, signature);\n  });\n  console.log(\"Subscribed to completeEvent with ID:\", completeEventId);\n};\n\nconst main = async () =\u003e {\n  try {\n    const provider = getProvider();\n    const sdk = new PumpFunSDK(provider);\n\n    // Set up event listeners\n    await setupEventListeners(sdk);\n  } catch (error) {\n    console.error(\"An error occurred:\", error);\n  }\n};\n\nmain();\n```\n\n#### Running the Event Subscription Example\n\nTo run the event subscription example, use the following command:\n\n```bash\nnpx ts-node example/events/events.ts\n```\n\n## Contributing\n\nWe welcome contributions! Please submit a pull request or open an issue to discuss any changes.\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\nHere is a sample \"Use at Your Own Risk\" disclaimer for a GitHub repository:\n\n---\n\n## Disclaimer\n\nThis software is provided \"as is,\" without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose, and noninfringement. In no event shall the authors or copyright holders be liable for any claim, damages, or other liability, whether in an action of contract, tort, or otherwise, arising from, out of, or in connection with the software or the use or other dealings in the software.\n\n**Use at your own risk.** The authors take no responsibility for any harm or damage caused by the use of this software. Users are responsible for ensuring the suitability and safety of this software for their specific use cases.\n\nBy using this software, you acknowledge that you have read, understood, and agree to this disclaimer.\n\n---\n\nFeel free to customize it further to suit the specific context and requirements of your project.\n\n---\n\nBy following this README, you should be able to install the PumpDotFun SDK, run the provided examples, and understand how to set up event listeners and perform token operations.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyumecode11%2Fpumpfun-sdk-devnet-support-open-source","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyumecode11%2Fpumpfun-sdk-devnet-support-open-source","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyumecode11%2Fpumpfun-sdk-devnet-support-open-source/lists"}