Sign Transaction

Once an application is connected to Martian wallet via connect method, an app can request the user to sign a transaction using window.martian.signTransaction()and it will return a Promise that resolves when the user accepts the request and reject (throw when awaited) when the user declines the request or request is not valid/fails. It takes one parameter listed below

  • Aptos RawTransaction serialized string

Below is an example code describing the way to sign 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: ["0x96da8990a7230a82250e85d943ca95e2e9319e5558b0f544f2d7a6aad327e46f", 50]
};
const transaction = await window.martian.generateTransaction(sender, payload);
const signedTxn = await window.martian.signTransaction(transaction);

Last updated