NEWTON

NEWTON


Popular tags

    How to get the contract ABI using Starknet.Py?

    Asked

    1 month ago

    32

    views


    0

    Hey! I have a contract deployed on Testnet. Let's say its address is 0x1234.

    I want to get its ABI somehow, but I don't have the code of the contract, because it wasn't deployed by me.

    I'm using StarkNet.py to interact with StarkNet.

    Does anyone know the answer?

      abistarknetpystarknet_pystarknetpython

    0xa483...6765fa

    asked

    1 month ago


    1 answers

    1

    Accepted answer

    Hey, to get the contract ABI using StarkNet.py just use the Client's get_class_by_hash method.

    However, it requires you to know the contract's class_hash. If you don't know it you will have to use a second method to get it.

    Here is a short example of how to get an ABI of your contract.

    client = GatewayClient(net="some_net")
    address = 0x1234
    
    class_hash = await client.get_class_hash_at(contract_address=address)
    abi = (await client.get_class_by_hash(class_hash=class_hash)).abi
    

    You can also go to starkscan.co and see class details. ABI is included there. Example: OpenZeppelin Universal Deployer

    war-in

    answered

    1 month ago

    Your answer

    NEWTON

    NEWTON