Docs Técnicas
Functions And Entry Points
Every callable function is a contract entrypoint.
Every callable function is a contract entrypoint.
Views
@view
def is_active() -> bool:
return self.activeViews are read-only. The verifier rejects storage writes, events, and economic effects in views.
Transactions
@tx
def request_loan(lender: Address, principal: u128, rate_ppm: u64):
require(self.active == False, "loan_already_active")
self.lender = lender
self.borrower = ctx.caller
self.requested_principal = principal
self.requested_rate_ppm = rate_ppm
emit LoanRequested(lender, ctx.caller, principal, rate_ppm)Transactions may mutate storage and produce effects.
Constructors
@construct
def initialize(admin: Address):
self.admin = adminAn @construct entrypoint is the contract constructor. It may mutate storage like a transaction, but it is one-shot: after it succeeds, the runtime rejects any second call. When a contract declares @construct, all other entrypoints are gated until construction succeeds.
@init is accepted as a compatibility alias, but new contracts should use @construct.
Descriptions
@describe("text") can document a contract or an entrypoint for wallet, explorer, and audit UX.
@describe("Credit card vault with issuer-funded payments.")
contract CreditCardVault:
@describe("Pays {merchant} with a signed card intent for {amount}.")
@tx
def pay(merchant: Address, amount: u128, nonce: u64, signed_intent: String):
require(amount > 0, "amount_required")For functions, {name} placeholders must reference a parameter of that function. {self.field} is accepted as author text, but it is not a protocol proof. AI Audit compares @describe claims with verified effects and can flag mismatches.
Parameters
def repay(amount: u128):Parameter names must be unique.
Returns
def principal() -> u128:
return self.principal_dueReturn arity and return type compatibility are verified at compile time.
Overrides
A child contract can replace a function inherited from a base module:
@tx
override def mint(amount: u128):
require(ctx.caller == self.owner, "only_owner")
require(amount > 0, "amount_must_be_positive")
self.balances[ctx.caller] = self.balances[ctx.caller] + amount
self.total = self.total + amountThe override keyword is required. The verifier rejects an override that does not match any base function name, and rejects a child function that shadows a base function without override.
The @tx, @view, or @construct decorator must still appear before override.
Calling the Base Implementation
Inside an override, super.method(args) calls the original base implementation:
@tx
override def pause():
require(ctx.caller == self.owner, "only_owner")
super.pause() # delegates to Pausable.pause()super is only valid inside an override def. The base function name must match the override name. The call is resolved at compile time — there is no dynamic dispatch.
Selectors
Artifacts include a deterministic selector for each entrypoint. Clients may call by name or selector through the ledger API.