michaelhly / solana-py

Solana Python SDK

Home Page:https://michaelhly.github.io/solana-py

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SignerError: not enough signers

rust-master opened this issue · comments

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

commented

i meet the same problem

Me too.

Same as #268. To be addressed in #442