I am currently trying to learn on writing programs for Solana and interacting with those.
I am using the example-helloworld code. In order to interact with the helloworld program, the nodejs code creates an account with seed:
const transaction = new Transaction().add(
SystemProgram.createAccountWithSeed({
fromPubkey: payer.publicKey,
basePubkey: payer.publicKey,
seed: GREETING_SEED,
newAccountPubkey: greetedPubkey,
lamports,
space: GREETING_SIZE,
programId,
})
)
tx = client.send_transaction(transaction, payer)
My understanding is, that it creates a data account, owned by the program with the programId
. Not sure why with seed yet.
I tried to replace this piece of code with the following:
const transaction = new Transaction().add(
SystemProgram.createAccount({
fromPubkey: payer.publicKey,
newAccountPubkey: greetedPubkey,
lamports,
space: GREETING_SIZE,
programId,
})
)
tx = client.send_transaction(transaction, payer)
but it is not working. Once the transaction is send, I get the following error:
{'code': -32602, 'message': 'invalid transaction: Transaction failed to sanitize accounts offsets correctly'}
Anyone who can explain the difference and what I am doing wrong??