NEWTON

NEWTON


Popular tags

    StarknetPy Error in get_balance_sync (StarknetErrorCode.ENTRY_POINT_NOT_FOUND_IN_CONTRACT)

    Asked

    1 month ago

    14

    views


    0

    I try to execute a code with get_balance_sync method: get_balance_sync Cairo StarknetPy code sample

    However, I got this error:

    starknet_py.net.client_errors.ClientError: Client failed with code 500: {"code": "StarknetErrorCode.ENTRY_POINT_NOT_FOUND_IN_CONTRACT", "message": "Error at pc=0:10:\nGot an exception while executing a hint.\nCairo traceback (most recent call last):\nUnknown location (pc=0:228)\nUnknown location (pc=0:214)\n\nError in the called contract (0x7f81ea93daf9c49494e3131b95646c3a8df5d97d151cc6484d49eaebe3e3d0a):\nEntry point 0x2e4263afad30923c891518314c3c95dbe830a16874e8abc5777a9a20b54c76e not found in contract with class hash 0x3ae692aaf1ded26a0b58cf42490f757563850acea887ed57b4894fee8279063."}
    

    Can you help me to resolve this?

      starknetpycairo

    Newton

    asked

    1 month ago


    1 answers

    0

    Accepted answer

    This error means that the function you tried to call does not exist in the contract (AccountClient.get_balance() takes token_address as optional input, and calls "balanceOf" function on the contract deployed at token_address).

    Your code is almost correct, except for the last part, where you specify token_address in call_result = account_client_testnet.get_balance_sync()

    So, the full code for getting the balance of an account should be:

    account = AccountClient(
        client=GatewayClient(net="mainnet"),
        address="0x07f81ea93daf9c49494e3131b95646c3a8df5d97d151cc6484d49eaebe3e3d0a",
        key_pair=KeyPair(private_key=123, public_key=456),
        chain=StarknetChainId.MAINNET,
    )
    balance = account.get_balance_sync()
    

    Newton

    answered

    1 month ago

    Your answer

    NEWTON

    NEWTON