Skip to content

Latest commit

 

History

History
2251 lines (1629 loc) · 195 KB

File metadata and controls

2251 lines (1629 loc) · 195 KB

Ledger

(ledger)

Available Operations

createTransactions

Create a new batch of transactions to a ledger

Example Usage

import { SDK } from "@formance/formance-sdk";

const sdk = new SDK({
  authorization: "<YOUR_AUTHORIZATION_HERE>",
});

async function run() {
  const result = await sdk.ledger.createTransactions({
    transactions: {
      transactions: [
        {
          postings: [
            {
              amount: BigInt("100"),
              asset: "COIN",
              destination: "users:002",
              source: "users:001",
            },
          ],
          reference: "ref:001",
        },
      ],
    },
    ledger: "ledger001",
  });

  // Handle the result
  console.log(result)
}

run();

Parameters

Parameter Type Required Description
request operations.CreateTransactionsRequest ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.

Response

Promise<operations.CreateTransactionsResponse>

Errors

Error Object Status Code Content Type
errors.ErrorResponse default application/json
errors.SDKError 4xx-5xx /

addMetadataOnTransaction

Set the metadata of a transaction by its ID

Example Usage

import { SDK } from "@formance/formance-sdk";

const sdk = new SDK({
  authorization: "<YOUR_AUTHORIZATION_HERE>",
});

async function run() {
  const result = await sdk.ledger.addMetadataOnTransaction({
    ledger: "ledger001",
    txid: BigInt("1234"),
  });

  // Handle the result
  console.log(result)
}

run();

Parameters

Parameter Type Required Description
request operations.AddMetadataOnTransactionRequest ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.

Response

Promise<operations.AddMetadataOnTransactionResponse>

Errors

Error Object Status Code Content Type
errors.ErrorResponse default application/json
errors.SDKError 4xx-5xx /

addMetadataToAccount

Add metadata to an account

Example Usage

import { SDK } from "@formance/formance-sdk";

const sdk = new SDK({
  authorization: "<YOUR_AUTHORIZATION_HERE>",
});

async function run() {
  const result = await sdk.ledger.addMetadataToAccount({
    requestBody: {
      "key": "<value>",
    },
    address: "users:001",
    ledger: "ledger001",
  });

  // Handle the result
  console.log(result)
}

run();

Parameters

Parameter Type Required Description
request operations.AddMetadataToAccountRequest ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.

Response

Promise<operations.AddMetadataToAccountResponse>

Errors

Error Object Status Code Content Type
errors.ErrorResponse default application/json
errors.SDKError 4xx-5xx /

countAccounts

Count the accounts from a ledger

Example Usage

import { SDK } from "@formance/formance-sdk";

const sdk = new SDK({
  authorization: "<YOUR_AUTHORIZATION_HERE>",
});

async function run() {
  const result = await sdk.ledger.countAccounts({
    address: "users:.+",
    ledger: "ledger001",
    metadata: {
      "0": "m",
      "1": "e",
      "2": "t",
      "3": "a",
      "4": "d",
      "5": "a",
      "6": "t",
      "7": "a",
      "8": "[",
      "9": "k",
      "10": "e",
      "11": "y",
      "12": "]",
      "13": "=",
      "14": "v",
      "15": "a",
      "16": "l",
      "17": "u",
      "18": "e",
      "19": "1",
      "20": "&",
      "21": "m",
      "22": "e",
      "23": "t",
      "24": "a",
      "25": "d",
      "26": "a",
      "27": "t",
      "28": "a",
      "29": "[",
      "30": "a",
      "31": ".",
      "32": "n",
      "33": "e",
      "34": "s",
      "35": "t",
      "36": "e",
      "37": "d",
      "38": ".",
      "39": "k",
      "40": "e",
      "41": "y",
      "42": "]",
      "43": "=",
      "44": "v",
      "45": "a",
      "46": "l",
      "47": "u",
      "48": "e",
      "49": "2",
    },
  });

  // Handle the result
  console.log(result)
}

run();

Parameters

Parameter Type Required Description
request operations.CountAccountsRequest ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.

Response

Promise<operations.CountAccountsResponse>

Errors

Error Object Status Code Content Type
errors.ErrorResponse default application/json
errors.SDKError 4xx-5xx /

countTransactions

Count the transactions from a ledger

Example Usage

import { SDK } from "@formance/formance-sdk";

const sdk = new SDK({
  authorization: "<YOUR_AUTHORIZATION_HERE>",
});

async function run() {
  const result = await sdk.ledger.countTransactions({
    account: "users:001",
    destination: "users:001",
    ledger: "ledger001",
    metadata: {},
    reference: "ref:001",
    source: "users:001",
  });

  // Handle the result
  console.log(result)
}

run();

Parameters

Parameter Type Required Description
request operations.CountTransactionsRequest ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.

Response

Promise<operations.CountTransactionsResponse>

Errors

Error Object Status Code Content Type
errors.ErrorResponse default application/json
errors.SDKError 4xx-5xx /

createTransaction

Create a new transaction to a ledger

Example Usage

import { SDK } from "@formance/formance-sdk";

const sdk = new SDK({
  authorization: "<YOUR_AUTHORIZATION_HERE>",
});

async function run() {
  const result = await sdk.ledger.createTransaction({
    postTransaction: {
      postings: [
        {
          amount: BigInt("100"),
          asset: "COIN",
          destination: "users:002",
          source: "users:001",
        },
      ],
      reference: "ref:001",
      script: {
        plain: "vars {
      account $user
      }
      send [COIN 10] (
      	source = @world
      	destination = $user
      )
      ",
        vars: {
          "user": "users:042",
        },
      },
    },
    ledger: "ledger001",
    preview: true,
  });

  // Handle the result
  console.log(result)
}

run();

Parameters

Parameter Type Required Description
request operations.CreateTransactionRequest ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.

Response

Promise<operations.CreateTransactionResponse>

Errors

Error Object Status Code Content Type
errors.ErrorResponse default application/json
errors.SDKError 4xx-5xx /

getAccount

Get account by its address

Example Usage

import { SDK } from "@formance/formance-sdk";

const sdk = new SDK({
  authorization: "<YOUR_AUTHORIZATION_HERE>",
});

async function run() {
  const result = await sdk.ledger.getAccount({
    address: "users:001",
    ledger: "ledger001",
  });

  // Handle the result
  console.log(result)
}

run();

Parameters

Parameter Type Required Description
request operations.GetAccountRequest ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.

Response

Promise<operations.GetAccountResponse>

Errors

Error Object Status Code Content Type
errors.ErrorResponse default application/json
errors.SDKError 4xx-5xx /

getBalances

Get the balances from a ledger's account

Example Usage

import { SDK } from "@formance/formance-sdk";

const sdk = new SDK({
  authorization: "<YOUR_AUTHORIZATION_HERE>",
});

async function run() {
  const result = await sdk.ledger.getBalances({
    address: "users:001",
    after: "users:003",
    cursor: "aHR0cHM6Ly9nLnBhZ2UvTmVrby1SYW1lbj9zaGFyZQ==",
    ledger: "ledger001",
  });

  // Handle the result
  console.log(result)
}

run();

Parameters

Parameter Type Required Description
request operations.GetBalancesRequest ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.

Response

Promise<operations.GetBalancesResponse>

Errors

Error Object Status Code Content Type
errors.ErrorResponse default application/json
errors.SDKError 4xx-5xx /

getBalancesAggregated

Get the aggregated balances from selected accounts

Example Usage

import { SDK } from "@formance/formance-sdk";

const sdk = new SDK({
  authorization: "<YOUR_AUTHORIZATION_HERE>",
});

async function run() {
  const result = await sdk.ledger.getBalancesAggregated({
    address: "users:001",
    ledger: "ledger001",
  });

  // Handle the result
  console.log(result)
}

run();

Parameters

Parameter Type Required Description
request operations.GetBalancesAggregatedRequest ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.

Response

Promise<operations.GetBalancesAggregatedResponse>

Errors

Error Object Status Code Content Type
errors.ErrorResponse default application/json
errors.SDKError 4xx-5xx /

getInfo

Show server information

Example Usage

import { SDK } from "@formance/formance-sdk";

const sdk = new SDK({
  authorization: "<YOUR_AUTHORIZATION_HERE>",
});

async function run() {
  const result = await sdk.ledger.getInfo();

  // Handle the result
  console.log(result)
}

run();

Parameters

Parameter Type Required Description
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.

Response

Promise<operations.GetInfoResponse>

Errors

Error Object Status Code Content Type
errors.ErrorResponse default application/json
errors.SDKError 4xx-5xx /

getLedgerInfo

Get information about a ledger

Example Usage

import { SDK } from "@formance/formance-sdk";

const sdk = new SDK({
  authorization: "<YOUR_AUTHORIZATION_HERE>",
});

async function run() {
  const result = await sdk.ledger.getLedgerInfo({
    ledger: "ledger001",
  });

  // Handle the result
  console.log(result)
}

run();

Parameters

Parameter Type Required Description
request operations.GetLedgerInfoRequest ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.

Response

Promise<operations.GetLedgerInfoResponse>

Errors

Error Object Status Code Content Type
errors.ErrorResponse default application/json
errors.SDKError 4xx-5xx /

getMapping

Get the mapping of a ledger

Example Usage

import { SDK } from "@formance/formance-sdk";

const sdk = new SDK({
  authorization: "<YOUR_AUTHORIZATION_HERE>",
});

async function run() {
  const result = await sdk.ledger.getMapping({
    ledger: "ledger001",
  });

  // Handle the result
  console.log(result)
}

run();

Parameters

Parameter Type Required Description
request operations.GetMappingRequest ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.

Response

Promise<operations.GetMappingResponse>

Errors

Error Object Status Code Content Type
errors.ErrorResponse default application/json
errors.SDKError 4xx-5xx /

getTransaction

Get transaction from a ledger by its ID

Example Usage

import { SDK } from "@formance/formance-sdk";

const sdk = new SDK({
  authorization: "<YOUR_AUTHORIZATION_HERE>",
});

async function run() {
  const result = await sdk.ledger.getTransaction({
    ledger: "ledger001",
    txid: BigInt("1234"),
  });

  // Handle the result
  console.log(result)
}

run();

Parameters

Parameter Type Required Description
request operations.GetTransactionRequest ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.

Response

Promise<operations.GetTransactionResponse>

Errors

Error Object Status Code Content Type
errors.ErrorResponse default application/json
errors.SDKError 4xx-5xx /

listAccounts

List accounts from a ledger, sorted by address in descending order.

Example Usage

import { SDK } from "@formance/formance-sdk";

const sdk = new SDK({
  authorization: "<YOUR_AUTHORIZATION_HERE>",
});

async function run() {
  const result = await sdk.ledger.listAccounts({
    address: "users:.+",
    after: "users:003",
    balance: 2400,
    cursor: "aHR0cHM6Ly9nLnBhZ2UvTmVrby1SYW1lbj9zaGFyZQ==",
    ledger: "ledger001",
    metadata: {
      "0": "m",
      "1": "e",
      "2": "t",
      "3": "a",
      "4": "d",
      "5": "a",
      "6": "t",
      "7": "a",
      "8": "[",
      "9": "k",
      "10": "e",
      "11": "y",
      "12": "]",
      "13": "=",
      "14": "v",
      "15": "a",
      "16": "l",
      "17": "u",
      "18": "e",
      "19": "1",
      "20": "&",
      "21": "m",
      "22": "e",
      "23": "t",
      "24": "a",
      "25": "d",
      "26": "a",
      "27": "t",
      "28": "a",
      "29": "[",
      "30": "a",
      "31": ".",
      "32": "n",
      "33": "e",
      "34": "s",
      "35": "t",
      "36": "e",
      "37": "d",
      "38": ".",
      "39": "k",
      "40": "e",
      "41": "y",
      "42": "]",
      "43": "=",
      "44": "v",
      "45": "a",
      "46": "l",
      "47": "u",
      "48": "e",
      "49": "2",
    },
    pageSize: 100,
  });

  // Handle the result
  console.log(result)
}

run();

Parameters

Parameter Type Required Description
request operations.ListAccountsRequest ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.

Response

Promise<operations.ListAccountsResponse>

Errors

Error Object Status Code Content Type
errors.ErrorResponse default application/json
errors.SDKError 4xx-5xx /

listLogs

List the logs from a ledger, sorted by ID in descending order.

Example Usage

import { SDK } from "@formance/formance-sdk";

const sdk = new SDK({
  authorization: "<YOUR_AUTHORIZATION_HERE>",
});

async function run() {
  const result = await sdk.ledger.listLogs({
    after: "1234",
    cursor: "aHR0cHM6Ly9nLnBhZ2UvTmVrby1SYW1lbj9zaGFyZQ==",
    ledger: "ledger001",
    pageSize: 100,
  });

  // Handle the result
  console.log(result)
}

run();

Parameters

Parameter Type Required Description
request operations.ListLogsRequest ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.

Response

Promise<operations.ListLogsResponse>

Errors

Error Object Status Code Content Type
errors.ErrorResponse default application/json
errors.SDKError 4xx-5xx /

listTransactions

List transactions from a ledger, sorted by txid in descending order.

Example Usage

import { SDK } from "@formance/formance-sdk";

const sdk = new SDK({
  authorization: "<YOUR_AUTHORIZATION_HERE>",
});

async function run() {
  const result = await sdk.ledger.listTransactions({
    account: "users:001",
    after: "1234",
    cursor: "aHR0cHM6Ly9nLnBhZ2UvTmVrby1SYW1lbj9zaGFyZQ==",
    destination: "users:001",
    ledger: "ledger001",
    pageSize: 100,
    reference: "ref:001",
    source: "users:001",
  });

  // Handle the result
  console.log(result)
}

run();

Parameters

Parameter Type Required Description
request operations.ListTransactionsRequest ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.

Response

Promise<operations.ListTransactionsResponse>

Errors

Error Object Status Code Content Type
errors.ErrorResponse default application/json
errors.SDKError 4xx-5xx /

readStats

Get statistics from a ledger. (aggregate metrics on accounts and transactions)

Example Usage

import { SDK } from "@formance/formance-sdk";

const sdk = new SDK({
  authorization: "<YOUR_AUTHORIZATION_HERE>",
});

async function run() {
  const result = await sdk.ledger.readStats({
    ledger: "ledger001",
  });

  // Handle the result
  console.log(result)
}

run();

Parameters

Parameter Type Required Description
request operations.ReadStatsRequest ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.

Response

Promise<operations.ReadStatsResponse>

Errors

Error Object Status Code Content Type
errors.ErrorResponse default application/json
errors.SDKError 4xx-5xx /

revertTransaction

Revert a ledger transaction by its ID

Example Usage

import { SDK } from "@formance/formance-sdk";

const sdk = new SDK({
  authorization: "<YOUR_AUTHORIZATION_HERE>",
});

async function run() {
  const result = await sdk.ledger.revertTransaction({
    ledger: "ledger001",
    txid: BigInt("1234"),
  });

  // Handle the result
  console.log(result)
}

run();

Parameters

Parameter Type Required Description
request operations.RevertTransactionRequest ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.

Response

Promise<operations.RevertTransactionResponse>

Errors

Error Object Status Code Content Type
errors.ErrorResponse default application/json
errors.SDKError 4xx-5xx /

runScript

This route is deprecated, and has been merged into POST /{ledger}/transactions.

⚠️ DEPRECATED: This will be removed in a future release, please migrate away from it as soon as possible.

Example Usage

import { SDK } from "@formance/formance-sdk";

const sdk = new SDK({
  authorization: "<YOUR_AUTHORIZATION_HERE>",
});

async function run() {
  const result = await sdk.ledger.runScript({
    script: {
      plain: "vars {
    account $user
    }
    send [COIN 10] (
    	source = @world
    	destination = $user
    )
    ",
      reference: "order_1234",
      vars: {
        "user": "users:042",
      },
    },
    ledger: "ledger001",
    preview: true,
  });

  // Handle the result
  console.log(result)
}

run();

Parameters

Parameter Type Required Description
request operations.RunScriptRequest ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.

Response

Promise<operations.RunScriptResponse>

Errors

Error Object Status Code Content Type
errors.SDKError 4xx-5xx /

updateMapping

Update the mapping of a ledger

Example Usage

import { SDK } from "@formance/formance-sdk";

const sdk = new SDK({
  authorization: "<YOUR_AUTHORIZATION_HERE>",
});

async function run() {
  const result = await sdk.ledger.updateMapping({
    mapping: {
      contracts: [
        {
          account: "users:001",
          expr: {},
        },
      ],
    },
    ledger: "ledger001",
  });

  // Handle the result
  console.log(result)
}

run();

Parameters

Parameter Type Required Description
request operations.UpdateMappingRequest ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.

Response

Promise<operations.UpdateMappingResponse>

Errors

Error Object Status Code Content Type
errors.ErrorResponse default application/json
errors.SDKError 4xx-5xx /

v2AddMetadataOnTransaction

Set the metadata of a transaction by its ID

Example Usage

import { SDK } from "@formance/formance-sdk";

const sdk = new SDK({
  authorization: "<YOUR_AUTHORIZATION_HERE>",
});

async function run() {
  const result = await sdk.ledger.v2AddMetadataOnTransaction({
    requestBody: {
      "admin": "true",
    },
    dryRun: true,
    id: BigInt("1234"),
    ledger: "ledger001",
  });

  // Handle the result
  console.log(result)
}

run();

Parameters

Parameter Type Required Description
request operations.V2AddMetadataOnTransactionRequest ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.

Response

Promise<operations.V2AddMetadataOnTransactionResponse>

Errors

Error Object Status Code Content Type
errors.V2ErrorResponse default application/json
errors.SDKError 4xx-5xx /

v2AddMetadataToAccount

Add metadata to an account

Example Usage

import { SDK } from "@formance/formance-sdk";

const sdk = new SDK({
  authorization: "<YOUR_AUTHORIZATION_HERE>",
});

async function run() {
  const result = await sdk.ledger.v2AddMetadataToAccount({
    requestBody: {
      "admin": "true",
    },
    address: "users:001",
    dryRun: true,
    ledger: "ledger001",
  });

  // Handle the result
  console.log(result)
}

run();

Parameters

Parameter Type Required Description
request operations.V2AddMetadataToAccountRequest ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.

Response

Promise<operations.V2AddMetadataToAccountResponse>

Errors

Error Object Status Code Content Type
errors.V2ErrorResponse default application/json
errors.SDKError 4xx-5xx /

v2CountAccounts

Count the accounts from a ledger

Example Usage

import { SDK } from "@formance/formance-sdk";

const sdk = new SDK({
  authorization: "<YOUR_AUTHORIZATION_HERE>",
});

async function run() {
  const result = await sdk.ledger.v2CountAccounts({
    ledger: "ledger001",
  });

  // Handle the result
  console.log(result)
}

run();

Parameters

Parameter Type Required Description
request operations.V2CountAccountsRequest ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.

Response

Promise<operations.V2CountAccountsResponse>

Errors

Error Object Status Code Content Type
errors.V2ErrorResponse default application/json
errors.SDKError 4xx-5xx /

v2CountTransactions

Count the transactions from a ledger

Example Usage

import { SDK } from "@formance/formance-sdk";

const sdk = new SDK({
  authorization: "<YOUR_AUTHORIZATION_HERE>",
});

async function run() {
  const result = await sdk.ledger.v2CountTransactions({
    ledger: "ledger001",
  });

  // Handle the result
  console.log(result)
}

run();

Parameters

Parameter Type Required Description
request operations.V2CountTransactionsRequest ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.

Response

Promise<operations.V2CountTransactionsResponse>

Errors

Error Object Status Code Content Type
errors.V2ErrorResponse default application/json
errors.SDKError 4xx-5xx /

v2CreateBulk

Bulk request

Example Usage

import { SDK } from "@formance/formance-sdk";

const sdk = new SDK({
  authorization: "<YOUR_AUTHORIZATION_HERE>",
});

async function run() {
  const result = await sdk.ledger.v2CreateBulk({
    requestBody: [
        {
          action: "<value>",
        },
    ],
    ledger: "ledger001",
  });

  // Handle the result
  console.log(result)
}

run();

Parameters

Parameter Type Required Description
request operations.V2CreateBulkRequest ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.

Response

Promise<operations.V2CreateBulkResponse>

Errors

Error Object Status Code Content Type
errors.V2ErrorResponse default application/json
errors.SDKError 4xx-5xx /

v2CreateLedger

Create a ledger

Example Usage

import { SDK } from "@formance/formance-sdk";

const sdk = new SDK({
  authorization: "<YOUR_AUTHORIZATION_HERE>",
});

async function run() {
  const result = await sdk.ledger.v2CreateLedger({
    v2CreateLedgerRequest: {
      metadata: {
        "admin": "true",
      },
    },
    ledger: "ledger001",
  });

  // Handle the result
  console.log(result)
}

run();

Parameters

Parameter Type Required Description
request operations.V2CreateLedgerRequest ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.

Response

Promise<operations.V2CreateLedgerResponse>

Errors

Error Object Status Code Content Type
errors.V2ErrorResponse default application/json
errors.SDKError 4xx-5xx /

v2CreateTransaction

Create a new transaction to a ledger

Example Usage

import { SDK } from "@formance/formance-sdk";

const sdk = new SDK({
  authorization: "<YOUR_AUTHORIZATION_HERE>",
});

async function run() {
  const result = await sdk.ledger.v2CreateTransaction({
    v2PostTransaction: {
      metadata: {
        "admin": "true",
      },
      postings: [
        {
          amount: BigInt("100"),
          asset: "COIN",
          destination: "users:002",
          source: "users:001",
        },
      ],
      reference: "ref:001",
      script: {
        plain: "vars {
      account $user
      }
      send [COIN 10] (
      	source = @world
      	destination = $user
      )
      ",
        vars: {
          "user": "users:042",
        },
      },
    },
    dryRun: true,
    ledger: "ledger001",
  });

  // Handle the result
  console.log(result)
}

run();

Parameters

Parameter Type Required Description
request operations.V2CreateTransactionRequest ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.

Response

Promise<operations.V2CreateTransactionResponse>

Errors

Error Object Status Code Content Type
errors.V2ErrorResponse default application/json
errors.SDKError 4xx-5xx /

v2DeleteAccountMetadata

Delete metadata by key

Example Usage

import { SDK } from "@formance/formance-sdk";

const sdk = new SDK({
  authorization: "<YOUR_AUTHORIZATION_HERE>",
});

async function run() {
  const result = await sdk.ledger.v2DeleteAccountMetadata({
    address: "3680 Emile Grove",
    key: "foo",
    ledger: "ledger001",
  });

  // Handle the result
  console.log(result)
}

run();

Parameters

Parameter Type Required Description
request operations.V2DeleteAccountMetadataRequest ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.

Response

Promise<operations.V2DeleteAccountMetadataResponse>

Errors

Error Object Status Code Content Type
errors.SDKError 4xx-5xx /

v2DeleteLedgerMetadata

Delete ledger metadata by key

Example Usage

import { SDK } from "@formance/formance-sdk";

const sdk = new SDK({
  authorization: "<YOUR_AUTHORIZATION_HERE>",
});

async function run() {
  const result = await sdk.ledger.v2DeleteLedgerMetadata({
    key: "foo",
    ledger: "ledger001",
  });

  // Handle the result
  console.log(result)
}

run();

Parameters

Parameter Type Required Description
request operations.V2DeleteLedgerMetadataRequest ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.

Response

Promise<operations.V2DeleteLedgerMetadataResponse>

Errors

Error Object Status Code Content Type
errors.V2ErrorResponse default application/json
errors.SDKError 4xx-5xx /

v2DeleteTransactionMetadata

Delete metadata by key

Example Usage

import { SDK } from "@formance/formance-sdk";

const sdk = new SDK({
  authorization: "<YOUR_AUTHORIZATION_HERE>",
});

async function run() {
  const result = await sdk.ledger.v2DeleteTransactionMetadata({
    id: BigInt("1234"),
    key: "foo",
    ledger: "ledger001",
  });

  // Handle the result
  console.log(result)
}

run();

Parameters

Parameter Type Required Description
request operations.V2DeleteTransactionMetadataRequest ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.

Response

Promise<operations.V2DeleteTransactionMetadataResponse>

Errors

Error Object Status Code Content Type
errors.V2ErrorResponse default application/json
errors.SDKError 4xx-5xx /

v2GetAccount

Get account by its address

Example Usage

import { SDK } from "@formance/formance-sdk";

const sdk = new SDK({
  authorization: "<YOUR_AUTHORIZATION_HERE>",
});

async function run() {
  const result = await sdk.ledger.v2GetAccount({
    address: "users:001",
    ledger: "ledger001",
  });

  // Handle the result
  console.log(result)
}

run();

Parameters

Parameter Type Required Description
request operations.V2GetAccountRequest ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.

Response

Promise<operations.V2GetAccountResponse>

Errors

Error Object Status Code Content Type
errors.V2ErrorResponse default application/json
errors.SDKError 4xx-5xx /

v2GetBalancesAggregated

Get the aggregated balances from selected accounts

Example Usage

import { SDK } from "@formance/formance-sdk";

const sdk = new SDK({
  authorization: "<YOUR_AUTHORIZATION_HERE>",
});

async function run() {
  const result = await sdk.ledger.v2GetBalancesAggregated({
    ledger: "ledger001",
  });

  // Handle the result
  console.log(result)
}

run();

Parameters

Parameter Type Required Description
request operations.V2GetBalancesAggregatedRequest ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.

Response

Promise<operations.V2GetBalancesAggregatedResponse>

Errors

Error Object Status Code Content Type
errors.V2ErrorResponse default application/json
errors.SDKError 4xx-5xx /

v2GetInfo

Show server information

Example Usage

import { SDK } from "@formance/formance-sdk";

const sdk = new SDK({
  authorization: "<YOUR_AUTHORIZATION_HERE>",
});

async function run() {
  const result = await sdk.ledger.v2GetInfo();

  // Handle the result
  console.log(result)
}

run();

Parameters

Parameter Type Required Description
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.

Response

Promise<operations.V2GetInfoResponse>

Errors

Error Object Status Code Content Type
errors.V2ErrorResponse default application/json
errors.SDKError 4xx-5xx /

v2GetLedger

Get a ledger

Example Usage

import { SDK } from "@formance/formance-sdk";

const sdk = new SDK({
  authorization: "<YOUR_AUTHORIZATION_HERE>",
});

async function run() {
  const result = await sdk.ledger.v2GetLedger({
    ledger: "ledger001",
  });

  // Handle the result
  console.log(result)
}

run();

Parameters

Parameter Type Required Description
request operations.V2GetLedgerRequest ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.

Response

Promise<operations.V2GetLedgerResponse>

Errors

Error Object Status Code Content Type
errors.V2ErrorResponse default application/json
errors.SDKError 4xx-5xx /

v2GetLedgerInfo

Get information about a ledger

Example Usage

import { SDK } from "@formance/formance-sdk";

const sdk = new SDK({
  authorization: "<YOUR_AUTHORIZATION_HERE>",
});

async function run() {
  const result = await sdk.ledger.v2GetLedgerInfo({
    ledger: "ledger001",
  });

  // Handle the result
  console.log(result)
}

run();

Parameters

Parameter Type Required Description
request operations.V2GetLedgerInfoRequest ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.

Response

Promise<operations.V2GetLedgerInfoResponse>

Errors

Error Object Status Code Content Type
errors.V2ErrorResponse default application/json
errors.SDKError 4xx-5xx /

v2GetTransaction

Get transaction from a ledger by its ID

Example Usage

import { SDK } from "@formance/formance-sdk";

const sdk = new SDK({
  authorization: "<YOUR_AUTHORIZATION_HERE>",
});

async function run() {
  const result = await sdk.ledger.v2GetTransaction({
    id: BigInt("1234"),
    ledger: "ledger001",
  });

  // Handle the result
  console.log(result)
}

run();

Parameters

Parameter Type Required Description
request operations.V2GetTransactionRequest ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.

Response

Promise<operations.V2GetTransactionResponse>

Errors

Error Object Status Code Content Type
errors.V2ErrorResponse default application/json
errors.SDKError 4xx-5xx /

v2GetVolumesWithBalances

Get list of volumes with balances for (account/asset)

Example Usage

import { SDK } from "@formance/formance-sdk";

const sdk = new SDK({
  authorization: "<YOUR_AUTHORIZATION_HERE>",
});

async function run() {
  const result = await sdk.ledger.v2GetVolumesWithBalances({
    cursor: "aHR0cHM6Ly9nLnBhZ2UvTmVrby1SYW1lbj9zaGFyZQ==",
    groupBy: 3,
    ledger: "ledger001",
    pageSize: 100,
  });

  // Handle the result
  console.log(result)
}

run();

Parameters

Parameter Type Required Description
request operations.V2GetVolumesWithBalancesRequest ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.

Response

Promise<operations.V2GetVolumesWithBalancesResponse>

Errors

Error Object Status Code Content Type
errors.V2ErrorResponse default application/json
errors.SDKError 4xx-5xx /

v2ListAccounts

List accounts from a ledger, sorted by address in descending order.

Example Usage

import { SDK } from "@formance/formance-sdk";

const sdk = new SDK({
  authorization: "<YOUR_AUTHORIZATION_HERE>",
});

async function run() {
  const result = await sdk.ledger.v2ListAccounts({
    cursor: "aHR0cHM6Ly9nLnBhZ2UvTmVrby1SYW1lbj9zaGFyZQ==",
    ledger: "ledger001",
    pageSize: 100,
  });

  // Handle the result
  console.log(result)
}

run();

Parameters

Parameter Type Required Description
request operations.V2ListAccountsRequest ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.

Response

Promise<operations.V2ListAccountsResponse>

Errors

Error Object Status Code Content Type
errors.V2ErrorResponse default application/json
errors.SDKError 4xx-5xx /

v2ListLedgers

List ledgers

Example Usage

import { SDK } from "@formance/formance-sdk";

const sdk = new SDK({
  authorization: "<YOUR_AUTHORIZATION_HERE>",
});

async function run() {
  const result = await sdk.ledger.v2ListLedgers({
    cursor: "aHR0cHM6Ly9nLnBhZ2UvTmVrby1SYW1lbj9zaGFyZQ==",
    pageSize: 100,
  });

  // Handle the result
  console.log(result)
}

run();

Parameters

Parameter Type Required Description
request operations.V2ListLedgersRequest ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.

Response

Promise<operations.V2ListLedgersResponse>

Errors

Error Object Status Code Content Type
errors.V2ErrorResponse default application/json
errors.SDKError 4xx-5xx /

v2ListLogs

List the logs from a ledger, sorted by ID in descending order.

Example Usage

import { SDK } from "@formance/formance-sdk";

const sdk = new SDK({
  authorization: "<YOUR_AUTHORIZATION_HERE>",
});

async function run() {
  const result = await sdk.ledger.v2ListLogs({
    cursor: "aHR0cHM6Ly9nLnBhZ2UvTmVrby1SYW1lbj9zaGFyZQ==",
    ledger: "ledger001",
    pageSize: 100,
  });

  // Handle the result
  console.log(result)
}

run();

Parameters

Parameter Type Required Description
request operations.V2ListLogsRequest ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.

Response

Promise<operations.V2ListLogsResponse>

Errors

Error Object Status Code Content Type
errors.V2ErrorResponse default application/json
errors.SDKError 4xx-5xx /

v2ListTransactions

List transactions from a ledger, sorted by id in descending order.

Example Usage

import { SDK } from "@formance/formance-sdk";

const sdk = new SDK({
  authorization: "<YOUR_AUTHORIZATION_HERE>",
});

async function run() {
  const result = await sdk.ledger.v2ListTransactions({
    cursor: "aHR0cHM6Ly9nLnBhZ2UvTmVrby1SYW1lbj9zaGFyZQ==",
    ledger: "ledger001",
    pageSize: 100,
  });

  // Handle the result
  console.log(result)
}

run();

Parameters

Parameter Type Required Description
request operations.V2ListTransactionsRequest ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.

Response

Promise<operations.V2ListTransactionsResponse>

Errors

Error Object Status Code Content Type
errors.V2ErrorResponse default application/json
errors.SDKError 4xx-5xx /

v2ReadStats

Get statistics from a ledger. (aggregate metrics on accounts and transactions)

Example Usage

import { SDK } from "@formance/formance-sdk";

const sdk = new SDK({
  authorization: "<YOUR_AUTHORIZATION_HERE>",
});

async function run() {
  const result = await sdk.ledger.v2ReadStats({
    ledger: "ledger001",
  });

  // Handle the result
  console.log(result)
}

run();

Parameters

Parameter Type Required Description
request operations.V2ReadStatsRequest ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.

Response

Promise<operations.V2ReadStatsResponse>

Errors

Error Object Status Code Content Type
errors.V2ErrorResponse default application/json
errors.SDKError 4xx-5xx /

v2RevertTransaction

Revert a ledger transaction by its ID

Example Usage

import { SDK } from "@formance/formance-sdk";

const sdk = new SDK({
  authorization: "<YOUR_AUTHORIZATION_HERE>",
});

async function run() {
  const result = await sdk.ledger.v2RevertTransaction({
    id: BigInt("1234"),
    ledger: "ledger001",
  });

  // Handle the result
  console.log(result)
}

run();

Parameters

Parameter Type Required Description
request operations.V2RevertTransactionRequest ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.

Response

Promise<operations.V2RevertTransactionResponse>

Errors

Error Object Status Code Content Type
errors.V2ErrorResponse default application/json
errors.SDKError 4xx-5xx /

v2UpdateLedgerMetadata

Update ledger metadata

Example Usage

import { SDK } from "@formance/formance-sdk";

const sdk = new SDK({
  authorization: "<YOUR_AUTHORIZATION_HERE>",
});

async function run() {
  const result = await sdk.ledger.v2UpdateLedgerMetadata({
    requestBody: {
      "admin": "true",
    },
    ledger: "ledger001",
  });

  // Handle the result
  console.log(result)
}

run();

Parameters

Parameter Type Required Description
request operations.V2UpdateLedgerMetadataRequest ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.

Response

Promise<operations.V2UpdateLedgerMetadataResponse>

Errors

Error Object Status Code Content Type
errors.V2ErrorResponse default application/json
errors.SDKError 4xx-5xx /