[英]Falling into issues Trying to Create a Program Derived Address (PDA) with Solana-py: "not enough values to unpack (expected 2, got 1)"
params = system_program.CreateAccountWithSeedParams(
base_pubkey = keypair.public_key,
from_pubkey = keypair.public_key,
lamports = 200,
new_account_pubkey = greeted,
program_id = program_id,
seed = 'hello',
space = 8
)
I am Getting the output我正在获取 output
CreateAccountWithSeedParams(from_pubkey=2ASw3tjK5bSxQxFEMsM6J3DnBozNh7drVErSwc7AtzJv, new_account_pubkey=BkuEamVXuHugbAAVurExanW1FGAejsEAa7hECYsP1j6o, base_pubkey=2ASw3tjK5bSxQxFEMsM6J3DnBozNh7drVErSwc7AtzJv, seed='hello', lamports=200, space=8, program_id=TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA)
CreateAccountWithSeedParams(from_pubkey=2ASw3tjK5bSxQxFEMsM6J3DnBozNh7drVErSwc7AtzJv, new_account_pubkey=BkuEamVXuHugbAAVurExanW1FGAejsEAa7hECYsP1j6o, base_pubkey=2ASw3tjK5bSxQxFEMsM6J3DnBozNh7drVErSwc7AtzJv, seed='hello', lamports=200, space=8, program_id=TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA)
The problem then comes when I use当我使用时,问题就来了
transaction_Params = system_program.create_account_with_seed(params)
I get the long slew of errors, whose long story cut short is: not enough values to unpack (expected 2, got 1)我得到了一长串的错误,长话短说:没有足够的值来解包(预期 2,得到 1)
Any Help will be more than Cherished and Appreciated, but will also get a significant amount of Thankful cheers任何帮助都将不仅仅是珍惜和赞赏,而且还会得到大量的感谢欢呼
It looks like the seed
provided should actually be a dict that serializes directly to a Rust string.看起来提供的
seed
实际上应该是一个直接序列化为 Rust 字符串的字典。 Here's a test that does it: https://github.com/michaelhly/solana-py/blob/b507d4dfe16cdaccc754b1f2bac5ed9e258ea039/tests/unit/test_system_program.py#L64这是一个测试: https://github.com/michaelhly/solana-py/blob/b507d4dfe16cdaccc754b1f2bac5ed9e258ea039/tests/unit/test_system_program.py#L64
Separately, if you're trying to create a program-derived address, you'll actually need to create it from within a program, using invoke_signed
in your program.另外,如果您尝试创建程序派生地址,您实际上需要在程序中使用
invoke_signed
在程序中创建它。 It is not possible to create a program-derived address from the outside, because you need the program to "sign" for the program-derived address.无法从外部创建程序派生地址,因为您需要程序为程序派生地址“签名”。 See the differences between https://solanacookbook.com/recipes/accounts.html#program-derived-address and https://solanacookbook.com/recipes/accounts.html#create-account-with-seed
请参阅https://solanacookbook.com/recipes/accounts.html#program-derived-address和https://solanacookbook.com/recipes/accounts.html#create-account-with-seed之间的区别
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.