Token Creation
How to Create your Security Token
This app covers the most basic and essential functionality of the Polymath protocol: security token creation. Creating a token requires two transactions with Polymath's SecurityTokenRegistry
contract, both of which charge a fee in POLY:
Reserve your preferred symbol.
Configure and deploy the security token.
The Polymath SDK abstracts the smart contract operations, so special knowledge of the SecurityTokenRegistry
contract is required.
First, we need to reserve a token symbol. The SDK interacts with the SecurityTokenRegistry
contract to make reserving token symbols simple:
A successful reserveSecurityToken()
call reserves a symbol to the current user address. Reserving a symbol means that no one else will be able to reserve it while you complete the necessary steps to deploy your security token.
Once reservation.run()
has resolved, it will return a reservation entity. We can use that entity to proceed with the token creation. Method createSecurityToken()
accepts four parameters:
name
: the human-friendly token name.detailsUrl
: an off-chain resource about the token (i.e., webpage).divisible
: whether or not the token is divisible.
Note that reserveSecurityToken()
, as well as all SDK functions, typically receive named parameters in the form of an object. That object wraps all required params such as symbol
and name
.
Symbols are reserved for a period of 60 days, after which they can be claimed by other issuers. You may also renew your reservation before it expires.
All SDK write operations are represented as transaction queues. For each operation, the SDK creates as many transactions as needed to complete the operation. Upon calling queue.run()
, the SDK executes these transactions, sequentially, until completion. Running a queue can result in values (for example, running the queue that creates a security token will return an entity that represents said token).
Transaction Errors
In a perfect world, your token reservation and creation transactions will go through without any issues. However, there are many reasons why a transaction may fail. Some errors are operational, for example, you've lost internet connection during script execution, or the Ethereum account responsible for signing transactions has ran out of ETH.
Another class of errors are revert
errors (smart contract execution errors). One common revert error occurs when we attempt to reserve a token symbol that's been reserved before and has not expired. You may catch the error in the example below:
Finally, you can retrieve the token you've created, either by symbol or by your own address:
A SecurityToken
entity is a js object representation of your deployed securitytoken contract. You may fetch properties such as the token name, symbol, divisibility, and manage all aspects of your security token. User permissions, tokenholder management, and launching your first STO are among some of the features covered in later tutorials.
Last updated