Solana: how we tested Pump-Fun-Exact-SOL Program Using Testnetpump.fun

Solana: how we tested Pump-Fun-Exact-SOL Program Using Testnetpump.fun
WEB3 ENGINEERING
When developing Solana-based programs, testing them effectively is critical. In this guide, I'll demonstrate how I used testnetpump.fun to test our new project, the pump-fun-exact-sol program.
Assuming your program is already set up and ready to deploy, let’s dive into the steps!

Step 1: Create a Wallet for Deploying the Program
Start by creating a wallet that will be used for deployment. Run the following command:
$ solana-keygen new --no-bip39-passphrase -o deployer.json
This will generate a new keypair and save it in the deployer.json file. You'll use this wallet throughout the deployment and testing process.

Step 2: Fund the Wallet Using Testnetpump.fun
  1. Visit testnetpump.fun.
  2. Request an airdrop to the wallet you just created by providing the public key.
After requesting the airdrop, wait until the balance is visible. You can confirm the wallet's balance with the following command:
$ solana balance -u https://testnetpump.fun:18899 deployer.json
The output should show your wallet funded with 7 SOL (or the amount testnetpump.fun provides). Example:
7 SOL
Step 3: Deploy the Pump-Fun-Exact-SOL Program
With your wallet funded, you can now deploy the program to the testnet. Use the following command:
$ solana program deploy -k deployer.json --program-id programid.json -u https://testnetpump.fun:18899 target/deploy/pfbbs.so --use-rpc
Here’s a breakdown of the command:
  • -k deployer.json: Specifies the wallet keypair file.
  • --program-id programid.json: Specifies the program ID file.
  • target/deploy/pfbbs.so: The compiled Solana program binary.
If successful, your program will now be live on the testnet.

Step 4: Create and Interact with Tokens
Head back to testnetpump.fun and create a new token. The platform allows you to generate tokens and bonding curves, which you’ll use for testing. After creating a token:
  1. Retrieve the mint address and bonding curve address from the Solana explorer.
These addresses will be used as inputs to your program.

Step 5: Write and Run a Test Script
Finally, it’s time to test your program. Create a simple script that interacts with your deployed program.
For example, a typical script in JavaScript might look like this. We omitted any structure and nice things just to show more or less how to interact with Pump-Fun-Exact-SOL program.
const web3 = require('@solana/web3.js')
const splToken = require('@solana/spl-token')
const programId = new web3.PublicKey("6sbiyZ7mLKmYkES2AKYPHtg4FjQMaqVx3jTHez6ZtfmX")
const connection = new web3.Connection('https://testnetpump.fun:18899')
const signer = web3.Keypair.fromSecretKey(new Uint8Array([...]))
const mint = new web3.PublicKey("F9Feoq4xrH5wf8CrSQtsbWaihAw7s4AtVVyMM5QuMYnU")
const ata = splToken.getAssociatedTokenAddressSync(mint, signer.publicKey)
const createAtaIx = splToken.createAssociatedTokenAccountIdempotentInstruction(signer.publicKey, ata, signer.publicKey, mint)
const solAmount = 2525000000n
const data = Buffer.alloc(8)
data.writeBigUInt64LE(solAmount)
const instruction = new web3.TransactionInstruction({
    keys: [
        {pubkey: new web3.PublicKey("4wTV1YmiEkRvAtNtsSGPtUrqRYQMe5SKy2uB4Jjaxnjf"), isSigner: false, isWritable: false},
        {pubkey: new web3.PublicKey("CebN5WGQ4jvEPvsVU4EoHEpgzq1VV7AbicfhtW4xC9iM"), isSigner: false, isWritable: true},
        {pubkey: mint, isSigner: false, isWritable: false},
        {pubkey: new web3.PublicKey("EfxG8nkXVbMfDcBScmJXwhEKRU4nVU72VBdVo67Sn5MH"), isSigner: false, isWritable: true},
        {pubkey: new web3.PublicKey("F9vPmsLgjm4o9n4AqXPPNvKo4RNuTwwG2Fba2YgZAmqh"), isSigner: false, isWritable: true},
        {pubkey: ata, isSigner: false, isWritable: true},
        {pubkey: signer.publicKey, isSigner: true, isWritable: true},
        {pubkey: new web3.PublicKey("11111111111111111111111111111111"), isSigner: false, isWritable: true},
        {pubkey: new web3.PublicKey("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"), isSigner: false, isWritable: true},
        {pubkey: new web3.PublicKey("SysvarRent111111111111111111111111111111111"), isSigner: false, isWritable: true},
        {pubkey: new web3.PublicKey("Ce6TQqeHC9p8KetsN6JsjHK7UTZk7nasjjnr7XxXp9F1"), isSigner: false, isWritable: true},
        {pubkey: new web3.PublicKey("6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P"), isSigner: false, isWritable: true},
    ],
    programId,
    data
})
const tx = new web3.Transaction().add(createAtaIx, instruction)
connection.sendTransaction(tx, [signer]).then(console.log).catch(console.error)
Close
Ready to take your business to the next level? Let's talk
I agree to the Terms of Service