Martian Wallet Dev Docs
HomeChrome web store
  • Introduction
  • 🏗️Integration
    • Detecting the Provider
    • Establishing a Connection
    • Displaying Your App
  • ⚙️methods
    • Aptos
      • Generate Transaction
      • Sign Transaction
      • Submit Transaction
      • Sign and Submit Transaction
      • Sign Generic Transaction
      • Generate Sign and Submit Transaction
      • Create Collection
      • Create Token
      • Add Network
      • Change Network
      • Get Networks
      • Get Transaction
      • Get Transactions
      • Get Account Transactions
      • Get Account Resources
      • Get Account
      • Get Chain Id
      • Get Ledger Info
    • Sui
      • Sign Transaction Block
      • Sign and Execute Transaction
      • Get Public Key
      • Get Old Address
      • Get Accounts
    • Sign Message
    • Get Network
    • Get Current Blockchain
    • Cancel Submitted Transactions
    • Network Change Event
    • Account Change Event
Powered by GitBook
On this page
  1. methods
  2. Aptos

Generate Transaction

PreviousAptosNextSign Transaction

Last updated 2 years ago

Once an application is connected to Martian wallet via method, an app can generate a transaction request serialized byte string using window.martian.generateTransaction()and it will return a 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: "4000",
   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]
};
// example to set custom gas amount, default options are mentioned above
const options = {
    max_gas_amount: "10000"
}
const transactionRequest = await window.martian.generateTransaction(sender, payload, options);

⚙️
Promise
connect