Smart Contract operations on tokens
One of the ways an owner of tokens can perform operations on them, is by using smart contracts referencing the tokens. The operations that can be used are defined by the https://paiwise.tagroot.io/Schema/NeuroFeatures.xsd
namespace, the same namespace used to create the tokens.
The operations supported include:
Create
Destroy
Donate
(new)Transfer
Create
A smart contract with the Create
machine-readable element creates one or more Neuro-Feature tokens. Creating tokens may require a comission fee to be paid first, as defined by the smart contract template used. An initial value is set by the creator.
Destroy
Destroy
on the other hand, in a smart contract, destroys the token, if such is permitted by the token definition. During the creation of the token, the creator defines under what cirumstances the tokenⓈ can be destroyed, and by whom (if at all):
CreatorCanDestroy
defines if the creator is allowed to destroy the token.OwnerCanDestroyBatch
specifies that an owner can destroy a token or tokens, but only if the owner is the owner of all tokens created using the same creation contract (here called a batch of tokens).OwnerCanDestroyIndividual
allows the owner to be able to destroy any token it owns, regardless if other owners owns tokens from the same batch.CertifierCanDestroy
can be used to give privileges to a certifier signing the token creation contract, to destroy any of the certified tokens. This gives the certifier the authority to ensure and enforce the rules set forth in the creation contract.
Donate
The Donate
operation is new as of build 2025-01-30
. It allows an owner to donate a token or set of tokens to another, without a monetary recompensation. This operation does not change the registered last value of the token. (This is the initial value set during creation if the token has never been transferred, i.e. sold.) The donation operation registers a specific donation event for transparency, showing the ownership has changed without compensation.
Transfer
The original way to change ownership of a token is called Transfer
and includes a payment of eDaler® to compensate for the transfer. This payment may include a commission to the Trust Provider hosting the token. The payment will also be recorded as the new value of the token, and a corresponding event will be recorded, for transparency, giving future new owners (buyers) a way to transparently review a token’s history and trade.
LegalLab
The LegalLab repository contains multiple examples of token operations. This includes examples of the Create
, Destroy
, Donate
and Transfer
operations.
Data Sheets in Digital Sensor Twins
The LegalLab repository contains an example smart contract for creating digital sensor twins. This template, together with the LegalLab utility, has been updated to support uploading and presentation of data sheets for the underlying sensors being mirrored digitally.
The process of attaching such data sheets is straight-forward:
Publish the new digital sensor template to your Neuron®, and get it approved.
Create a smart contract based on this template, pointing to the sensor you want to mirror.
Before signing the contract, upload any number of data-sheets appropriate for the digital twin. If these attachments are in the following formats, they will be presented together with sensor data from the sensor:
- Plain text file (
*.txt
) - Markdown text file (
*.md
) - Image files (
*.jpg
,*.png
,*.webp
, and other supported formats) - Microsoft Word files, in the interoperable OpenXML format (
*.docx
) - Microsoft Excel files, in the interoperable OpenXML format (
*.xlsx
)
- Plain text file (
- Once data sheets have been uploaded, sign the contract accordingly.
- Once the token has been created, create a Present Report to view sensor data, together with associated data sheets.
Note: For performance reasons, it might be less resource-intensive and quicker to pre-convert MS Word files to Markdown, and upload the Markdown file.
Note 2: For security reasons, only files (actually Internet Content-Types) recognized by both LegalLab and the Neuron® will be accepted.
Note 3: To be able to upload and process Microsoft Word documents and Excel spreadsheets, you need to install the Microsoft Interoperability package. You can also check microsoft for more information related to Microsoft interoperability.
Contract Attachments in LegalLab
While the TAG Neuron® and the underlying infrastructure has supported attachments on legal identities and smart contracts for a long time, LegalLab has not enjoyed this support, until now.
The process is simple: After having created a smart contract, from a template, but before signing it, it is possible to upload signed attachments to the contract. Attachments can be of any type that is recognized by the embedded content architecture of both LegalLab, and the TAG Neuron® to which it is connected. Each uploaded attachment is signed by the uploader, and the signature is stored with the contract. When anyone signs the contract, the references to uploaded attachments is included in the signature, which is the reason that new attachments cannot be uploaded once the contract has received a client signature.
You can find the area where you manage contract attachments above the list of client signatures. After creating a contract, while it is Approved, but not yet with signatures, this area would look as follows:

Press the Upload button to upload relevant files. A record of each upload will be displayed, after all validation checks have been performed:

To double-check the contents of an attachment, you can always download it by pressing the corresponding Download button. You can also remove an attachment by pressing its Remove button. Once you start signing the contract, attachment buttons that modify the contract will be disabled:

LegalLab and identities with e-mail addresses
Some operations with Legal identities, require a verified e-mail address. Such an e-mail address is typically available in IDs created by the TAG ID app, or Agent API, where e-mail is part of the onboarding process. When using LegalLab however, there’s typically not an onboarding process available, and accounts are created manually by the operator, for development purposes. For that reason, e-mail was not part of Legal Identities created by LegalLab.
LegalLab has now been updated, allowing users to create new Legal Identities with an associated e-mail address:

By getting the latest code and rebuilding, you will get access to this new property. You need to apply for a new ID, to get the e-mail address engraved into your identity application.
Note: When creating an account, even manually, the operator will associate the account with an e-mail address. This e-mail address must match the e-mail address in the application, or the application will fail
Creating a Neuro-Feature token on credit using AgentAPI
This article describes how you can use the Agent API to create Neuro-Feature™ tokens on credit. It assumes you already have an account, and a wallet created. The wallet will receive the tokens created, as well as receive the credits required to pay for any token creation fees required. If you do not have an account with a wallet, check out the recipe Creating a wallet using Agent API.
The process is as follows:
- A smart contract template is created and approved. The purpose of the template is to define how tokens are created, and their legal context.
- A smart contract is created based on the approved template.
- Neuro-Credits™ are bought, to generate sufficient eDaler® in the wallet to create the tokens.
- Invoices with reminders are sent to the e-mail registered for the account.
- Payment of invoices can be done at a later stage (before the due-date) on the links provided in the e-mails.
- The contract is signed. This casues a series of events:
- The token generation process to start (if contract successfully approved, and not failed).
- Funds required to create the token or tokens are withdrawn from the wallet.
- The created token or tokens are received in the wallet.
Creating a smart contract template for token creation
The creation of smart contract templates is done outside of the scope of the Agent API. It is typically a development process, where token developers generate the template in some form of tool, such as LegalLab, and publish the templates on Neurons. Once the templates have been approved by the Neuron® operators, they can be the basis of creating smart contracts using the Agent API. When creating a smart contract based on a template, you can change the parties that sign, and the parameter values, within the valid ranges defined by the template, but you cannot change the underlying definition of the token, or any human-readable sections or validation rules of the smart contract template.
Note: The LegalLab repository contains many examples of templates for creating Neuro-Feature™ tokens. These can be used for development purposes, and for testing the concepts described in this article.
Creating a smart contract for token creation, based on a template
When automating the creation of smart contracts based on a smart contract template, you typically need the following information:
- A Contract ID for the template.
- What Roles are defined in the template, and how many are needed of each for the contract to become valid.
- What Parameters exist, and their types and valid value ranges.
This information is readily available from the template itself, and it may vary from template to template. It can also be provided by the developer of the template. But there are some roles and parameters that will occur frequently, if they are not hard-coded into the contract template itself. They are provided here, for reference:
Common Roles | ||
---|---|---|
Role | Use | Description |
Creator |
Required | The creator of the token. The party that signs the contract as a Creator pays the fees required to create the token or tokens. This would be the Agent API client, in the example of this article. |
Owner |
Optional | If the template allows the owner to be different from the creator, the party that signs as Owner will receive the created tokens in their wallet. |
TrustProvider |
Required | This role is reserved for the Neuron® itself. The Trust Provider is the party that permits the creation and hosting of the token, and assures the integrity of the token, as well as protects the confidentiality and privacy of the associated information. |
Valuator |
Optional | A party that attests to the initial value stated for the contract. |
Assessor |
Optional | A party that has provided necessary input in the creation of the token. |
Certifier |
Optional | A privileged role albeit external role of a token. They can certify to the correctness, legality, contents or context of the token. They can also be given special privileges with control over the life-cycle of the token (meaning, if the token definition permits it, they can kill the token if compliance quirements are not met). |
Witness |
Optional | A witness to the signature and creation of the tokens. |
Common Parameters | |||
---|---|---|---|
Parameter | Use | Type | Description |
Value |
Optional | Numeric | The initial value of the token. |
Currency |
Optional | String | The currency of the token. |
CommissionPercent |
Optional | Numeric | The number of percent of the value that needs to be paid by the creator, for the creation of the token or tokens. |
Note: There may be other parameters available that are required, depending on the type of token that is to be created. Check with the creator of the token definition to get a detailed list of parameters required to be set.
Getting token creation attributes
The Currency
and CommissionPercent
parameters that will be accepted by the Neuron®, as well as the Legal Identity identifier for the TrustProvider
Role, can be retrieved by calling the GetCreationAttributes resource using the Agent API. After retrieving these values, you can preset the parameter values accordingly.
Buying Neuro-Credits™
When you know the amount of eDaler® that is required to create a token, or the tokens, you can generate eDaler® on credit, by buying Neuro-Credits™. You can also generate more eDaler® than the token creation requires, and use it for multiple operations, to save on invoicing fees. Use the following resources in the AgentAPI to manage eDaler® in the wallet:
To get the current balance of the wallet, call the GetBalance resource.
To generate eDaler® in the wallet, you buy eDaler®. To see options available for buying eDaler®, call the GetServiceProvidersForBuyingEDaler resource. It will present configured options available for your choice of country and currency. Some of these providers are contract-based (i.e. they are initated by signing a smart contract with relevant information), and some are initiated by collecting information from the user via an external web page.
If you already know what service provider you want to use, like in the case for using Neuro-Credits™, you can skip this part. The Service Provider ID in this case is
TAG.Payments.NeuroCredits
, the Service ID isTAG.Payments.NeuroCredits.NeuroCreditsService
, and the ID of the smart contract template for initiating the process is2cdbfa69-6c21-82d9-880e-301af77b53f6@legal.paiwise.tagroot.io
(at the time of writing; you might want to double-check this regularly).To initiate the process of buying eDaler®, you can call the InitiateBuyEDaler if the service collects information from external web pages. If the process is started via smart contracts (like in the case for Neuro-Credits™) you simply create and sign a smart contract based on the template provided for the service.
Following is some information required to create a smart contract for buying Neuro-Credits™:
Defined roles Role Description Buyer
The one buying eDaler®, i.e. the Agent API client. TrustProvider
The Neuron® itself, giving the credit to the buyer. The following parameters need to be provided:
Required parameters Name Type Description Amount
¹Numeric Amount of eDaler® to buy. Currency
²String Currency to buy. InvoiceFee
³Numeric A fee for each invoice that is sent. Message
String A text message that will be included in invoices sent to the client, for reference. Period
³Duration The duration of the credit, or the time between installments, if multiple installments are used. PeriodInterest
³Numeric The interest rate of the (remaining) amount, calculated over the period. Installments
4Integer Number of installments desired. Some of the parameters are limited in range, and some must be set to a fixed value, depending on the configuration of the Neuro-Credits™ service on the Neuron®. To get these values and ranges, you call the GetServiceProvidersForBuyingEDaler resource:
- Amount is restricted to the maximum remaining credit allowed to the client.
- Currency must be the same as defined in the wallet of the client.
- The fees, period and interest rates are fixed by the service.
- The amount of installments allowed may vary on client.
Note: A smart contract with parameters outside of the authorized ranges will fail the contract.
The following parameters will be required to exist in the legal identity of the buyer, and will be visible to auditors of the contract, if a personal credit is requested:
- Full Name
- Personal Number
- Full Address
- Postal Code
- City
- Country
If an organizational credit is requested, the following additional information must be available in the legal identity of the buyer. This information will be visible to auditors of the contract:
- Organization Name
- Organization Number
- Department
- Role
- Organization Address
- Organization Postal Code
- Organization City
- Organization Country
Additional information that may be required include an associated e-mail address and phone number of the client. These will not be engraved into the contract however, for privacy reasons, and only be available to the operators of the service.
Once the parameter values have been determined, you create the smart contract by calling the CreateContract resource, and then sign it using the SignContract resource. Once everyone has signed the contract except the Trust Provider, the contract is analyzed, and the Neuron® signs as Trust Provider given that all parameters are correct. If information is incorrect or the process fails, the contract will be set to a
Failed
state, otherwise the contract will be set to aSigned
state and the corresponding eDaler® will be generated and placed in the wallet of the client. Al lasynchronous processes generate messages sent to the client, which the client can read by calling the PopMessages resource.
Note: Any changes to the balance of the wallet, or transactions being performed, are notified to the client asycnrhonously (i.e. as they happen). You can use the PopMessages resource to retrieve all such asynchronously sent messages to you.
Getting the human-readable text of a smart contract
The GetContract resource allows you to get the contents of a smart contract (that you have access rights to). If you want to present the contents of the contract to the user, you have to choose if you will render the contents, based on the existing object-model for human-readable text, or if you want the Nueuron® to format it for you. The default is to let the client render the contents in its own way. If you provide a value in the Format
argument, in the call to the GetContract resource, you can get the human-readable texts pre-rendered instead in the corresponding format. The following formats are supported (at the time of writing):
Human-readable text formats | |
---|---|
Value | Format |
Markdown |
Texts are returned in Markdown format. Markdown is easy to edit in text editors, and can be transformed to any of a series of other formats. |
Html |
Text is converted to HTML for insertion into existing HTML (i.e. it does not include HTML, HEAD and BODY tags.) |
Text |
Contents is converted to plain, unformatted text. |
Xaml |
XAML is generated for use together with Windows Presentation Foundation (WPF). |
XamarinXaml |
A special dialect of XAML, for use in Xamarin Forms, is returned. |
SmartContract |
An XML string containing the contents using the smart contract object model is returned. |
Signing smart contract to create tokens
When it is time to sign the contract, you call the SignContract resource for each signature you perform. You will sign the contract using the legal identity referred to in the call, and using the associated key. A contract becomes signed when all required signatures have been provided.
When then smart contract is to create a Neuro-Feature™ token, one of the roles is that of a Trust Provider. This role is reserved for the Neuron® itself, and represents the party that will host the token. Typically, a smart contract for token generation includes at least a Creator role, and often (but not always) an Owner role as well (if different from the Creator. If no Owner role is available, the Creator becomes the initial Owner.
When all signatures, except then Trust Provider has signed, the Neuron® validates the contract and signatures, and if all is OK, signs the contract itself. Once the contract has been signed, the token creation process begins. In this step, if the Neuron® detects there are missing funds, or other prohibited content is detected within the token itself, the contract becomes failed, and a message is sent to the creator.
Note: All changes to the contract, and generated token or tokens are notified to the concerned parties asynchronously. Use the PopMessages resource to receive such notification messages.
Transferring ownership of token
Once a token is created and alive, it can be transferred to a new owner. Such a transfer is basically a contract in itself. In this contract, the prospective new owner (or buyer) agrees with the current owner (or seller) to transfer the token from the seller to the buyer, and transfer an agreed amount of eDaler® from the buyer to the seller. The amount of eDaler® transferred is logged on the token itself, and visible to future buyers, and acts as the basis for the current value of the token.
The LegalLab repository contains example contracts for transferring ownership of a token between owners.
Note: The process of creating a transfer contract, and signing it, is the same as creating the token in the first place: You refer to a template when creating the contract, providing the corresponding parameters, and sign the contract accordingly. The Neurons take care of the rest.
#agent, #api, #neuro-feature, #credit, #edaler, #recipe, #legallab
Posts tagged #legallab
No more posts with the given tag could be found. You can go back to the main view by selecting Home in the menu above.