我目前正在努力学习如何为Solana编写程序并与这些程序进行交互。
我正在使用例子-helloworld代码。为了与helloworld程序进行交互,nodejs代码创建了一个带有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)
我的理解是,它创建了一个数据帐户,由programId
程序拥有。还不确定为什么有种子。
我试图用以下代码替换这段代码:
const transaction = new Transaction().add(
SystemProgram.createAccount({
fromPubkey: payer.publicKey,
newAccountPubkey: greetedPubkey,
lamports,
space: GREETING_SIZE,
programId,
})
)
tx = client.send_transaction(transaction, payer)
但这是行不通的。一旦事务发送,我将得到以下错误:
{'code': -32602, 'message': 'invalid transaction: Transaction failed to sanitize accounts offsets correctly'}
有人能解释我做错了什么吗??
https://stackoverflow.com/questions/71615654
复制相似问题