Docs Técnicas
Intrinsics
Intrinsics are built-in functions known to the verifier and runtime.
Intrinsics are built-in functions known to the verifier and runtime.
Guards
require(condition, "error_label")
assert(condition, "error_label")
fail("error_label")
fail("error_label", "message")Use require(...) for preconditions.
Events
emit LoanRequested(lender, ctx.caller, principal, rate_ppm)Events are emitted only if execution succeeds.
Movement
send(amount, from, to)Use send(...) for generic value transfer. It lowers to canonical available plus EQ3_4 residual lines. Use post(...) when the accounting reason matters.
Posting
post(lines_generator(asset, operation_kind, line1, ...))
line_generator(owner, bucket, op, amount)
lines_generator(asset, operation_kind, line1, ...)Corrections
reverse(source_tx_id, asset, operation_kind?, line1, ...)
reversal(source_tx_id, asset, operation_kind?, line1, ...)
counterpost(source_tx_id, asset, operation_kind?, line1, ...)
reclassify(source_tx_id, asset, line1, line2)Product Helpers
Product helpers return validated posting plans and are preferred over raw post(lines_generator(...)) for product flows.
loan
loan.accrue_interest(principal, rate_ppm, from_ts, to_ts) -> u128
loan.origination_lines(asset, lender, borrower, amount)
loan.accrual_lines(asset, lender, borrower, amount)
loan.repayment_lines(asset, lender, borrower, amount)fees
fees.charge_lines(asset, payer, recipient, amount)
fees.accrual_lines(asset, payer, recipient, amount)
fees.settlement_lines(asset, payer, recipient, amount)yield
yield.accrue_interest(principal, rate_ppm, from_ts, to_ts) -> u128
yield.accrual_lines(asset, issuer, holder, amount)
yield.realization_lines(asset, issuer, holder, amount)installments
installments.schedule_lines(asset, servicer, obligor, amount)
installments.payment_lines(asset, servicer, obligor, amount)fx
fx.conversion_lines(asset, from_party, to_party, amount)Call twice for a full FX round-trip, once per currency leg.
insurance
insurance.premium_lines(asset, insured, insurer, amount)
insurance.reserve_lines(asset, insurer, amount)
insurance.payout_lines(asset, insurer, beneficiary, amount)provisioning_loss
provisioning_loss.provision_lines(asset, institution, counterparty, amount)
provisioning_loss.writeoff_lines(asset, institution, counterparty, amount)
provisioning_loss.recovery_lines(asset, institution, counterparty, amount)nfa
nfa.transfer_lines(asset, from_holder, to_holder, amount)
nfa.encumber_lines(asset, holder, amount)
nfa.release_lines(asset, holder, amount)Collection Stdlib
Collection functions are pure. They never mutate in place. Always assign the return value back to storage.
vec
vec_push(vec, item) # new Vec with item appended
vec_pop(vec) # new Vec with last item removed
vec_len(vec) -> u64
vec_get(vec, idx) # element at index; fails if out of bounds
vec_contains(vec, item) -> boolself.checkpoints = vec_push(self.checkpoints, block_ts)map
map_get(map, key) # value for key, or type default if absent
map_set(map, key, value) # new Map with key set
map_remove(map, key) # new Map with key removed
map_contains(map, key) -> bool
map_len(map) -> u64self.balances = map_set(self.balances, owner, new_amount)The compiler rejects bare vec_push/vec_pop/map_set/map_remove as statements where the result is not assigned — a fatal error.
Financial Balance Helpers
Balance[T] storage fields are updated through tracked helpers:
credit(position, amount)
debit(position, amount)
amount_of(position) -> u128credit and debit are statements. amount_of is read-only and can be used in views or guards. Raw u128 arithmetic is not recognized as money.
Context Vault
ctx.vault() -> AddressReturns the deterministic implicit vault address for the current contract instance. Use it when a contract needs to receive, hold, or release value without introducing a user-controlled burn address or a zero-address sentinel.
KYC Helpers
ctx.kyc_verified(account) -> bool
ctx.kyc_level(account) -> KycLevel
ctx.kyc_compat(account, schema) -> bool
ctx.kyc_verifier(account) -> Address
ctx.kyc_expires_at(account) -> u64These read the deterministic ledger snapshot. They do not fetch private KYC evidence from the validator.
Spending Helpers
spending.verify_intent(card_pubkey, card_curve, vault_id, merchant,
token_id, amount, nonce, expires_at,
signed_intent) -> boolVerifies the PaymentIntentV1 card signature used by SpendingVault, AuthorizedSpendingVault, and CreditCardVault.
Factory Helpers
derive_child_id(template_id, requester, salt) -> AddressDerives a deterministic child contract id (contract:<hex16>) for ProductTemplate flows.