project-serum / sol-wallet-adapter

Other
185 stars 93 forks source link

create stake acccount #17

Open AC-devon opened 3 years ago

AC-devon commented 3 years ago

hey, i wonder how to create stakeAccount using this wallet adapter, since the current signTransaction wallet method expect TransactionInstruction type while create stakeAccount is Transaction type, so it already signed

any ideas?

jstarry commented 3 years ago

I'm pretty sure that signTransaction expects a Transaction, not TransactionInstruction. You can create a Transaction with new Transaction().add(instruction)

AC-devon commented 3 years ago

yea, sorry my bad. i just notes that StakeProgram.createAccount return Transaction and SystemProgram.transfer return TransactionInstruction so I got confused.

anyway...it seems that sign transaction still not working for create stake account: here's the code: image

this: const signed = await wallet.signTransaction(transaction); return error: Signature verification failed at Transaction.serialize

jstarry commented 3 years ago

I believe this is due to a mismatch of @solana/web3.js versions. Try using the web3 version that the adapter is using:

"@solana/web3.js": "^0.70.3",
AC-devon commented 3 years ago

unfortunately it didnt to the trick =/ here with relative code for 0.70.3ver image

Sotatek-HungNgo3 commented 3 years ago

Hi, I have the same problem. Any idea to fix this issue? Thanks a lot

jstarry commented 2 years ago

Hi, I have the same problem. Any idea to fix this issue? Thanks a lot

@Sotatek-HungNgo3 which problem are you hitting?

jstarry commented 2 years ago

The @solana/web3.js dependency for this adapter has been updated so I recommend updating everything to latest

yangli-io commented 2 years ago

The above code was getting a Signature verification failed which probably means there is something wrong signing the message.

On a closer inspection of what the code is doing, it looks like it's trying to created a new Stake account using the wallet account to pay for it. So here we are dealing with two accounts, the new Stake account and our wallet account hence we need to sign with both accounts. But it looks like only the wallet is signing the tx here.

I think adding these lines after line 85 should fix it, I haven't tried but let me know

// After line 85
transaction.feePayer = wallet.publicKey; // Specify Fee payer
transaction.partialSign(newStakeAccount);
Patelravi8585 commented 2 years ago

is code for staking running now ?