how to pass a long string to a starknet contract in python

For example, in the following transaction, https://starkscan.co/tx/0x012829d678c9b5bff701a6f2fed31744e14e736a209f61522fbc0bb65be98983, a long string

data:,{\"p\":\"stark-20\",\"op\":\"mint\",\"tick\":\"STRK\",\"amt\":\"1000\"}

is passed to the contract. I want to reproduce it with the following code:

async with aiohttp.TCPConnector(ssl=False) as tcpconnector:
    async with aiohttp.ClientSession(connector=tcpconnector,trust_env=True) as session:

        full_node_client = FullNodeClient(node_url=node_url,session=session)

        account = Account(
            client=full_node_client,
            address=address,
            key_pair=KeyPair.from_private_key(key=private_key),
            chain=StarknetChainId.MAINNET,
            )

                   
   
        call = Call(
            to_addr=0x07341189e3c96f636a4192cfba8c18deeee33a19c5d0425a26cf96ea42388c4e,
            selector=get_selector_from_name("inscribe"),
            calldata=["data:,{\"p\":\"stark-20\",\"op\":\"min","t\",\"tick\":\"STRK\",\"amt\":\"1000\"}"]
        )

        calls = [call]
        
        tx = await account.sign_invoke_transaction(
            calls=calls, max_fee=0
            )

        estimated_fee = await account.client.estimate_fee(
            tx=tx,
            )

the following error is returned:

{'jsonrpc': '2.0', 'id': 0, 'error': {'code': 40, 'data': {'revert_error': "Execution error at transaction index 0: Transaction validation has failed. Execution failed. Failure reason: 0x496e70757420746f6f206c6f6e6720666f7220617267756d656e7473 ('Input too long for arguments')."}, 'message': 'Contract error'}} 

So what is the right method to pass a long string to starknet contract?

  • data:,{\"p\":\"stark-20\",\"op\":\"mint\",\"tick\":\"STRK\",\"amt\":\"1000\"} is not valid python. are you saying that you want to create a string that looks like this ?

    – 




Leave a Comment