NetworkCoinsTransferRequest network.coins-transfer-request@1

Generated at from openvibe-contracts v0.53.0 and openvibe-sdk v0.11.0.

Version
1.0.0
Owner
network
Visibility
first-party
Status
active
Compatibility
backward
Schema
https://openvibe.network/contracts/network/coins-transfer-request.v1.json

network.coins-transfer-request@1: the body of network.coins.transfer on OpenVibe.Network. POST /internal/coins/transfer: { from_user_id, to_user_id, app_id?, amount, reason?, ref?, idempotency_key } moves OpenCoins between two Network users atomically (the two ids are Network user ids and must differ). Refusals are { error } bodies: 400 invalid_from_user_id, invalid_to_user_id, invalid_transfer (the same person), invalid_amount or missing_idempotency_key; 404 user_not_found; 409 { error: insufficient_funds, balance } when the sender cannot cover it. Unknown fields are ignored.

Fields

FieldTypeRequiredDescriptionConstraints
from_user_idinteger | stringyesThe Network user id that pays.
  • pattern ^[1-9][0-9]*$
  • minimum 1
to_user_idinteger | stringyesThe Network user id that receives.
  • pattern ^[1-9][0-9]*$
  • minimum 1
app_idstringThe app the coins move for. A service token may only name its own (svc:live → live); anything else is 403 capability.owner_denied. The shared internal key may name any.
amountintegeryesOpenCoins, a positive whole number (a string is refused: 400 invalid_amount).
  • minimum 1
reasonstring | nullWhy, kept on the ledger row.
refstring | nullThe caller's reference for the row (an order, a game, …).
idempotency_keystringyesUnique per mutation. A replay returns the first answer and changes nothing (400 missing_idempotency_key without it).
  • minLength 1

Examples

From the contract's own test fixtures: valid ones validate, rejected ones must fail.

Valid: transfer
{
  "from_user_id": 1042,
  "to_user_id": 2210,
  "app_id": "games",
  "amount": 40,
  "reason": "wager",
  "ref": "match:m_8812",
  "idempotency_key": "games:wager:m_8812"
}
Rejected: no-recipient
{
  "from_user_id": 1042,
  "amount": 10,
  "idempotency_key": "games:wager:m_8814"
}
Rejected: zero
{
  "from_user_id": 1042,
  "to_user_id": 2210,
  "amount": 0,
  "idempotency_key": "games:wager:m_8813"
}

Validate

const contracts = require('openvibe-contracts');
contracts.validate('network.coins-transfer-request@1', value);   // { valid, errors: [{ path, message }] }