Submit Transaction

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

  • signedTxn, signed transaction string can be obtained from signTransaction method.

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

// Create 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: ["0x997b38d2127711011462bc42e788a537eae77806404769188f20d3dc46d72750", 50]
};
const transaction = await window.martian.generateTransaction(sender, payload);
const signedTxn = await window.martian.signTransaction(transaction);
const txnHash = await window.martian.submitTransaction(signedTxn);

Last updated