简体   繁体   中英

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

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)

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. Here's a test that does it: 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. 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM