michaelhly / solana-py

Solana Python SDK
https://michaelhly.github.io/solana-py
MIT License
979 stars 252 forks source link

SignerError: not enough signers #426

Open rust-master opened 4 months ago

rust-master commented 4 months ago
async with AsyncClient('https://api.mainnet-beta.solana.com') as client:
    connected = await client.is_connected()
    token_client = AsyncToken(conn=client, pubkey=token_mint_address, program_id=TOKEN_PROGRAM_ID, payer=wallet_keypair)
    token_account_address = get_associated_token_address(
        wallet_keypair.pubkey(),
        token_mint_address
    )

    blockhash = await client.get_latest_blockhash()

    create_account_ix = spl_token.initialize_account( InitializeAccountParams(
        mint=token_mint_address,
        program_id=TOKEN_PROGRAM_ID,
        owner=wallet_pubkey,
        account=token_account_address
    )
    )
    txn = Transaction(fee_payer=wallet_pubkey, recent_blockhash=blockhash.value.blockhash)
    txn.add(
        sp.create_account(
            sp.CreateAccountParams(
                from_pubkey=wallet_pubkey,
                to_pubkey=token_account_address,
                lamports= await token_client.get_min_balance_rent_for_exempt_for_account(
                    client
                ),
                space=2*ACCOUNT_LAYOUT.sizeof(),
                owner=wallet_pubkey,
            ),
        )
    )
    txn.add(create_account_ix)
    txn.sign(wallet_keypair)
    await client.send_transaction(txn)

SignerError Traceback (most recent call last) in <cell line: 108>() 106 print("Swap transaction signatures:", swap_tx_signatures) 107 --> 108 await execute_swap()

2 frames /usr/local/lib/python3.10/dist-packages/solana/transaction.py in sign(self, *signers) 237 The Transaction must be assigned a valid recent_blockhash before invoking this method. 238 """ --> 239 self._solders.sign(signers, self._solders.message.recent_blockhash) 240 241 def add_signature(self, pubkey: Pubkey, signature: Signature) -> None:

SignerError: not enough signers

AceSen commented 3 months ago

i meet the same problem

Beardev118 commented 1 month ago

Me too.

michaelhly commented 1 month ago

Same as #268. To be addressed in https://github.com/michaelhly/solana-py/pull/442