2

i am trying to run my transaction, but i get the 0x65 error code, i dont know what it means could somebody help solve this problem? i am trying to interact with my program and post a title.

CLIENT CODE

import * as Web3 from '@solana/web3.js';
import * as fs from 'fs';
import dotenv from 'dotenv';
dotenv.config();

const PROGRAM_ID = new Web3.PublicKey("FS1yZFS9Vjbv77rqXBk46eGUdTgUXP7esZwKxtQFW8Ku")
const PROGRAM_DATA_PUBLIC_KEY = new Web3.PublicKey("Ah9K7dQ8EHaZqcAsgBW8w37yN2eAy3koFmUn4x3CJtod")


const TWEET_ACCOUNT_FILE = 'tweet_account.json';
const author_ACCOUNT_FILE = 'author_account.json';
async function pingProgram(
  connection: Web3.Connection,
  tweet: Web3.Keypair,
  author: Web3.Keypair
) {
  if (!process.env.PRIVATE_KEY) {
    console.log('Generating new keypair');
    author = Web3.Keypair.generate();
    fs.writeFileSync('.env', `PRIVATE_KEY=[${author.secretKey.toString()}]`);
  } else {
    console.log('Using existing keypair');
    const privateKeyArray = process.env.PRIVATE_KEY.split(',').map(s => parseInt(s));
    const privateKeyUint8Array = new Uint8Array(privateKeyArray);
    author = new Web3.Keypair({ publicKey: privateKeyUint8Array.slice(32), secretKey: privateKeyUint8Array });
  }  
  const balance = await connection.getBalance(author.publicKey);
  console.log('Current balance is', balance / Web3.LAMPORTS_PER_SOL, 'SOL');

  // 1 SOL should be enough for almost anything you wanna do
  if (balance / Web3.LAMPORTS_PER_SOL < 1) {
    // You can only get up to 2 SOL per request 
    console.log('Airdropping 1 SOL');
    const airdropSignature = await connection.requestAirdrop(
      author.publicKey,
      Web3.LAMPORTS_PER_SOL
    );

    const latestBlockhash = await connection.getLatestBlockhash();

    await connection.confirmTransaction({
      blockhash: latestBlockhash.blockhash,
      lastValidBlockHeight: latestBlockhash.lastValidBlockHeight,
      signature: airdropSignature,
    });
  }
    const newBalance = await connection.getBalance(author.publicKey);
    console.log('New balance is', newBalance / Web3.LAMPORTS_PER_SOL, 'SOL');
    const instructionData = Buffer.alloc(8);
    instructionData.writeBigInt64LE(BigInt(0)); // replace 0 with the instruction number you want to use
  const transaction = new Web3.Transaction();
  // console.log(tweet.publicKey.toString());
  const tweetTitle = "My first tweet!";
  const instruction = new Web3.TransactionInstruction({
    keys: [
      { pubkey: tweet.publicKey, isSigner: false, isWritable: true },
      { pubkey: author.publicKey, isSigner: true, isWritable: false },
      { pubkey: PROGRAM_DATA_PUBLIC_KEY, isSigner: false, isWritable: false },
    ],
    programId: PROGRAM_ID,
    data: instructionData,
  });
  
  const authorSecret = author.secretKey
  transaction.add(instruction);
  
  const transactionSignature = await Web3.sendAndConfirmTransaction(
    connection,
    transaction,
    [author], // add author as payer to signers
    { commitment: 'singleGossip', preflightCommitment: 'singleGossip' },
  );

  console.log(
    `Transaction https://explorer.solana.com/tx/${transactionSignature}?cluster=devnet`
  );
}



async function main() {
  const connection = new Web3.Connection(Web3.clusterApiUrl('devnet'));
  // const signer = await Web3.Keypair.generate();
  let author = Web3.Keypair.generate(); ;

  let tweet = Web3.Keypair.generate();
  
  // console.log("New bbaalance is", newBalance / Web3.LAMPORTS_PER_SOL)
  await pingProgram(connection, author, tweet);
}


main()
  .then(() => {
    console.log('Finished successfully');
    process.exit(0);
  })
  .catch((error) => {
    console.log('Error:', error.message);
    console.log('Stack trace:', error.stack);
    process.exit(1);
  });

ANCHOR CODE

use anchor_lang::prelude::*;
use anchor_lang::solana_program::system_program;
use solana_program::entrypoint::ProgramResult;

declare_id!("FS1yZFS9Vjbv77rqXBk46eGUdTgUXP7esZwKxtQFW8Ku");

#[program]
pub mod solana_twitter {
    use super::*;
    pub fn send_tweet(ctx: Context<SendTweet>, title: String) -> ProgramResult {
        let tweet: &mut Account<Tweet> = &mut ctx.accounts.tweet;
        let author: &Signer = &ctx.accounts.author;
        tweet.title = title.to_string();
        Ok(())
    }
}

#[derive(Accounts)]
pub struct SendTweet<'info> {
    #[account(init, payer = author, space = 100)]
    pub tweet: Account<'info, Tweet>,
    #[account(mut)]
    pub author: Signer<'info>,
    #[account(address = system_program::ID)]
    pub system_program: AccountInfo<'info>,

    

#[account]
pub struct Tweet {
    pub author: Pubkey,
    pub title: String,
}

TERMINAL OUTPUT

Using existing keypair
Current balance is 1 SOL
New balance is 1 SOL
Error: failed to send transaction: Transaction simulation failed: Error processing Instruction 0: custom program error: 0x65
Stack trace: Error: failed to send transaction: Transaction simulation failed: Error processing Instruction 0: custom program error: 0x65

1 Answer 1

1

You might find this helpful for decoding anchor errors. Here 0x65 means 101 in decimal which translates to the error "Fallback functions not supported".

This usually happens when the instruction you're compiling from your client does not decode into any valid one in your on-chain code.

Anchor adds a method-identifier to its instruction format in addition to the "plain" Solana format. Anchor programs know to expect that identifier and how to decode it. Here since you're not using Anchor in your client, you have to uphold that contract and compute the identifier yourself.

Check here to see how that's done.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.