3

I am new to solana development working through the playground hello world tutorial.

What is the right hash needed for "solana confirm -v <Transaction_hash>"?

I have built and deployed the hello world program in the browser playground and am trying to confirm the transactions. I have tried using hash from txhash below and the latest block hash (blockhashinfo) but both return a "Parse error: Bad parameter: Invalid signature". Would love some guidance on what I should be entering.

Thanks for the help on a neub question!

Program here:

// Client code...

console.log("programID: ", pg.PROGRAM_ID.toString());


//Get the latest blockhash info
const blockhashInfo = await pg.connection.getLatestBlockhash();


//create transaction
const tx = new web3.Transaction({
  ...blockhashInfo,
});

//Add hello world program

tx.add(
  new web3.TransactionInstruction({
    programId: pg.PROGRAM_ID,
    keys: [],
    data: Buffer.from([]),
  })
);

// sign transaction
tx.sign(pg.wallet.keypair); 

//send the transaction to solana network
const txHash = await pg.connection.sendRawTransaction(tx.serialize());
console.log("transaction sent with hash:", txHash);

1 Answer 1

4

Just type 'run' in the terminal in playground. Then you should see in the terminal on the bottom your transaction signature.

You can then paste the hash from the terminal on the bottom into

https://explorer.solana.com/?cluster=devnet

to see the transaction.

You can confirm the transaction in playground like this in the js client:

var result = await pg.connection.confirmTransaction(txHash);
console.log("confirm:", txHash);

You dont really need to do that though. You can also directly put the txHash (aka signature) in the the solana explorer and you should see your transaction.

This is how you program should look like:

// Imports we need
use solana_program::{
    account_info::AccountInfo, entrypoint, entrypoint::ProgramResult, msg, pubkey::Pubkey,
};

entrypoint!(process_instruction);

pub fn process_instruction(
    program_id: &Pubkey,
    accounts: &[AccountInfo],
    instruction_data: &[u8],
) -> ProgramResult {
    msg!("Hello, World!");
    Ok(())
}
2
  • 1
    Thank you! This helped and I got to see my transaction on the devnet :)
    – user8001
    Commented Jan 14 at 3:43
  • @user8001 considering this worked, would you mind accepting the answer? Thanks!
    – beeman
    Commented Jan 14 at 4:37

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.