Skip to content

Contract templates ​

A template is reusable contract bytecode in the on-chain registry. Anyone can deploy a contract from it in the cabinet's Market; the template's interface tells the cabinet which fields to ask for at deploy time and which functions to offer on the contract's page.

Publish a template ​

Only a .node (validator) address can publish (Market → Create Template, or POST /api/v1/templates/register signed by the node's owner key). You give:

FieldRequiredNotes
Template nameyesShown on the Market card
DescriptionnoOne or two sentences on what the contract does
Usage royalty (NRO)noPaid to you each time someone deploys from the template (0 = free)
WASM bytecodeyesUpload the .wasm or paste its hex (0061736d…)
Interface (ABI)no, but recommendedConstructor fields and functions, see below

The template id is the SHA3 hash of the bytecode, so the same bytecode cannot be registered twice. To publish a changed interface for the same bytecode, retire the template (author only) and register it again.

Describe the interface ​

Build it in the visual editor (+ Field, + Method; each method has a one-sentence description field) or switch to { } Raw JSON and paste an object with two lists:

json
{
  "init_params": [
    { "name": "seller", "label": "Seller address", "type": "text", "required": true,
      "placeholder": "neuro:seller.human",
      "note": "Who receives the NRO when the deal is released" }
  ],
  "methods": [
    { "name": "release", "label": "Release to the seller", "type": "write",
      "description": "Pay the escrowed amount to the seller and close the deal.",
      "args": [] },
    { "name": "balance_of", "label": "Balance Of", "type": "read",
      "description": "How many tokens an address holds.",
      "args": [ { "name": "address", "label": "Address", "type": "text" } ] }
  ]
}

Constructor fields (init_params) are the deploy form. Their values are passed to the contract's initialize function right after the deploy.

KeyMeaning
nameArgument name the contract reads
labelField title in the deploy form
typetext or number
requiredThe deploy button waits until it is filled
placeholder, default, min, max, maxlengthInput hints and limits
noteOne line under the field explaining it

Functions (methods) are what users can call once the contract exists.

KeyMeaning
nameExact function name in the contract
labelTitle the user sees
descriptionOne sentence on what the function does — shown on the deploy page ("What this contract can do") and on the contract page
typeread (free, no transaction) or write (a signed transaction, uses gas)
argsArguments, each { "name", "label", "type" } (text or number)
ownerOnlytrue hides the function from everyone but the contract owner

The repository's templates are complete examples: neurochain/contracts/dao/dao.abi.json, gov_dao/gov_dao.abi.json, escrow/escrow.abi.json.

Without an interface ​

Publishing works with bytecode alone; the interface is stored as []. Then:

  • the deploy page has no constructor fields, so the contract is deployed without initialize. A contract that needs it stays uninitialized until its deployer calls initialize (other callers are refused by well-written contracts — the repo's templates check the deployer);
  • the deploy page cannot list what the contract can do;
  • the contract page has no ready-made forms — only the generic Call Contract panel: the user types a function name and its arguments as a JSON object and presses Read (dry) or Write (TX). It works, but the user has to know the function names and arguments;
  • the Market card shows 0 methods.

Security score ​

Every template card shows the score its deploy would get — the same verdict the validators apply at deploy:

  • reviewed — the bytecode is on the validators' whitelist: score 100, no analysis;
  • otherwise VMGuardian analyses the bytecode and lists its findings (rule and severity: critical, warning, info). A deploy whose risk reaches the network threshold is refused.

Every deployed contract gets a security certificate in the deploy itself: the score it passed with, its level (Gold, Silver, Bronze), the bytecode hash and VMGuardian's findings, issued by neuro:vmguardian.cert. When a release updates the analyzer, the chain re-scores every contract and re-issues the certificates whose score moved.

The reentrancy rule flags a function that writes storage after calling another contract (call_contract) on the same path; apply your own state changes before external calls (checks-effects-interactions).