> For the complete documentation index, see [llms.txt](https://signum-network.gitbook.io/signumjs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://signum-network.gitbook.io/signumjs/recipes/basics/list-transactions.md).

# List Transactions

In the basic examples we still show how to use SignumJS depending the way you are using SignumJS, i.e. imported via NodeJS package manager or as minified bundle. In case you haven't read about the module system, take a quick look there:

{% content-ref url="/pages/5LpyrKz8NZepdbWjzEW9" %}
[Modules](/signumjs/getting-started/modules.md)
{% endcontent-ref %}

{% hint style="info" %}
A fully working example is available [here](https://github.com/signum-network/signumjs/blob/main/examples/nodejs/basic/listTransactions.js)
{% endhint %}

Following functions from SignumJS are used in this example&#x20;

* [composeApi](https://signum-network.github.io/signumjs/modules/core_api.html#composeapi) function to create the api instance
* [api.account.getAccountTransactions](https://signum-network.github.io/signumjs/interfaces/core_api.accountapi.html#getaccounttransactions) function to fetch the transactions from the blockchain
* [Address](https://signum-network.github.io/signumjs/classes/core.address.html) Value Object to parse and convert the given address&#x20;
* [Amount](https://signum-network.github.io/signumjs/classes/util.amount.html) Value Object to convert between Planck and Signa
* [ChainTime](https://signum-network.github.io/signumjs/classes/util.chaintime.html) Value Object to convert between blockchain timestamp and real date

{% tabs %}
{% tab title="Javascript" %}

```javascript
const {Address} = require("@signumjs/core");
const {Amount, ChainTime} = require("@signumjs/util");

// Create the Api instance to connect to a blockchain node
const api = composeApi({
    nodeHost: "https://europe.signum.network"
});

async function listTransactions(account) {
    // All API calls are asynchronous
    // The recommended pattern is using async/await
    // This makes exception handling easy using try/catch
    try {      
        // we check if incoming account is either a Signum Address, or Numeric Id
        // eventually, we convert to Numeric Id
        const accountId = Address.create(account).getNumericId()

        // Now, we call the getAccountTransactions method,
        // but we want only the 100 most recent transactions, 
        // *not* including multi-out
        const {transactions} = await api.account.getAccountTransactions(
            {
                firstIndex: 0,
                lastIndex: 100,
                includeIndirect: true,
                accountId,
            }
        );

        // now we map the fields we want to print as a table to console then
        // NOTE: for sake of simplicity we do not filter out the multi payments
        const mappedTransactions = transactions.map(t => {
            const hasReceived = t.sender !== accountId
            return {
                date: ChainTime.fromChainTimestamp(t.timestamp).getDate(),
                account: hasReceived ? t.senderRS : t.recipientRS || 'SELF',
                value: `${hasReceived ? '+' : '-'} ${Amount.fromPlanck(t.amountNQT).toString()}`, // convert from Planck value to Signa
                fee: Amount.fromPlanck(t.feeNQT).toString()
            }
        });

        console.table(mappedTransactions, ['date', 'value', 'fee', 'account'])
    } catch (e) {
        console.error(e)
    }
}
```

{% endtab %}

{% tab title="Typescript" %}

```typescript
import {Address} from "@signumjs/core";
import {Amount, ChainTime} = from "@signumjs/util";

// Create the Api instance to connect to a blockchain node
const api = composeApi({
    nodeHost: "https://europe.signum.network"
});

async function listTransactions(account: string): Promise<void> {
    // All API calls are asynchronous
    // The recommended pattern is using async/await
    // This makes exception handling easy using try/catch
    try {
        // we check if incoming account is either a Signum Address, or Numeric Id
        // eventually, we convert to Numeric Id
        const accountId = Address.create(account).getNumericId()

        // Now, we call the getAccountTransactions method,
        // but we want only the 100 most recent transactions, 
        // *not* including multi-out
        const {transactions} = await api.account.getAccountTransactions(
            {
                firstIndex: 0,
                lastIndex: 100,
                includeIndirect: false,
                accountId,
            }
        );

        // now we map the fields we want to print as a table to console then
        // NOTE: for sake of simplicity we do not filter out the multi payments
        const mappedTransactions = transactions.map(t => {
            const hasReceived = t.sender !== accountId
            return {
                date: ChainTime.fromChainTimestamp(t.timestamp).getDate(),
                account: hasReceived ? t.senderRS : t.recipientRS || 'SELF',
                value: `${hasReceived ? '+' : '-'} ${Amount.fromPlanck(t.amountNQT).toString()}`, // convert from Planck value to Signa
                fee: Amount.fromPlanck(t.feeNQT).toString()
            }
        });

        console.table(mappedTransactions, ['date', 'value', 'fee', 'account'])
    } catch (e) {
        console.error(e)
    }
}
```

{% endtab %}

{% tab title="<script/>" %}

```javascript
// you need to have imported in your index.html:
/*
<script src='https://cdn.jsdelivr.net/npm/@signumjs/core/dist/signumjs.min.js'></script>
<script src='https://cdn.jsdelivr.net/npm/@signumjs/util/dist/signumjs.util.min.js'></script>
*/

// Create the Api instance to connect to a blockchain node
const api = sig$.composeApi({
    nodeHost: "https://europe.signum.network"
});

async function listTransactions(account) {
    // All API calls are asynchronous
    // The recommended pattern is using async/await
    // This makes exception handling easy using try/catch
    try {
        // we check if incoming account is either a Signum Address, or Numeric Id
        // eventually, we convert to Numeric Id
        const accountId = sig$.Address.create(account).getNumericId()

        // Now, we call the getAccountTransactions method,
        // but we want only the 100 most recent transactions, 
        // *not* including multi-out
        const {transactions} = await api.account.getAccountTransactions(
            {
                firstIndex: 0,
                lastIndex: 100,
                includeIndirect: true,
                accountId,
            }
        );

        // now we map the fields we want to print as a table to console then
        // NOTE: for sake of simplicity we do not filter out the multi payments
        const mappedTransactions = transactions.map(t => {
            const hasReceived = t.sender !== accountId
            return {
                date: sig$util.ChainTime.fromChainTimestamp(t.timestamp).getDate(),
                account: hasReceived ? t.senderRS : t.recipientRS || 'SELF',
                value: `${hasReceived ? '+' : '-'} ${sig$util.Amount.fromPlanck(t.amountNQT).toString()}`, // convert from Planck value to Signa
                fee: sig$util.Amount.fromPlanck(t.feeNQT).toString()
            }
        });

        console.table(mappedTransactions, ['date', 'value', 'fee', 'account'])
    } catch (e) {
        console.error(e)
    }
}
```

{% endtab %}
{% endtabs %}
