Generate Sign and Submit Transaction

Once an application is connected to Martian wallet via connect method, an app can generate and submit the transaction using window.martian.generateSignAndSubmitTransaction()and it will return a Promise that resolves when the request is successful and reject (throw when awaited) when the request is not valid/fails. It takes three parameter listed below

  • sender: Aptos Address of the owner

  • payload: function: EntryFunctionId; type_arguments: Array; arguments: Array;

  • options?: It allow to overwrite default transaction options.

// Default transaction Options
{
   sender: senderAddress.hex(),
   sequence_number: account.sequence_number,
   max_gas_amount: "1000",
   gas_unit_price: "1",
   gas_currency_code: "XUS",
   // Unix timestamp, in seconds + 10 seconds
   expiration_timestamp_secs: (Math.floor(Date.now() / 1000) + 10).toString(),
 }

Below is an example code describing the way to generate a transaction.

// Generate a transaction
const response = await window.martian.connect();
const sender = response.address;
const payload = {
    function: "0x1::coin::transfer",
    type_arguments: ["0x1::aptos_coin::AptosCoin"],
    arguments: ["0x96da8990a7230a82250e85d943ca95e2e9319e5558b0f544f2d7a6aad327e46f", 50]
};
const transactionHash = await window.martian.generateSignAndSubmitTransaction(sender, payload);

Last updated