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

Get Transactions

PreviousGet TransactionNextGet Account Transactions

Last updated 2 years ago

Once an application is connected to Martian wallet via method, an app can fetch a transactions using window.martian.getTransactions()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 one optional parameter listed below

  • query?: {start?: number, limit?: number}

    • query.start The start transaction version of the page. Default is the latest ledger version

    • query.limit The max number of transactions should be returned for the page. Default is 25

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

// Fetch blockchain transactions
const transactions = await window.martian.getTransactions()
// above code output
// https://fullnode.devnet.aptoslabs.com/transactions
[
    {
        "type": "state_checkpoint_transaction",
        "version": "3801259",
        "hash": "0xe1b55d299a4925dc15cca45853c1c7ce69ad450006a1c0e183aaa6b227b3a3ab",
        "state_root_hash": "0x361b522c30b531419053ccf47049c3792f1a50b8e3fb6ad3f855c2b9289912c0",
        "event_root_hash": "0x414343554d554c41544f525f504c414345484f4c4445525f4841534800000000",
        "gas_used": "0",
        "success": true,
        "vm_status": "Executed successfully",
        "accumulator_root_hash": "0xac7e0e8abc93d9287ba2145f596f25a80b6a0daa78eeb2a201a5d30cc16c13d5",
        "changes": [],
        "timestamp": "1658817506725410"
    },
    ...
]
// Fetch blockchain transactions
const query = {
    start: 380128,
    limit: 2
}
const transactions = await window.martian.getTransactions(query)
// above code output
//  https://fullnode.devnet.aptoslabs.com/transactions?start=380128&limit=2
[
    {
        "type": "state_checkpoint_transaction",
        "version": "380128",
        "hash": "0x57a800f9e898b36e2365ae3c4ad7c0d164a02087293b59d2923bab0c6edb4d3a",
        "state_root_hash": "0x361b522c30b531419053ccf47049c3792f1a50b8e3fb6ad3f855c2b9289912c0",
        "event_root_hash": "0x414343554d554c41544f525f504c414345484f4c4445525f4841534800000000",
        "gas_used": "0",
        "success": true,
        "vm_status": "Executed successfully",
        "accumulator_root_hash": "0x8b64da56d1d79f4554b278988f56684ce85b818f5f830477e0fd9586721ff42f",
        "changes": [],
        "timestamp": "1658482861807578"
    },
    {
        "type": "block_metadata_transaction",
        "version": "380129",
        "hash": "0x5a86e5dfbdfc318a072ca0daf8356d35b0639d8382a4e72d62bf3000e7c28eb7",
        "state_root_hash": "0x5660ed86b83ece8f7d542db5982edf23a1bfe7a15e2930f6a3ddc12c691c6539",
        "event_root_hash": "0x2788d95f9e8fbe4964657e68ede1e575f104d9187b942783dc0edf0811f4ba20",
        "gas_used": "0",
        "success": true,
        "vm_status": "Executed successfully",
        "accumulator_root_hash": "0x2c98ea0df4dd521c91157ae3acc43d46f3d21103f8979bdfcfaeaab13e0bcff4",
        "changes": [
            {
                "type": "write_resource",
                "address": "0x1",
                "state_key_hash": "0xeac3bb50beedae400e2fcb24b4911cbaf61645d56eaa4a213e8354646ed7bbe2",
                "data": {
                    "type": "0x1::block::BlockMetadata",
                    "data": {
                        "epoch_internal": "86400000000",
                        "height": "173062",
                        "new_block_events": {
                            "counter": "173062",
                            "guid": {
                                "id": {
                                    "addr": "0x1",
                                    "creation_num": "3"
                                }
                            }
                        }
                    }
                }
            },
            {
                "type": "write_resource",
                "address": "0x1",
                "state_key_hash": "0x8048c954221814b04533a9f0a9946c3a8d472ac62df5accb9f47c097e256e8b6",
                "data": {
                    "type": "0x1::stake::ValidatorPerformance",
                    "data": {
                        "missed_votes": [
                            "130531",
                            "120936",
                            "40625",
                            "20738",
                            "17794",
                            "33950",
                            "19947",
                            "22816",
                            "118144",
                            "107198",
                            "120537",
                            "121647",
                            "20544",
                            "18644",
                            "17680",
                            "13865",
                            "21581",
                            "123773",
                            "117813",
                            "32915",
                            "31674",
                            "28480",
                            "30280",
                            "35673",
                            "16720"
                        ],
                        "num_blocks": "173061"
                    }
                }
            },
            {
                "type": "write_resource",
                "address": "0x1",
                "state_key_hash": "0x7b1615bf012d3c94223f3f76287ee2f7bdf31d364071128b256aeff0841b626d",
                "data": {
                    "type": "0x1::timestamp::CurrentTimeMicroseconds",
                    "data": {
                        "microseconds": "1658482862018771"
                    }
                }
            }
        ],
        "id": "0xcc884929315c1f392627eb1b3dfda50c45a7effd24d1495577cc2eae70e8af09",
        "epoch": "2",
        "round": "173063",
        "events": [
            {
                "key": "0x03000000000000000000000000000000000000000000000000000000000000000000000000000001",
                "sequence_number": "173061",
                "type": "0x1::block::NewBlockEvent",
                "data": {
                    "epoch": "2",
                    "failed_proposer_indices": [],
                    "previous_block_votes": [
                        true,
                        true,
                        true,
                        true,
                        true,
                        true,
                        false,
                        true,
                        false,
                        false,
                        true,
                        false,
                        false,
                        true,
                        true,
                        true,
                        true,
                        false,
                        false,
                        true,
                        true,
                        true,
                        false,
                        true,
                        true
                    ],
                    "proposer": "0xca9a87a329135ab0af3ba020e1abd2eb28a0ae8f13600d33117bffe5afab7055",
                    "round": "173063",
                    "time_microseconds": "1658482862018771"
                }
            }
        ],
        "previous_block_votes": [
            true,
            true,
            true,
            true,
            true,
            true,
            false,
            true,
            false,
            false,
            true,
            false,
            false,
            true,
            true,
            true,
            true,
            false,
            false,
            true,
            true,
            true,
            false,
            true,
            true
        ],
        "proposer": "0xca9a87a329135ab0af3ba020e1abd2eb28a0ae8f13600d33117bffe5afab7055",
        "failed_proposer_indices": [],
        "timestamp": "1658482862018771"
    }
]
⚙️
Promise
connect