• Brendan Lee

Creating a Tokenized Smart Contract (4/5)

Updated: Feb 13, 2020

Depending on the type of token being issued, contracts require varying levels of documentation and complexity. The smart contract is adaptable and can represent anything from very simple agreements between friends right up to the definition of corporate or state-level bodies.

A smart contract is defined in a request action called a "Contract Offer."

To learn more about how a Contract Offer is structured, check out the documentation at:


The contract offer action contains all necessary information to establish a legal contract including the legal text of the contract, information on the type of contract, links to supporting documentation and more.

Importantly, the contract definition action includes data on the who the issuer is that is asking the agent to establish the contract. The issuer data is contained in a compound data structure called an ‘Entity’ which can be expanded to define a company structure including multiple personnel, addresses and other pertinent details as required to establish the legal identity for the contract. For more information on the Entity type, have a look at the docs:


The contract offer can also include details such as data on the contract operator (also an entity which can be a third party distinct from the contract issuer), details of any oracles that might be required to confirm the details of the administrator, a blockheight for the oracle to sign, fee settings for the contract and any rules needed for asset management such as the quantity of different asset types that can be managed, voting rights and more.

Building the Contract Offer action

Before we can start using the smart contract, we must set up the contract offer that we are going to send to the agent. This is prepared as a .json file. For this contract offer, my file looks like the following:

This is a very simple contract set up in the name of my company, Coinstorage Pty Ltd.

The BodyOfAgreementType indicates that the wording of the contract is in the Tokenized Body of Agreement Format. For the purposes of this contract, the BodyOfAgreement is simply the following text encoded in hexadecimal:

“This contract manages the ownership rights to Coinstorage Pty Ltd and all other tokens used for purposes such as loyalty programs, prizes and coupon distribution.”

While this is a simple example, it is possible to create a full set of legal documentation in Markdown format and convert that text to hex for the definition of your smart contract.

The ContractType is specified by the issuer and should be an appropriate description of what the contract does.

Issuer is the entity that owns the smart contract and who is the legally responsible party for any tokens it issues. In this example, it has the legal details of my company, Coinstorage Pty Ltd and lists myself as CEO.

ContractFee sets the price for request actions to be looked at by the contract.

MasterAddress gives an address from which a command to migrate the contract to a new address can be issued. This is a useful backup in cases where a contract’s private key has been lost or compromised. This is the public key in HEX format. To generate this value, use the following command below in your user directory:

$ smartcontract convert yourKeyHere

You must also add '20' to the start of the key string to tell the tool that it is a P2PKH address.

Keep in mind that fixed width fields such as TerritoryStateProvinceCode must be the expected length which is achieved here by adding spaces.

Checking the Contract Offer

Before sending the Contract Offer, check that your JSON builds properly using:

$ smartcontract build cl ~/coinstorage/C1_coinstorage.jon --hex

If your JSON file has no issues, it should return the hex corresponding to your contract offer.

Now build the TX using:

$ smartcontract build cl ~/coinstorage/C1_coinstorage.jon --tx

This should return the full tx structure including the funding coin details and change output.

Send your contract offer

Send your contract offer to the network using:

$ smartcontract build cl ~/coinstorage/C1_coinstorage.jon --tx

For my contract, the corresponding TXID is:


I was very surprised how fast the smart contract agent responded. By the time I had refreshed the page on www.whatsonchain.com I could already see the smart contract’s response which has TXID:


You can see that it properly mirrored all the settings from my transaction.

The next step is to update your tool to see the response transaction use the sync command:

$ source ~/.client/cli.dev.env && smartcontract sync


You have created a Smart Contract using

the Tokenized Smart Contract agent.

Next week we will look at how to create and send assets using the platform.


Blog 1

Blog 2

Blog 3

Blog 4 You're reading it.

Blog 5

About the Author

Mr. Lee's career to date has been focused on increasingly senior roles within industrial design, automation, and control, focusing on software design and implementation. Most recently, Mr. Lee was the Bitcoin Engineering Lead for the Tokenized project team who developed the Tokenized protocol. The Tokenized protocol is a comprehensive, regulation-friendly solution for businesses to create tokens for real-world assets on the BSV blockchain. Follow him.

Subscribe to our FREE weekly newsletter to follow our journey

into building a business at the intersection of community & technology.


Subscribe to our weekly newsletter to follow our journey into building a business at the intersection of community & technology. 

©2021 by Faiabrand Pte Ltd
Singapore (UEN: 201841048Z)