how to pass arguments when submitting an aptos transaction

88 views Asked by At

In Python, an aptos transaction payload is like this:

payload = EntryFunction.natural(
        module,
        function,
        [TypeTag(StructTag.from_str(type_arguments))],
        [
         (some TransactionArguments)
        ]
)

In order to call the below entry function:

sell_instantly_token_v2<T0>(&signer, 0x1::object::Object<0x...::collection_offer::CollectionOffer>, 0x1::object::Object<0x4::token::Token>, 0x1::option::Option<0x1::object::Object<0x...::listing::Listing>>)

In Aptos Explorer, an aptos tx payload is like this:

arguments: [
  {
    "inner": "0x..."
  },
  {
    "inner": "0x..."
  },
  {
    "vec": []
  }
]

how should I properly serialize arguments of type 0x1::object::Object and 0x1::option::Option?

I tried serialize with Serialize.map, but something went wrong, maybe I'm passing the arguments incorrectly

1

There are 1 answers

0
Roy.S On

try using submit_transaction with raw payload.

aptos-rest-api

account = Account.load_key("xxxxxx")  
payload = {
        "type": "entry_function_payload",
        "function": "some func",
        "type_arguments": ["0x1::aptos_coin::AptosCoin"],
        "arguments": [
            "arg1",
            "arg2"
        ],
    }
tx_hash = await rest_client.submit_transaction(account, payload)
print(tx_hash)
await rest_client.wait_for_transaction(tx_hash)