Token Contract
Operation Example
The dmc_client object is an instance of dmc.js, which provides a series of methods for interacting with the blockchain.
The dmc_client mentioned in the following code is created by the code provided below, and it will not be reiterated.
1 | var DMC = require('dmc.js'); |
transfer
Transfer - Only tokens issued by datamall can be called (currently only DMC@datamall
).
Parameters
name | type | description |
---|---|---|
from | string | token sender |
to | string | token receiver |
quantity | string | token quantity |
memo | string | memo |
Instance
1 | let r = dmc_client.transact_sync({ |
extransfer
Transfer.
Parameters
name | type | description |
---|---|---|
from | string | token sender |
to | string | token receiver |
quantity | string | token quantity |
memo | string | memo |
Instance
1 | let r = dmc_client.transact_sync({ |
exissue
Increase token issuance.
Parameters
name | type | description |
---|---|---|
to | string | token receiver |
quantity | string | token quantity |
memo | string | memo |
Instance
1 | let r = dmc_client.transact_sync({ |
exretire
Destroy the circulating tokens held by an account.
Parameters
name | type | description |
---|---|---|
from | string | token sender |
value | string | token quantity |
memo | string | memo |
Instance
1 | let r = dmc_client.transact_sync({ |
exlock
Lock token.
Parameters
name | type | description |
---|---|---|
from | string | token owner |
quantity | string | token quantity |
expiration | date-time | lock-up period |
memo | string | memo |
Instance
1 | let r = dmc_client.transact_sync({ |
exunlock
Unlock.
Parameters
name | type | description |
---|---|---|
owner | string | token owner |
quantity | string | unlocked quantity |
expiration | date-time | unlocked quantity Lock-up period for pending unlock tokens |
memo | string | memo |
Instance
1 | let r = dmc_client.transact_sync({ |
bill
Place a PST order.
Parameters
name | type | description |
---|---|---|
owner | string | order Placer |
asset | string | quantity of the PST of the order |
price | double | the price of the order |
expire_on | date-time | minimun period of the order |
deposit_ratio | uint64_t | stake rate |
memo | string | memo |
Instance
1 | let r = dmc_client.transact_sync({ |
unbill
Cancel Order.
Parameters
name | type | description |
---|---|---|
owner | string | order Placer |
bill_id | uint64_t | id of the order |
memo | string | memo |
Instance
1 | let r = dmc_client.transact_sync({ |
order
fill an order.
Parameters
name | type | description |
---|---|---|
owner | string | account Name that executes the transaction |
bill_id | uint64_t | order ID |
benchmark_price | uint64_t | the benchmark price when placing the order, to convert the price to an integer, multipy the benchmark price by 10000 |
price_range | PriceRangeType | 1:Based on the benchmark price with a positive or negative fluctuation of 20% 2: Based on the base price with a positive or negative fluctuation of 30% 3: No price limit |
epoch | uint64_t | service period (in weeks), currently with a minimum of 24. |
asset | extended_asset | PST quantity to be purchased |
reserve | extended_asset | reserve |
memo | string | memo |
Instance
1 | let r = dmc_client.transact_sync({ |
increase
Increase reserve.
Parameters
name | type | description |
---|---|---|
owner | string | account Name that executes the transaction |
asset | string | the amount of increased reserve |
miner | string | miner |
Instance
1 | let r = dmc_client.transact_sync({ |
redemption
claim reserve.
Parameters
name | type | description |
---|---|---|
owner | string | account Name that executes the transaction |
rate | double | claim rate, $ 0<rate\le1$ |
miner | string | miner |
Instance
1 | let r = dmc_client.transact_sync({ |
mint
mint PST.
Parameters
name | type | description |
---|---|---|
owner | string | account Name that executes the transaction |
asset | string | the quantity of minted PST |
Instance
1 | let r = dmc_client.transact_sync({ |
setmakerrate
The minimum staking rate for miners.
Parameters
name | type | description |
---|---|---|
owner | string | account Name that executes the transaction |
rate | double | the minimum staking rate for miners $0.2 \le rate \le 1$ |
Instance
1 | let r = dmc_client.transact_sync({ |
setmakerbstr
Setting a custom staking rate for miners.
Parameters
name | type | description |
---|---|---|
owner | string | account Name that executes the transaction |
self_benchmark_stake_rate | uint64_t | custom staking ratio for miners, multiplied by 100 due to the limitation of two decimal places.0 |
Instance
1 | let r = dmc_client.transact_sync({ |
addmerkle
Miners and users provide consistent Merkle tree root information.
Parameters
name | type | description |
---|---|---|
sender | string | account Name that executes the transaction |
order_id | uint64_t | order ID |
merkle_root | checksum256 | merkle tree root |
data_block_count | uint64_t | number of data blocks |
Instance
1 | let r = dmc_client.transact_sync({ |
reqchallenge
User requests a challenge.
Parameters
name | type | description |
---|---|---|
sender | string | account Name that executes the transaction |
order_id | uint64_t | order ID |
data_id | uint64_t | data block ID |
hash_data | checksum256 | data block hash |
nonce | std::string | random number |
Instance
1 | let r = dmc_client.transact_sync({ |
anschallenge
Miner answers a challenge.
Parameters
name | type | description |
---|---|---|
sender | string | account Name that executes the transaction |
order_id | uint64_t | order ID |
reply_hash | checksum256 | response hash |
Instance
1 | let r = dmc_client.transact_sync({ |
arbitration
Arbitration by miner.
Parameters
name | type | description |
---|---|---|
sender | string | account Name that executes the transaction |
order_id | uint64_t | order ID |
data | std::vector\<uint8_t> | data |
cut_merkle | std::vector\<checksum256> | merkle tree |
Instance
1 | let r = dmc_client.transact_sync({ |
paychallenge
Challenge timeout compensation.
Parameters
name | type | description |
---|---|---|
sender | string | account Name that executes the transaction |
order_id | uint64_t | order ID |
Instance
1 | let r = dmc_client.transact_sync({ |
claimorder
Claim delivery rewards.
Parameters
name | type | description |
---|---|---|
payer | string | account Name that executes the transaction |
order_id | uint64_t | order ID |
Instance
1 | let r = dmc_client.transact_sync({ |
claimdeposit
Claim user‘s deposit.
Parameters
name | type | description |
---|---|---|
payer | string | account name |
order_id | uint64_t | order ID |
Instance
1 | let r = dmc_client.transact_sync({ |
addordasset
Increase order predeposit by user.
Parameters
name | type | description |
---|---|---|
sender | string | account name |
order_id | uint64_t | order ID |
quantity | extended_asset | increased quantity |
Instance
1 | let r = dmc_client.transact_sync({ |
subordasset
Decrease order predeposit by user.
Parameters
name | type | description |
---|---|---|
sender | string | account name |
order_id | uint64_t | order ID |
quantity | extended_asset | decreased quantity |
Instance
1 | let r = dmc_client.transact_sync({ |
updateorder
Update order status.
Parameters
name | type | description |
---|---|---|
payer | string | account name |
order_id | uint64_t | order ID |
Instance
1 | let r = dmc_client.transact_sync({ |
cancelorder
Cancel order.
Parameters
name | type | description |
---|---|---|
sender | string | account name |
order_id | uint64_t | order ID |
Instance
1 | let r = dmc_client.transact_sync({ |