I am trying to stake from my wallet to a stake account which is created through this.stakeAccount = web3.Keypair.generate();

Now i am facing error while delegation, it says "SendTransactionError: failed to send transaction: Transaction simulation failed: Error processing Instruction 0: Invalid account owner". I have also craeted mint account under wallet address.

code https://solanacookbook.com/references/staking.html#withdraw-stake

  • can you share your code? Commented Jan 9, 2023 at 12:02

3 Answers 3


Here, web.Keypair.generate only returns a public and keypair corresponding to a system account(which you can think of as sort of the blank slate on which other kinds of accounts are built). You'd have to give instructions to convert this account to a stake account.

The error gives a hint of the issue here, albeit in an unclear way. The delegate instruction expects the account given to it to be a stake account owned by the stake program but instead gets a blank account owned by the system program.

Here's example code to show initialization of a stake account, and delegation:

export const initializeStakeAccount = async (
  stakeAccount: Keypair,
  lamports: BN
) => {
// Required fields for initialization, we set the authorities for the 
// stake account
  const authorized = {
    staker: client.provider.publicKey,
    withdrawer: client.provider.publicKey,

  const createParams = {
    fromPubkey: client.provider.publicKey,
    stakePubkey: stakeAccount.publicKey,
    lamports: lamports.toNumber(),

// Actually creating a stake account from our system account
  const createIx = StakeProgram.createAccount(createParams);

  await client.provider.sendAndConfirm(new Transaction().add(createIx), [

// Getting the address of the validator we're delegating to. It's
// derived in this way because this sample is from a localnet test.
  const voteKeypair = getKeypair(
  const votePubkey = voteKeypair.publicKey;

  const delegateParams = {
    stakePubkey: stakeAccount.publicKey,
    authorizedPubkey: client.provider.publicKey,

  const delegateIx = StakeProgram.delegate(delegateParams);
  await client.provider.sendAndConfirm(new Transaction().add(delegateIx), []);


You did not share any code, but it sounds like you have not "registered" the generated Keypair address with the Solana blockchain.

You can always generate new random keypairs, but until you send a transaction to the solana blockchain to allocate that account address on chain (paying account rent for the space) the keypairs public address is not actually known to the blockchain.


you did not share your code but since you shared docs about withdraw-stake, I am assuming you are withdrawing funds. when you withdraw funds from an account, the wallet address that created that account can withdraw funds. So you should connect to the address that you created the account.

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.