简体   繁体   English

遇到问题尝试使用 Solana-py 创建程序派生地址 (PDA):“没有足够的值来解压(预期 2,得到 1)”

[英]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)

and full story:和完整的故事: 完整的故事

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-addresshttps://solanacookbook.com/recipes/accounts.html#create-account-with-seed之间的区别

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 没有足够的值来解包(预期 3,得到 2) - not enough values to unpack (expected 3, got 2) 没有足够的值来解包(预期 3,得到 1) - not enough values to unpack (expected 3, got 1) 没有足够的值来解包(预期为 2,得到 0) - not enough values to unpack (expected 2, got 0) (编辑)ValueError:没有足够的值要解压(预期3,得到2),尝试向其中添加if语句 - (Edit) ValueError: not enough values to unpack (expected 3, got 2), trying to add an if statement to it ValueError:没有足够的值可解包(预期2,got1) - ValueError: not enough values to unpack (expected 2, got1) ValueError:没有足够的值来解包(预期为 2,得到 0) - ValueError:not enough values to unpack (expected 2, got 0) Python:ValueError:没有足够的值来解包(预期为 3,得到 1) - Python: ValueError: not enough values to unpack (expected 3, got 1) 如何解决“没有足够的值来解压(预期2,得到1)”? - How to fix “not enough values to unpack (expected 2, got 1)”? ValueError:没有足够的值来解包(预期为 4,得到 1) - ValueError: not enough values to unpack (expected 4, got 1) ValueError:没有足够的值来解包(预期为 4,得到 3) - ValueError: not enough values to unpack (expected 4, got 3)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM