Waher.Script 2.15.0. Token creation and the first transition still need to be tested on your development Neuron.
Prerequisites
- Complete contract authoring and submission.
- Obtain an approved Creator Legal Identity, its signing key, and access to token and state-machine Agent API operations.
- Confirm the provider supports this token creation vocabulary and the selected schema set.
- Arrange the TrustProvider role, template approval, any creation charge, and the provider’s signing procedure. You cannot sign the provider’s role with your Creator key.
- Confirm an accepted value, currency, commission percentage, and expiration date. Zero value in the sample request is a placeholder choice, not a guarantee of free creation.
1. Start with the complete definition
Save the complete definition below asnote-token.xml, or download the XML file.
Complete token creation contract
Complete token creation contract
2. Understand the transition
The machine initializesCount to zero. In Waiting, OnTextNote invokes RecordNote. A successful action enters Complete; a failed action enters Failed. Both states invoke End.
Script contains raw Neuron Script. The value attribute uses braces to evaluate an expression. NextCount is a calculation variable; PersistVariable records Count for subsequent machine state. An ordinary assignment alone does not replace that persistence step.
The expected successful result is Count = 1. Later notes should not repeat this ended machine’s step. This is a design expectation to verify on your provider, not a general duplicate-event guarantee.
Read Script syntax and execution contexts when changing the calculation. If you add a less-than comparison in an XML attribute, escape it as <.
3. Validate before proposing
Validate the complete file against the contract, token, and state-machine schemas, following local validation. Check that each state and action reference names a definition in the same machine. Expected result: the schema set compiles, the XML validates, and all explicit machine references resolve. The core expressionCount:=0; NextCount:=Count+1; NextCount returns 1; see Script expressions.
Neither check approves the template or runs the machine in its host context.
4. Obtain creation attributes and template approval
Send the following requests over HTTPS with your account’s exact host, JWT, and application URL asReferer. Replace every placeholder before sending a request.
currency, commission, and trustProvider. A missing provider identity is a provisioning issue to resolve before creation. Confirm how these values apply to the accepted template and charges.
Base64-encode the complete note-token.xml file’s UTF-8 bytes and propose it:
Template identifier and follow the sandbox automatic review or operator approval process. Use Legal/GetContract with that identifier as contractId to observe the template lifecycle. Continue only with an approved, usable template. Template approval does not supply the TrustProvider signature required by this creation contract.
5. Create and sign the creation contract
Prepare the creation request:- Set the approved template ID.
- Assign
Creatorto your approved Legal Identity andTrustProviderto the provider’s approved identity. - Set
ValueandCommissionPercentas JSON numbers. Replace the quoted commission placeholder with an actual number. - Set
Currencyto the accepted string andExpiresto an ISO 8601 date-time accepted by the provider within the creation contract’s valid period. - Choose
FriendlyName, from 1 to 80 characters.
Contract ID. Retrieve the instance:
Legal/GetContract and the same contract ID. Coordinate the provider’s required signature separately. Observe all required signatures and the creation contract’s final state. Do not assume your first signature creates the token.
6. Find the created token
Retrieve tokens associated with the creation contract:Tokens structure for the token associated with this creation contract. Preserve the exact identifier. An empty list can mean creation is pending or failed; inspect the contract and provider result before submitting another creation request.
Use the returned token identifier to retrieve the token and machine state:
Waiting with Count = 0. The state response contains CurrentState; use its returned structure rather than assuming an invented flat state field.
7. Send an owner note and observe the result
Send this request with the account that owns the token, using the same token ID. The request setspersonal to false.
StateMachines/GetCurrentState above, and retrieve the event history:
Note. A note being accepted is separate from confirming the intended machine outcome. Retrieve the state and event history until the provider’s documented completion window, with bounded polling in your application.
For this example, verify Complete, the persisted Count = 1, and the corresponding note/action history. Record actual results and the Neuron build before treating the workflow as tested. If you receive Failed, preserve the returned diagnostic/history information and resolve the action failure before adapting the template.
Diagnose and adapt
When adapting this example, keep role references, parameter names, state IDs, and action references aligned. Update human-readable terms whenever automated behavior changes, validate the new file, and obtain a newly reviewed template when required by your provider.
Retain the creation contract ID, token ID, template revision, input values, and observed state/history. Ending this custom machine does not itself destroy the token or delete its contract. Follow the asset’s supported expiration and retention rules; transfer and destruction require their own approved behavior.