Syscoin

Syscoin Core Developer Portal

Comprehensive guides and documentation to help you start working with Syscoin as quickly as possible, and support if you get stuck.

Get Started

HOWTO: Create a Token

Basic Walk-through

This guide helps you create a new Syscoin Platform Token (SPT) using Syscoin Core 4

📘

NOTE

You should use a separate walk-through if you are creating a Bridge-enabled token that correlates with an existing Ethereum ERC-20. HOWTO: Provision the Bridge for your ERC-20

🚧

Changes to the Syscoin Token Platform since Syscoin Core 3.0

  • Tokens can now be used with Syscoin Bridge
  • New option: aux_fees structure (learn more)
  • New option: contract (reference coming soon)
  • asset_guid is the token unique identifier
  • Assets are now address-only. On-chain aliases have been removed for greater scalability.
  • P2PWKH and P2WSH are the current supported witness programs. Future witness programs may be included in Bitcoin Core and Syscoin Core enhancements to extend functionality.

1. Generate a new Syscoin address for your SPT.

Use the default address type (bech32 which begins w/ 'sys'), do not use the legacy option.

> getnewaddress "My Address Label"
sys1q09vm5lfy0j5reeulh4x5752q25uqqvz34hufdl

2. Send 502 SYS to the new address.

The token creation fee is currently 500 SYS, plus a little extra to cover future transactions such as asset allocations and updating your token spec. Wait until your transaction of 502 SYS has at least one network confirmation, then proceed to the next step.

3. Define and create your token

We will now define then create the SPT using the assetnew command. In this example we will create a basic SPT without the contract or aux_fees options.

>help assetnew

assetnew "address" "symbol" "description" "contract" precision total_supply max_supply update_flags {"address":"str","fee_struct":["","",...]} "witness"

Create a new asset

Arguments:
1. address                  (string, required) An address that you own.
2. symbol                   (string, required) Asset symbol (1-8 characters)
3. description              (string, required) Public description of the token.
4. contract                 (string, required) Ethereum token contract for SyscoinX bridge. Must be in hex and not include the '0x' format tag. For example contract '0xb060ddb93707d2bc2f8bcc39451a5a28852f8d1d' should be set as 'b060ddb93707d2bc2f8bcc39451a5a28852f8d1d'. Leave empty for no smart contract bridge.
5. precision                (numeric, required) Precision of balances. Must be between 0 and 8. The lower it is the higher possible max_supply is available since the supply is represented as a 64 bit integer. With a precision of 8 the max supply is 10 billion.
6. total_supply             (numeric or string, required) Initial supply of asset. Can mint more supply up to total_supply amount or if total_supply is -1 then minting is uncapped.
7. max_supply               (numeric or string, required) Maximum supply of this asset. Set to -1 for uncapped. Depends on the precision value that is set, the lower the precision the higher max_supply can be.
8. update_flags             (numeric, required) Ability to update certain fields. Must be decimal value which is a bitmask for certain rights to update. The bitmask represents 0x01(1) to give admin status (needed to update flags), 0x10(2) for updating public data field, 0x100(4) for updating the smart contract field, 0x1000(8) for updating supply, 0x10000(16) for being able to update flags (need admin access to update flags as well). 0x11111(31) for all.
9. aux_fees                 (json object, required) Auxiliary fee structure
     {
       "address": "str",    (string, required) Address to pay auxiliary fees to
       "fee_struct": [      (json array, required) Auxiliary fee structure
         "",                (string) Bound (in amount) for for the fee level based on total transaction amount
         "",                (string) Percentage of total transaction amount applied as a fee
         ...
       ],
     }
10. witness                 (string, required) Witness address that will sign for web-of-trust notarization of this transaction.

Result:
{                      (json object)
  "hex" : "str",       (string) the unsigned funded transaction hexstring.
  "asset_guid" : n,    (numeric) The guid of asset to be created
}

Examples:
> syscoin-cli assetnew "myaddress" "CAT" "publicvalue" "contractaddr" 8 100 1000 31 {} ""
> curl --user myusername --data-binary '{"jsonrpc": "1.0", "id": "curltest", "method": "assetnew", "params": ["myaddress", "CAT", "publicvalue", "contractaddr", 8, 100, 1000, 31, {}, ""]}' -H 'content-type: text/plain;' http://127.0.0.1:8370/

📘

aux_fees

The aux_fees parameter is used to specify a custom fee structure for your token. Learn about aux_fees and how to use them.

assetnew "<tokenAddress>" "<tokenSymbol>" "<tokenDescription>" "<contractERC20>" <precision> <totalSupply> <maxSupply> <auxFees> "<witnessAddress>"

The command and parameters for creating our simple token look as follows:

> assetnew "sys1q09vm5lfy0j5reeulh4x5752q25uqqvz34hufdl" "XYZ" "My token description" "" 8 100000 9999999999 31 {} ""

Once you have defined your assetnew parameters and checked them thoroughly, you may execute the command.

After executing, the output will consist of a raw unsigned transaction (hex), and the [asset_guid] of your soon-to-be SPT. Note [asset_guid] for later use.

Now unlock your wallet in order to sign and send this raw transaction. Unlocking is done by using the command walletpassphrase YOUR_PASSPHRASE_HERE 600. The 600 is how many seconds the wallet will remain unlocked. Set as needed, but be conservative for security sake. You can reissue this command if walletpassphrase expires, and you can manually re-lock your wallet using walletlock.

Now copy the raw unsigned transaction (hex) from the assetnew output (omitting quotes) and paste into the following command.
signrawtransactionwithwallet PASTE_HERE

Execute the command. The signrawtransactionwithwallet command will output the signed transaction (hex). Copy this new hex (omitting quotes) and paste into the following command.
sendrawtransaction PASTE_HERE

Execute the command to send your transaction across the network. The output presented here should be your transaction id. Note this transaction id for later use.

After this transaction has at least one confirmation you can execute the following command to review your SPT spec as it is present on the Syscoin blockchain.
assetinfo [asset_guid]

It should look similar to this and reflect the attributes you set in assetnew:

> assetinfo 490411133
{
  "asset_guid": 490411133,
  "symbol": "XYZ",
  "txid": "341af480b61361386a8b63edabc5cecbbc16799c043ca15058eb654bb07dcf74",
  "public_value": "{\"description\":\"My token description\"}",
  "address": "sys1q09vm5lfy0j5reeulh4x5752q25uqqvz34hufdl",
  "contract": "",
  "balance": 100000.00000000,
  "total_supply": 100000.00000000,
  "max_supply": 9999999999.00000000,
  "update_flags": 31,
  "precision": 8
}

4. Issue your tokens

Introduce a quantity of tokens into circulation by issuing them from the token address we have been using above. To do this, create another new address using getnewaddress which we will designate as the recipient of these new tokens, then use assetsend to issue the tokens.

> getnewaddress "My address label"
sys1qt5svp74tvskr6care5zd05449x3ukctz9lattv

> assetsend 490411133 sys1qt5svp74tvskr6care5zd05449x3ukctz9lattv 10000

Now once again make sure your wallet is unlocked, then sign and send the transaction using the hex outputs as described in Step 3.

Wait for your transaction to receive at least one confirmation. Now check your allocation balance (assetallocationinfo)

$ syscoin-cli assetallocationinfo 490411133 sys1qt5svp74tvskr6care5zd05449x3ukctz9lattv
{
  "asset_allocation": "1532854725-sys1qt5svp74tvskr6care5zd05449x3ukctz9lattv",
  "asset_guid": 490411133,
  "symbol": "XYZ",
  "address": "sys1qt5svp74tvskr6care5zd05449x3ukctz9lattv",
  "balance": 100000.00000000,
  "balance_zdag": 100000.00000000
}

Updated 10 months ago


What's Next

Now that you have created your token and issued your first allocation, proceed to Using Syscoin 4 Tokens to learn how token allocation owners can re-allocate ('send') tokens between one another.

Using Syscoin 4 Tokens

HOWTO: Create a Token


Basic Walk-through

Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.