/api/v1/accounts/[commitment]

This endpoint returns accounts by commitment for the access token owner. The endpoints also serve as a way to refresh cached balance. The backend will query the blockchain and update the account

Commitment

The commitment is a Poseidon hash stored on-chain as Bytes32 inside the smart contracts and serves as an identifier for accounts and it's used for the zero-knowledge proofs, we prove we know the preimage of this hash when verifying proofs, among other things. The commitment is used by the server as an account identifier and lets you query the account by substituting it to the [commitment] parameter.

To query the blockchain manually, you find information in the smart contract here.

Available Methods: GET

The following URL will return you the account by commitment. It will also refresh account balances if there is a difference between the on-chain balance and the cached balance

https://debitllama.com/api/v1/accounts/${commitment}

Updating Account Balance Too Low errors:

When Relaying a transaction fails due to Account Balance Too Low, the on-chain account balances must be topped up first and then refreshed to resume the payments. The balances are automatically refreshed using the front-end and can be done through this API endpoint also.

Updating Account balances only works for authenticated users! Users can only refresh their own account's balances.

Pagination

The endpoint will return all the payment intents created with this Account which can be used with the pagination API. The URL to paginate the results is same as explained before and will paginate Payment intents

https://debitllama.com/api/v1/accounts/${commitment}?current_page=0&page_size=10&sort_by=status_text&sort_direction=DESC

To learn more about how to paginate payment intents see:

An example response when fetching an account:

{
  _self: {
    href: "/api/v1/accounts/0x1e7032519f83b854fd7f61e2c802be3c60463d9f8cc59a6acd86072875d89f0e",
    methods: [ "GET" ]
  },
  _version: "v1",
  _description: "GET: an account by commitment and refresh cached balance",
  _links: [ {
      "href": "/api/v1/payment_intents/0x2d7c87415a32a81805d3e76ec587d2d04d41fab19e2ea2688d6b6fd2b0f6d829",
      "methods": [
        "GET",
        "POST"
      ]
    }, 
    { 
     href: "/api/v1/accounts", 
     methods: [ "GET" ] 
    }],
  all_payment_intents: {
    pagination: {
      current_page: 0,
      total_pages: 3,
      page_size: 1,
      sort_by: "created_at",
      sort_direction: "DESC",
      sortable_columns: [
        "created_at",
        "payee_address",
        "max_debit_amount",
        "debit_times",
        "debit_interval",
        "payment_intent",
        "status_text",
        "estimated_gas",
        "last_payment_date",
        "next_payment_date",
        "pricing",
        "currency",
        "debit_item_id"
      ]
    },
    data: [
      {
        "id": 89,
        "created_at": "2023-09-20T23:32:32+00:00",
        "account": {
          "network": {
            "name": "BTT Donau Testnet",
            "rpc": "https://pre-rpc.bt.io/",
            "chain_id": "0x405",
            "virtual_accounts_contract": "0x2137F4096365bCA1457E945838e0d7EC1925A973",
            "connected_wallets_contract": "0x2137F4096365bCA1457E945838e0d7EC1925A973",
            "currency": "BTT",
            "available_currencies": [
              {
                "name": "BTT",
                "native": true,
                "contractAddress": ""
              },
              {
                "name": "USDTM",
                "native": false,
                "contractAddress": "0x4420a4415033bd22393d3A918EF8d2c9c62efD99"
              }
            ]
          },
          "closed": false,
          "currency": {
            "name": "USDTM",
            "native": false,
            "contractAddress": "0x4420a4415033bd22393d3A918EF8d2c9c62efD99"
          },
          "balance": 920,
          "account_type": "VIRTUALACCOUNT"
        },
        "payee_address": "0x2beE8f1a64A0a2dFbf105114B6B092b5636bC552",
        "max_debit_amount": 100,
        "debit_times": 24,
        "debit_interval": 25,
        "payment_intent": "0x2d7c87415a32a81805d3e76ec587d2d04d41fab19e2ea2688d6b6fd2b0f6d829",
        "commitment": "0x1e7032519f83b854fd7f61e2c802be3c60463d9f8cc59a6acd86072875d89f0e",
        "estimated_gas": "399097",
        "status_text": "Created",
        "last_payment_date": null,
        "next_payment_date": "2023-09-20T23:32:32+00:00",
        "pricing": "Dynamic",
        "currency": {
          "name": "USDTM",
          "native": false,
          "contractAddress": "0x4420a4415033bd22393d3A918EF8d2c9c62efD99"
        },
        "network": {
          "name": "BTT Donau Testnet",
          "rpc": "https://pre-rpc.bt.io/",
          "chain_id": "0x405",
          "virtual_accounts_contract": "0x2137F4096365bCA1457E945838e0d7EC1925A973",
          "connected_wallets_contract": "0x2137F4096365bCA1457E945838e0d7EC1925A973",
          "currency": "BTT",
          "available_currencies": [
            {
              "name": "BTT",
              "native": true,
              "contractAddress": ""
            },
            {
              "name": "USDTM",
              "native": false,
              "contractAddress": "0x4420a4415033bd22393d3A918EF8d2c9c62efD99"
            }
          ]
        },
        "debit_item": {
          "id": 29,
          "created_at": "2023-09-20T22:09:26+00:00",
          "payee_address": "0x2beE8f1a64A0a2dFbf105114B6B092b5636bC552",
          "currency": {
            "name": "USDTM",
            "native": false,
            "contractAddress": "0x4420a4415033bd22393d3A918EF8d2c9c62efD99"
          },
          "max_price": 100,
          "debit_times": 24,
          "debit_interval": 25,
          "button_id": "524c8ce8-3049-48f4-be0a-4396a88f6437",
          "redirect_url": "https://monstercomix.me",
          "pricing": "Dynamic",
          "network": {
            "name": "BTT Donau Testnet",
            "rpc": "https://pre-rpc.bt.io/",
            "chain_id": "0x405",
            "virtual_accounts_contract": "0x2137F4096365bCA1457E945838e0d7EC1925A973",
            "connected_wallets_contract": "0x2137F4096365bCA1457E945838e0d7EC1925A973",
            "currency": "BTT",
            "available_currencies": [
              {
                "name": "BTT",
                "native": true,
                "contractAddress": ""
              },
              {
                "name": "USDTM",
                "native": false,
                "contractAddress": "0x4420a4415033bd22393d3A918EF8d2c9c62efD99"
              }
            ]
          },
          "name": "Monster comix subscription",
          "deleted": false,
          "payment_intents_count": 4
        },
        "used_for": 0,
        "transactions_left": 24,
        "failed_dynamic_payment_amount": 0
      },
    ]
  },
  missing_payments: [],
  account: {
    id: 26,
    created_at: "2023-09-20T22:13:37+00:00",
    network: {
      name: "BTT Donau Testnet",
      rpc: "https://pre-rpc.bt.io/",
      chain_id: "0x405",
      virtual_accounts_contract: "0x2137F4096365bCA1457E945838e0d7EC1925A973",
      connected_wallets_contract: "0x2137F4096365bCA1457E945838e0d7EC1925A973",
      currency: "BTT",
      available_currencies: [
        { name: "BTT", native: true, contractAddress: "" },
        {
          name: "USDTM",
          native: false,
          contractAddress: "0x4420a4415033bd22393d3A918EF8d2c9c62efD99"
        }
      ]
    },
    commitment: "0x1e7032519f83b854fd7f61e2c802be3c60463d9f8cc59a6acd86072875d89f0e",
    name: "My USDTM Wallet",
    closed: false,
    currency: {
      name: "USDTM",
      native: false,
      contractAddress: "0x4420a4415033bd22393d3A918EF8d2c9c62efD99"
    },
    balance: 920,
    account_type: "CONNECTEDWALLET",
    creator_address: "0x2beE8f1a64A0a2dFbf105114B6B092b5636bC552"
  }
}

  • all_payment_intents - You find all the payment intents created with this account paginated inside this object

  • all_payment_intents.pagination - The pagination object is used as described before in the Schema

  • all_payment_intents.data - An array of payment intents created with this account

  • missing_payments - Payment intents with the status_text ACCOUNTBALANCETOOLOW are fetched separately. These payments are delayed as the account failed to make payments in time.

Filtering

The filter query parameter lets you filter payment intents using these keys, to filter payment intents , check out the /api/v1/payment_intents page !

 enum PaymentIntents_filterKeys {
  payee_address = "payee_address",
  max_debit_amount = "max_debit_amount",
  debit_times = "debit_times",
  debit_interval = "debit_interval",
  status_text = "status_text",
  pricing = "pricing",
  currency = "currency",
  debit_item_id = "debit_item_id",
}

Last updated