BillingBalance billing.balance@1

Generated at from openvibe-contracts v0.53.0 and openvibe-sdk v0.11.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 person's Vibes balances, GET /api/v1/balances/:subject on OpenVibe.Billing (also returned after a recycle). credit is spendable (bought or given back), payable is what others gave the person (the only balance that can be cashed out), pending_payouts is held for requested cashouts.

Fields

FieldTypeRequiredDescriptionConstraints
subjectidentity.subject-refyes
currencyconstyes
  • = "vibes-bits"
creditintegeryes
payableintegeryes
pending_payoutsintegeryes
payable_value_centsintegeryesWhat payable is worth in US cents at today's rate.
bits_per_usdnumberyes

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
}
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 }] }