DCore application case: issuing custom tokens (UIA)

Keywords: network less

Custom tokens

To create a new custom token (user_issued_asset), use the create_user_issued_asset method. In addition to the symbol and precision parameters, you can change other parameters by calling the update_asset command. Note that if the parameter is_fixed_max_supply is set to true in the first step, the max_supply parameter cannot be updated by calling the update_asset method. Once the parameters are set, they cannot be modified. The issuer of tokens can also modify it, but only the issuer currently in force can modify it. In addition, please note that core_exchange_rate (core exchange_rate) uses the Chinomoto representation of DCT tokens and is defined as a ratio called "base" and "quote", where "quote" is denominator.

METHODS:
create_user_issued_asset - Create new user-published assets. Some options can then be changed by using the update_asset method.

signed_transaction
create_user_issued_asset(string issuer,
                         string symbol,
                         uint8_t precision,
                         string description,
                         uint64_t max_supply,
                         price core_exchange_rate,
                         bool is_exchangeable,
                         bool is_fixed_max_supply,
                         bool broadcast = false);

Parameters:

  • Issuer - The name or id of the account that pays the fee and becomes the new asset issuer. The publisher name can be updated later
  • Symbol - symbol for newly created assets
  • Precision - The exact value to the right of the decimal point, that is, the currency accuracy, must be less than or equal to 12. Example: If the value is set to 0, the currency precision is 0, that is, there is no decimal point after the number of assets.
  • Description - Detailed description of assets. The maximum length is 1000 characters.
  • max_supply - Maximum issuance of assets. Once the asset is issued, it will exist forever.
  • Core_exchange_rate - Core_exchange_rate (core exchange rate) technically requires that the asset id of the newly created asset be stored. Since the id was not generated when the asset was created, the id can be considered as 1 when creating the price (in the previous example, we used 1.3.1, DCT token code is 1.3.0), and then the block chain will override the previous id with a new asset id.
  • is_exchangeable - Allows indirect conversion between assets and core assets, which is shown as true
  • After is_fixed_max_supply - is negated, the max_supply parameter is modified and displayed as true.
  • Broadcast - If you want to broadcast transactions over the network, it is shown as true

Return value:

  • Create a new custom token signed transaction.

Examples are given to illustrate:

create_user_issued_asset alien MCCC 0 "Mick credits" 10000 {"base":{"amount":200000000,"asset_id":1.3.0},"quote":{"amount":1,"asset_id":1.3.1}} true false true

Respond:

{
  "ref_block_num": 59571,
  "ref_block_prefix": 4222948911,
  "expiration": "2018-04-23T14:06:20",
  "operations": [[
      3,{
        "fee": {
          "amount": 100000000,
          "asset_id": "1.3.0"
        },
        "issuer": "1.2.30",
        "symbol": "MCCC",
        "precision": 0,
        "description": "Mick credits",
        "options": {
          "max_supply": 10000,
          "core_exchange_rate": {
            "base": {
              "amount": 200000000,
              "asset_id": "1.3.0"
            },
            "quote": {
              "amount": 1,
              "asset_id": "1.3.1"
            }
          },
          "is_exchangeable": true,
          "extensions": [[
              1,{
                "is_fixed_max_supply": false
              }
            ]
          ]
        },
        "is_exchangeable": true,
        "extensions": []
      }
    ]
  ],
  "extensions": [],
  "signatures": [
    "20331fca29ff7de6dafb3cb180d1a1920b601c1c2587b2e7634a609f689a55a9575600e4553381362731cfe2dd07a0ab8a2ec7ac7a5b2f764d68d506012658acfe"
  ]
}

API Developer Document for Creating User Published Assets

Issuance of created assets

Custom token issuers can issue custom tokens at any time. The only restriction is max_supply.

METHODS:

  • issue_asset - New share of revenue from issuing custom tokens.
signed_transaction issue_asset(string to_account,
                               string amount,
                               string symbol,
                               string memo,
                               bool broadcast = false);

Parameters:

  • to_account - The name or id of an account that obtains a new share of income
  • Amount - the amount of each token
  • symbol - symbol for issuing assets on behalf of others
  • memo - Information contained in a transaction that is readable to the recipient
  • Broadcast - If you want to broadcast traffic over the network, it is shown as true

Return value:
Signed transactions for issuing new earnings shares.

Examples are given to illustrate:

issue_asset mickey 500 MCC "creating funds" true

Respond:

issue_asset mickey 500 MCC "creating funds" true
{
  "ref_block_num": 39762,
  "ref_block_prefix": 3654765070,
  "expiration": "2017-11-14T13:11:50",
  "operations": [[
      4,{
        "fee": {
          "amount": 552734,
          "asset_id": "1.3.0"
        },
        "issuer": "1.2.73",
        "asset_to_issue": {
          "amount": 500,
          "asset_id": "1.3.34"
        },
        "issue_to_account": "1.2.73",
        "memo": {
          "from": "DCT5VrGVjdjUqmg8bKDXZAC3C8ib28WXJVTmWQ8A9SKXTgGPMX7yP",
          "to": "DCT5wSrG4yDau5ADsCizp6XDiMfYezmUWc81ieakMcxr8EcnkS2Xa",
          "nonce": "12179244057494284541",
          "message": "91d85802da178df3f5f74f419084481a2a01b843449f82a7788bed829fa2b50a"
        },
        "extensions": []
      }
    ]
  ],
  "extensions": [],
  "signatures": [
    "1f215bca01f517105bb8649828abdca0799bea89ec00bfaca992572a5b6a0983571a8c961705fc39dce8d2f024f2eecaea6132e80b6a18d4463ec04f5103272669"
  ]
}

API Developer Document for Issuing Assets

Verify whether the asset has been created by accessing list_account_balances.

Examples are given to illustrate:

list_account_balances mickey

Respond:

list_account_balances mickey
[{
    "amount": "100037396947266",
    "asset_id": "1.3.0"
  },{
    "amount": 500,
    "asset_id": "1.3.34"
  }
]

API Developer Documents Listing Account Balances

Capital pool

Once an asset is issued, you can invest in the asset pool. The asset pool is used for the conversion of funds and DCT tokens. It is helpful to set content prices in relatively stable currencies.

METHODS:

fund_asset_pools - Pay for the asset pool with the specified assets. Custom tokens can choose to create asset pools for core assets (DCT tokens), which can be used to automatically use assets to pay transaction costs for arbitrary transactions (using the asset core exchange rate). Any user can deposit the core / asset into the asset pool. When assets need to be converted, the asset pool will play a role (e.g., paying for content with other assets).

signed_transaction fund_asset_pools(string from,
                                    string uia_amount,
                                    string uia_symbol,
                                    string dct_amount,
                                    string dct_symbol,
                                    bool broadcast = false);

Parameters:

  • from - Send the account name or id of the core asset
  • uia_amount - "the amount of this" asset to be stored
  • uia_symbol - the name or id of the pool of assets you want to invest in
  • dct_amount - the amount of core assets to be deposited
  • Dct_symbol - The name or id of the DCT asset
  • broadcast - If broadcasting transactions over the whole network, they are shown as true

Return value:

  • Signed transactions that invest in a pool of paid assets.

Examples are given to illustrate:

fund_asset_pools mickey 900 MCC 1000 DCT true

Respond:

fund_asset_pools mickey 900 MCC 1000 DCT true
{
  "ref_block_num": 40906,
  "ref_block_prefix": 3394212377,
  "expiration": "2017-11-14T15:03:00",
  "operations": [[
      33,{
        "fee": {
          "amount": 0,
          "asset_id": "1.3.0"
        },
        "from_account": "1.2.73",
        "uia_asset": {
          "amount": 900,
          "asset_id": "1.3.34"
        },
        "dct_asset": {
          "amount": "100000000000",
          "asset_id": "1.3.0"
        },
        "extensions": []
      }
    ]
  ],
  "extensions": [],
  "signatures": [
    "1f54b76013f3fe6082951703201943e9266b1269edf3f4ac2aefac43ea2bdf9831509f6191de0a3b88df1bd16d1126f88ef1f6db4d81a9ba78f1854d7e8ddf5a7f"
  ]
}

API Developer Documentation for Investing in Asset Pool

Find the asset id

Find the asset ID and the dynamic_asset_data_id (dynamic asset data) target item ID to provide information about the fund supply pool or fund pool.

METHODS:
get_asset - Returns information about the specified asset

asset_object get_asset(string asset_name_or_id);

Parameters:

  • asset_name_or_id - Symbol or ID of the asset being questioned

Return value:

  • Asset information stored in block chains.

Examples are given to illustrate:

get_asset MCC

Respond:

get_asset MCC
{
  "id": "1.3.34",
  "symbol": "MCC",
  "precision": 0,
  "issuer": "1.2.73",
  "description": "Mickey credits",
  "options": {
    "max_supply": 10000,
    "core_exchange_rate": {
      "base": {
        "amount": 200000000,
        "asset_id": "1.3.0"
      },
      "quote": {
        "amount": 1,
        "asset_id": "1.3.34"
      }
    },
    "is_exchangeable": true,
    "extensions": []
  },
  "dynamic_asset_data_id": "2.3.34"
}

API Developer Documentation for Getting Assets

dynamic_asset_data_id (dynamic asset data) target ID

Examples are given to illustrate:

get_object "2.3.34"

Respond:

[{
    "id": "2.3.33",
    "current_supply": 0,
    "asset_pool": 0,
    "core_pool": 1250000
  }
]

The unit of core_pool parameter is DCT token and Satoshi representation.

Getting API Developer Documents for Target Items

Update asset parameters

Use the update_user_issued_asset method to update the existing asset parameters. Note that only asset issuers can update asset parameters. If you change the exchange rate parameters, make sure that the asset id is correct - in this case, the asset id is 1.3.34. As a reminder, the id of DCT is 1.3.0. You can use the ones mentioned in the previous section get_asset Method Gets the asset id.

METHODS:
update_user_issued_asset - Update the option to specify custom tokens. Some options for customizing tokens are not relevant to other asset types. This operation is used to update these options.

signed_transaction update_user_issued_asset(string symbol,
                                            string new_issuer,
                                            string description,
                                            uint64_t max_supply,
                                            price core_exchange_rate,
                                            bool is_exchangeable,
                                            bool broadcast = false);

Parameters:

  • symbol - The name or id of the asset to be updated. The asset must be issued on the market.
  • new_issuer - If the asset is to be delivered to a new issuer, this directive specifies the new issuer id
  • Description - Detailed description of assets
  • max_supply - Maximum issuance of an asset, which once issued will last forever.
  • core_exchange_rate - The value of transferring non-core assets to core assets
  • is_exchangeable - Allows conversion between assets and core assets, which is shown as true
  • Broadcast - To broadcast transactions over the network, display as true

Return value:

  • Signed Transactions Updating User Issued Assets

Examples are given to illustrate:

update_user_issued_asset MCC "" "" 20000 {"base":{"amount":200000000,"asset_id":1.3.0},"quote":{"amount":1,"asset_id":1.3.34}} true true

Respond:

{
  "ref_block_num": 5707,
  "ref_block_prefix": 3762837208,
  "expiration": "2017-11-16T13:22:55",
  "operations": [[
      36,{
        "fee": {
          "amount": 0,
          "asset_id": "1.3.0"
        },
        "issuer": "1.2.73",
        "asset_to_update": "1.3.34",
        "new_description": "",
        "max_supply": 20000,
        "core_exchange_rate": {
          "base": {
            "amount": 200000000,
            "asset_id": "1.3.0"
          },
          "quote": {
            "amount": 1,
            "asset_id": "1.3.34"
          }
        },
        "is_exchangeable": true,
        "extensions": []
      }
    ]
  ],
  "extensions": [],
  "signatures": [
    "20323b8730d22cad290b935baaf0612be39f71780a32fb94d65c81bb408b882dc7247a593c8a00e64194eb1a8876db94716751eecc9e38d5d83c1fe1f25a04a4bb"
  ]
}

Update API Developer Documents for User Published Assets

Posted by stonefish on Mon, 26 Aug 2019 01:16:37 -0700