Balance

POST /wallets/{walletId}/transactions-balance

status: under development

Balance a transaction body of a given transaction, add needed inputs/outputs, so as the transaction can be signed from the wallet.

Path parameters

  • walletId string(hex) Required

    Minimum length is 40, maximum length is 40.

application/json

Body Required

  • transaction string(base64|base16) Required

    The CBOR-encoded transaction, represented in either hex or base64 encoding. This always includes the transaction body and the witness set, even if the latter is empty.

  • inputs array[object]

    Mapping from inputs (id, ix) in the supplied transaction binary to outputs (amount, assets, ...). It is not required to include inputs present in the cardano-node UTxO, as cardano-wallet will automatically query for them.

    In other words, this field can be left empty unless the supplied transaction contains inputs referring to pending transactions.

    Hide inputs attributes Show inputs attributes object
    • id string(hex) Required

      A unique identifier for this transaction

      Minimum length is 64, maximum length is 64.

    • index integer Required

      Minimum value is 0.

    • address string(base58|bech32) Required

      A sequence of characters that encodes (in Base58 or Bech32) a sequence of bytes which represents an address on the Cardano blockchain. Sequences in Base58 encoding are expected to be legacy Byron addresses, whereas sequences in Bech32 encoding correspond to current Shelley addresses.

      For more details, see CIP-0019 — Cardano addresses .

    • amount object Required

      Coins, in Lovelace. Only relates to 'Ada'. Refer to assets for multi-assets wallets instead.

      Hide amount attributes Show amount attributes object
      • quantity integer Required

        Minimum value is 0.

      • unit string Required

        Value is lovelace.

    • datum string(hex)

      A datum hash.

      Minimum length is 64, maximum length is 64.

    • assets array[object] Required

      A flat list of assets (possibly empty).

      Hide assets attributes Show assets attributes object
      • policy_id string(hex) Required

        A unique identifier of the asset's monetary policy. The policy controls how assets of this kind are created and destroyed.

        The contents are the blake2b-224 hash of the monetary policy script, encoded in hexadecimal.

        Minimum length is 56, maximum length is 56.

      • asset_name string(hex) Required

        The asset on-chain type which acts as a sub-identifier within a policy. Although we call it "asset name", the value needn't be text, and it could even be empty.

        For policies with a single fungible asset item, asset name is typically an empty string.

        This value can be up to 32 bytes of arbitrary data (which is 64 hexadecimal digits).

        Maximum length is 64.

      • quantity integer Required

        Number of assets for the given policy_id and asset_name.

        Minimum value is 0.

  • redeemers array[object]

    A list of redeemers data with their purpose. The redeemers in the transaction binary will be overwritten by this value.

    One of:
  • encoding string

    Encoding of transaction CBOR returned in response (base64 by default).

    Values are base16 or base64.

Responses

  • 400 application/json

    Bad Request

    One of:
  • 403 application/json

    Forbidden

    One of:
  • 415 application/json

    Unsupported Media Type

    Hide response attributes Show response attributes object
    • message string Required

      May occur when providing an invalid 'Content-Type' header.

    • code string Required

      Value is unsupported_media_type.

  • 406 application/json

    Not Acceptable

    Hide response attributes Show response attributes object
    • message string Required

      May occur when providing an invalid 'Accept' header.

    • code string Required

      Value is not_acceptable.

  • 404 application/json

    Not Found

    Hide response attributes Show response attributes object
    • message string Required

      May occur when a given walletId does not match with any known wallets (because it has been deleted, or has never existed).

    • code string Required

      Value is no_such_wallet.

    • info object
      Hide info attribute Show info attribute object
      • wallet_id string(hex) Required

        A unique identifier for the wallet

        Minimum length is 40, maximum length is 40.

  • 202 application/json

    Accepted

    Hide response attribute Show response attribute object
    • transaction string(base64|base16) Required

      The CBOR-encoded transaction, represented in either hex or base64 encoding. This always includes the transaction body and the witness set, even if the latter is empty.

POST /wallets/{walletId}/transactions-balance
curl \
 --request POST https://localhost:8090/v2/wallets/{walletId}/transactions-balance \
 --header "Content-Type: application/json" \
 --data '{"transaction":"string","inputs":[{"id":"1423856bc91c49e928f6f30f4e8d665d53eb4ab6028bd0ac971809d514c92db1","index":42,"address":"addr1sjck9mdmfyhzvjhydcjllgj9vjvl522w0573ncustrrr2rg7h9azg4cyqd36yyd48t5ut72hgld0fg2xfvz82xgwh7wal6g2xt8n996s3xvu5g","amount":{"quantity":42000000,"unit":"lovelace"},"datum":"16f30f4e8d665d53eb4ab6028bd0ac971809d514c92d423856bc91c49e928faf","assets":[{"policy_id":"65ab82542b0ca20391caaf66a4d4d7897d281f9c136cd3513136945b","asset_name":"string","quantity":42}]}],"redeemers":[{"purpose":"spending","data":"string","input":{"id":"1423856bc91c49e928f6f30f4e8d665d53eb4ab6028bd0ac971809d514c92db1","index":42}}],"encoding":"base16"}'
Request examples
{
  "transaction": "string",
  "inputs": [
    {
      "id": "1423856bc91c49e928f6f30f4e8d665d53eb4ab6028bd0ac971809d514c92db1",
      "index": 42,
      "address": "addr1sjck9mdmfyhzvjhydcjllgj9vjvl522w0573ncustrrr2rg7h9azg4cyqd36yyd48t5ut72hgld0fg2xfvz82xgwh7wal6g2xt8n996s3xvu5g",
      "amount": {
        "quantity": 42000000,
        "unit": "lovelace"
      },
      "datum": "16f30f4e8d665d53eb4ab6028bd0ac971809d514c92d423856bc91c49e928faf",
      "assets": [
        {
          "policy_id": "65ab82542b0ca20391caaf66a4d4d7897d281f9c136cd3513136945b",
          "asset_name": "string",
          "quantity": 42
        }
      ]
    }
  ],
  "redeemers": [
    {
      "purpose": "spending",
      "data": "string",
      "input": {
        "id": "1423856bc91c49e928f6f30f4e8d665d53eb4ab6028bd0ac971809d514c92db1",
        "index": 42
      }
    }
  ],
  "encoding": "base16"
}
{
  "message": "string",
  "code": "bad_request"
}
{
  "message": "string",
  "code": "redeemer_script_failure"
}
{
  "message": "string",
  "code": "redeemer_target_not_found"
}
{
  "message": "string",
  "code": "redeemer_invalid_data"
}
{
  "message": "string",
  "code": "translation_error"
}
{
  "message": "string",
  "code": "unknown_inputs"
}
{
  "message": "string",
  "code": "input_resolution_conflicts"
}
{
  "message": "string",
  "code": "already_withdrawing"
}
{
  "message": "string",
  "code": "node_not_yet_in_recent_era",
  "info": {
    "node_era": "byron",
    "recent_eras": [
      "byron"
    ]
  }
}
{
  "message": "string",
  "code": "balance_tx_conflicting_networks"
}
{
  "message": "string",
  "code": "balance_tx_existing_collateral"
}
{
  "message": "string",
  "code": "balance_tx_existing_key_witnesses"
}
{
  "message": "string",
  "code": "balance_tx_existing_collateral_return_outputs"
}
{
  "message": "string",
  "code": "balance_tx_existing_total_collateral"
}
{
  "message": "string",
  "code": "balance_tx_internal_error"
}
{
  "message": "string",
  "code": "cannot_cover_fee"
}
{
  "message": "string",
  "code": "insufficient_collateral"
}
{
  "message": "string",
  "code": "invalid_wallet_type"
}
{
  "message": "string",
  "code": "no_utxos_available"
}
{
  "message": "string",
  "code": "not_enough_money",
  "info": {
    "shortfall": {
      "ada": {
        "quantity": 42000000,
        "unit": "lovelace"
      },
      "assets": [
        {
          "policy_id": "65ab82542b0ca20391caaf66a4d4d7897d281f9c136cd3513136945b",
          "asset_name": "string",
          "quantity": 42
        }
      ]
    }
  }
}
{
  "message": "string",
  "code": "transaction_already_balanced"
}
{
  "message": "string",
  "code": "transaction_is_too_big"
}
{
  "message": "string",
  "code": "utxo_too_small",
  "info": {
    "tx_output_index": 42,
    "tx_output_lovelace_specified": {
      "quantity": 42000000,
      "unit": "lovelace"
    },
    "tx_output_lovelace_required_minimum": {
      "quantity": 42000000,
      "unit": "lovelace"
    }
  }
}
{
  "message": "string",
  "code": "tx_not_in_node_era"
}
{
  "message": "string",
  "code": "balance_tx_inline_plutus_v3_script_not_supported_in_babbage"
}
{
  "message": "string",
  "code": "translation_byron_tx_out_in_context"
}
Response examples (415)
{
  "message": "string",
  "code": "unsupported_media_type"
}
Response examples (406)
{
  "message": "string",
  "code": "not_acceptable"
}
Response examples (404)
{
  "message": "string",
  "code": "no_such_wallet",
  "info": {
    "wallet_id": "2512a00e9653fe49a44a5886202e24d77eeb998f"
  }
}
Response examples (202)
{
  "transaction": "string"
}