BillingBalance billing.balance@1
Generated at from
openvibe-contracts v0.454.0 and
openvibe-sdk v0.193.0.
- Version
- 1.0.0
- Owner
- billing
- Visibility
- first-party
- Status
- active
- Compatibility
- backward
- Schema
https://openvibe.network/contracts/billing/balance.v1.json
billing.balance@1: a Balance account (D12), held by a person (owner user:<usr_id>) or a project (owner project:<prj_id>). GET /api/me/balance answers { personal, projects } of these. balance_nano_usd is the whole account; held_nano_usd is reserved by active holds; available_nano_usd is spendable (balance = held + available). Money is integer nano-USD as decimal strings (D1), never a float. sandbox marks a sandbox account. An id is permanent, so this contract still also describes the Vibes wallet body that billing.balance.read has answered: a person's Vibes (currency vibes-bits), not a Balance. Each branch is closed with additionalProperties: false; new code sends the Balance branch.
Fields
| Field | Type | Required | Description | Constraints |
|---|---|---|---|---|
subject | identity.subject-ref | |||
currency | const |
| ||
credit | integer | |||
payable | integer | |||
pending_payouts | integer | |||
payable_value_cents | integer | What payable is worth in US cents at today's rate. | ||
bits_per_usd | number |
Examples
From the contract's own test fixtures: valid ones validate, rejected ones must fail.
Valid: creator
{
"subject": {
"type": "user",
"id": "usr_01JAB2C3D4E5F6G7H8J9K0MNPR"
},
"currency": "vibes-bits",
"credit": 1200,
"payable": 5500,
"pending_payouts": 0,
"payable_value_cents": 5500,
"bits_per_usd": 100
}Valid: personal
{
"owner": {
"type": "user",
"id": "usr_01JAB2C3D4E5F6G7H8J9K0MNPQ"
},
"balance_nano_usd": "12400000000",
"held_nano_usd": "0",
"available_nano_usd": "12400000000",
"sandbox": false
}Valid: project
{
"owner": {
"type": "project",
"id": "prj_01JAB2C3D4E5F6G7H8J9K0MNPQ"
},
"balance_nano_usd": "5000000000",
"held_nano_usd": "1200000000",
"available_nano_usd": "3800000000"
}Valid: sandbox
{
"owner": {
"type": "project",
"id": "prj_01JAB2C3D4E5F6G7H8J9K0MNPQ"
},
"balance_nano_usd": "100000000",
"held_nano_usd": "0",
"available_nano_usd": "100000000",
"sandbox": true
}Rejected: extra-promo-bits
{
"owner": {
"type": "user",
"id": "usr_01JAB2C3D4E5F6G7H8J9K0MNPQ"
},
"balance_nano_usd": "1",
"held_nano_usd": "0",
"available_nano_usd": "1",
"promo_bits": 5
}Rejected: missing-available
{
"owner": {
"type": "user",
"id": "usr_01JAB2C3D4E5F6G7H8J9K0MNPQ"
},
"balance_nano_usd": "12400000000",
"held_nano_usd": "0"
}Rejected: mixed-shapes
{
"owner": {
"type": "user",
"id": "usr_01JAB2C3D4E5F6G7H8J9K0MNPQ"
},
"balance_nano_usd": "1",
"held_nano_usd": "0",
"available_nano_usd": "1",
"subject": {
"type": "user",
"id": "usr_01JAB2C3D4E5F6G7H8J9K0MNPQ"
},
"currency": "vibes-bits",
"credit": 1,
"payable": 0,
"pending_payouts": 0,
"payable_value_cents": 0,
"bits_per_usd": 100
}Rejected: money-number
{
"owner": {
"type": "user",
"id": "usr_01JAB2C3D4E5F6G7H8J9K0MNPQ"
},
"balance_nano_usd": 12400000000,
"held_nano_usd": "0",
"available_nano_usd": "12400000000"
}Rejected: unknown-owner-type
{
"owner": {
"type": "guest",
"id": "usr_01JAB2C3D4E5F6G7H8J9K0MNPQ"
},
"balance_nano_usd": "1",
"held_nano_usd": "0",
"available_nano_usd": "1"
}Rejected: wrong-currency
{
"subject": {
"type": "user",
"id": "usr_01JAB2C3D4E5F6G7H8J9K0MNPR"
},
"currency": "usd-cents",
"credit": 1,
"payable": 0,
"pending_payouts": 0,
"payable_value_cents": 0,
"bits_per_usd": 100
}Validate
const contracts = require('openvibe-contracts');
contracts.validate('billing.balance@1', value); // { valid, errors: [{ path, message }] }