Voltar para Documentação

Docs Técnicas

Runtime Context

The runtime context is available as ctx.

O conteúdo abaixo vem das fontes técnicas do repositório e é prerenderizado no site para leitura direta por pessoas, crawlers e agentes.

The runtime context is available as ctx.

python
ctx.caller
ctx.block_timestamp
ctx.block_height
ctx.asset
ctx.tx_id
ctx.contract_id
ctx.family_id
ctx.version_id

`ctx.caller`

The actor executing the contract call.

Use it for permission checks:

python
require(ctx.caller == self.borrower, "only_borrower")

`ctx.asset`

The asset supplied by the contract call.

Use it when building posting plans:

python
post(loan.repayment_lines(ctx.asset, self.lender, self.borrower, amount))

`ctx.block_timestamp`

Ledger-provided execution timestamp.

Useful for accrual:

python
let interest = loan.accrue_interest(
    self.principal_due,
    self.rate_ppm,
    self.last_accrual_ts,
    ctx.block_timestamp)

Identity Fields

These fields provide execution attribution:

python
ctx.tx_id
ctx.contract_id
ctx.family_id
ctx.version_id

Contract Vault

python
ctx.vault()

Returns the implicit vault address for the current contract instance. The vault address is deterministic, non-zero, and owned by protocol accounting, so custody contracts do not need a user-supplied vault_account sentinel.

python
ctx.transfer(self.token_id, ctx.caller, ctx.vault(), amount)

KYC Snapshot Queries

KYC helpers are exposed as context intrinsics. They read the deterministic KYC snapshot available during execution; they do not open network connections to a validator.

python
ctx.kyc_verified(account)
ctx.kyc_level(account)
ctx.kyc_compat(account, schema)
ctx.kyc_verifier(account)
ctx.kyc_expires_at(account)

Use them for compliance gates:

python
require(ctx.kyc_verified(ctx.caller), "kyc_required")
require(ctx.kyc_compat(ctx.caller, "kyb-v1"), "schema_required")

Detailed KYC disclosure remains private and wallet-authorized; see KYC And Private Sharing.