Python alternative to Anchorpy for interacting with Anchor v0.30.1 programs

I want to interact with a Solana contract that was built and deployed using Anchor v0.30.1.

The anchorpy package offers a very clean API for interacting with anchor programs without manually passing all the accounts. However, the latest version of anchorpy is incompatible with Anchor programs built with v0.30.1.

I am looking for a solution that would let me send transactions to solana with a similar api that the anchorpy framework allows with older versions.

For instance, take this instruction

    { 
      "name": "add_agent",
      "discriminator": [ 214, 206, 14, 110, 178, 131, 218, 45 ],
      "accounts": [ 
        { "name": "signer", "writable": true, "signer": true },
        { "name": "new_agent_account", "writable": true, "pda": { "seeds": [ { "kind": "const", "value": [ 97, 103, 101, 110, 116 ] }, { "kind": "arg", "path": "agent" } ] } },
        { "name": "agent_account", "pda": { "seeds": [ { "kind": "const", "value": [ 97, 103, 101, 110, 116 ] }, { "kind": "account", "path": "signer" } ] } },
        { "name": "system_program", "address": "11111111111111111111111111111111" },
        { "name": "event_authority", "pda": { "seeds": [ { "kind": "const", "value": [ 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, 105, 116, 121 ] } ] } },
        { "name": "program" } 
      ],
      "args": [
        { "name": "agent", "type": "pubkey" }
      ]
    },

With anchorpy, I wouldn’t need to manually specify all the accounts and seeds for PDAs. The framework automatically derives them based on the IDL.

    client = AsyncClient(rpc_url)
    keypair = Keypair.from_base58_string(sender_private_key)
    wallet = Wallet(keypair)
    provider = Provider(client, wallet)

    program_id = Pubkey.from_string(program_address)
    program = await Program.at(program_id, provider)

    program.methods.addAgent(agent.publicKey).transaction();

    await program.close()

I’m looking for a Python library or approach that:

  1. Supports Anchor programs built with v0.30.1.
  2. Simplifies the process of interacting with Solana programs, preferably with an API similar to anchorpy.

What options do I have to achieve this? Are there any alternative tools or frameworks I should consider?

Related Articles

Responses

Your email address will not be published. Required fields are marked *