Skip to main content

Search transactions

In this guide, you will learn how to retrieve information from a ledger using the MARCO API.

Prerequisites

Before you start, complete the following prerequisites:

Search actions by wallet ID

To get all the actions where a wallet was involved either as a sender or a receiver, send a GET request to the Search by wallet ID endpoint as follows:

curl --location --request GET 'https://api-marco.finboot.com/v1/ledger-ops/search/wallets/<WALLET_ID>/actions' \
--header 'ApplicationToken: <APPLICATION_TOKEN>' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer <ACCESS_TOKEN>'

Replace:

  • WALLET_ID: The resource ID of the wallet involved in the action. For example, WAL-62EPFgDCGOM. Note that the service account making the request must have access to this wallet. For more information, see Authorize wallet access to the service account.
  • APPLICATION_TOKEN: The marpp token. For guidance on obtaining this token, see the Quickstart guide.
  • ACCESS_TOKEN: The access token. For guidance on obtaining this token, see the Quickstart guide.
note

The endpoint allows you to apply filters to refine the results. For example, you can filter by intent. For more information, see the complete API reference.

You will receive a paginated response similar to the following:

{
"contentType": "ActionPage",
"pageElements": 200,
"pageNumber": null,
"totalElements": 2,
"totalPages": 1,
"pageContent": [
{
"actionId": "0d5081c2-d4c1-4612-958c-606ffd987e26",
"contractAddress": "0x20436c76F39098c12DBCE07aDFE7700824Df4614",
"dateUpdated": "Fri May 19 15:41:39 UTC 2023",
"dependencies": [],
"intent": "5ff541af-a2be-49c7-b345-b7ea048b231a",
"ledgerId": "finboot-clique-v1",
"locator": "0x211de19d275464a4e0f5b622f2b0d7b5c1232d625182b5a4609a94143c473a7f",
"status": "SUCCEEDED",
"walletId": "WAL-62EPFgDCGOM"
},
{
"actionId": "ac4d8d94-86e9-48b3-a8f1-12fad3b8e1d3",
"contractAddress": null,
"dateUpdated": "Fri May 19 16:37:11 UTC 2023",
"intent": "",
"ledgerId": null,
"locator": null,
"status": "pending",
"walletId": "WAL-62EPFgDCGOM"
},
]
}

Get action details

To get the details of an action by its action ID, send a GET request to the Find by action ID endpoint as follows:

curl --location --request GET 'https://api-marco.finboot.com/v1/ledger-ops/search/actions/<ACTION_ID>' \
--header 'ApplicationToken: <APPLICATION_TOKEN>' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer <ACCESS_TOKEN>'

Replace:

  • ACTION_ID: The ID of the action to query. For example ac4d8d94-86e9-48b3-a8f1-12fad3b8e1d3.
  • APPLICATION_TOKEN: The marpp token. For guidance on obtaining this token, see the Quickstart guide.
  • ACCESS_TOKEN: The access token. For guidance on obtaining this token, see the Quickstart guide.

You will receive a response similar to the following:

{
"actionId": "a6a9d972-a8ac-47f1-bd91-b00de153ce2d",
"dateUpdated": "Tue May 23 11:00:55 UTC 2023",
"dependencies": [],
"intent": "cb46cca9-774b-4537-b33b-2f29864d54a8",
"ledgerId": "finboot-clique-v1",
"locator": "0x5ecd1176e5786999ac730210d7d32658304f3ac14294f9a0e59ea1c6de245ccc",
"status": "succeeded",
"txId": "0x5ecd1176e5786999ac730210d7d32658304f3ac14294f9a0e59ea1c6de245ccc",
"walletId": "WAL-62EPFgDCGOM"
}

If status is set to succeeded, this means the action has received at least one confirmation from the ledger.

note

For additional endpoints to query the ledger, refer to the LedgerOps API Reference.

Fetch transaction details

To dive deeper into the specifics of a transaction, use a native library compatible with the network's underlying ledger.

If you are working with Ethereum-based networks, one such powerful library is web3.js. It provides an interface for interacting with the Ethereum blockchain, enabling tasks like reading the contract state and fetching transaction details.

Here is how you can retrieve information about a specific transaction using web3.js and JavaScript:

const Web3 = require('web3');

//Replace with your Ethereum node URL.
const web3 = new Web3('http://localhost:8545');

// Replace with the transaction ID you want to retrieve.
const txId = "0x5ecd1176e5786999ac730210d7d32658304f3ac14294f9a0e59ea1c6de245ccc";

web3.eth.getTransaction(txId).then(transaction => {
console.log(transaction);
});

By fetching a transaction's details, you can get the following information:

  • The transaction sender and recipient addresses.
  • The number of tokens transferred.
  • The amount of gas used and price.
  • The block number and hash.
  • The input data, such as methods called and their arguments.
note

For more information about how to get started with web3 and other available methods, see web3.js documentation.