System 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
in the code examples below is created using the following code, and it is not reiterated further.
1 | var DMC = require('dmc.js'); |
newaccount
create a new account.
Parameters
name | type | description |
---|---|---|
creator | string | account name of the creator |
name | string | account name of the account being created |
owner | string | owner permission public key of the account being created |
active | string | active permission public key of the account being created |
Instance
1 | let r = dmc_client.transact_sync({ |
setcode
Deploying a wasm contract.
Parameters
name | type | description |
---|---|---|
account | string | account of the contract owner |
vmtype | uint8 | contract engine type |
vmversion | uint8 | contract engine version |
code | string | contract code |
Instance
1 | let r = dmc_client.transact_sync({ |
setabi
Deploy ABI file.
Parameters
name | type | description |
---|---|---|
account | string | account of the contract owner |
abi | json | abi file code |
Instance
1 | let r = dmc_client.transact_sync({ |
updateauth
Add or modify user permissions.
Parameters
name | type | description |
---|---|---|
account | string | the name of the account |
permission | string | the name of an existing permission or a newly created permission |
parent | string | the parent permission that creates this permission |
auth | json | the composition of this permission |
Instance
1 | let r = dmc_client.transact_sync({ |
deleteauth
Delete permission.
Parameters
name | type | description |
---|---|---|
account | string | account name |
permission | string | permission to be deleted |
Instance
1 | let r = dmc_client.transact_sync({ |
linkauth
Specify action for permission.
Parameters
name | type | description |
---|---|---|
account | string | account name |
code | string | contract name |
type | string | action name |
requirement | string | permission name |
Instance
Taking the example of binding the dmc.token
contract with the transfer
action.
1 | let r = dmc_client.transact_sync({ |
unlinkauth
Actions allowed to be executed by the permission being deleted.
Parameters
name | type | description |
---|---|---|
account | string | account name |
code | string | contract name |
type | string | action name |
Instance
1 | let r = dmc_client.transact_sync({ |
buyrambytes
Purchase storage resources.
Parameters
name | type | description |
---|---|---|
payer | string | account name of the creator |
receiver | string | account name of the receiver |
bytes | uint32 | amount of ram to be purchased in bytes |
Instance
1 | let r = dmc_client.transact_sync({ |
buyram
Purchase storage resources, distinguishing between buying a specific quantity of tokens or buying a specific size of content.
Parameters
name | type | description |
---|---|---|
payer | string | account buying the storage resources |
receiver | string | account receiving the storage resources |
quant | string | amount of tokens used for purchasing the storage resources |
Instance
1 | let r = dmc_client.transact_sync({ |
sellram
Sell unused storage resources.
Parameters
name | type | description |
---|---|---|
account | string | account receiving the sold resource tokens, which is the same as the seller’s account |
bytes | uint64 | amount of storage space to be sold |
Instance
1 | let r = dmc_client.transact_sync({ |
delegatebw
Stake tokens to obtain CPU and bandwidth resources.
Parameters
name | type | description |
---|---|---|
from | string | account name of the resource staker |
receiver | string | account name of the resource receiver |
stake_net_quantity | string | staker staking DMC for the receiver to obtain NET |
stake_cpu_quantity | string | staker staking DMC for the receiver to obtain CPU |
transfer | bool | whether to transfer the corresponding tokens to the receiver when staking resources. 1 for transfer, 0 for no transfer |
Instance
1 | let r = dmc_client.transact_sync({ |
undelegatebw
Used to unstake resources, release resources, and retrieve tokens.
Parameters
name | type | description |
---|---|---|
from | string | unstake tokens staked by which account |
receiver | string | tokens staked on which account to be unstaked |
unstake_net_quantity | string | amount of tokens staked for obtaining bandwidth resources to be unstaked |
unstake_cpu_quantity | string | amount of tokens staked for obtaining CPU resources to be unstaked |
Instance
1 | let r = dmc_client.transact_sync({ |
refund
Called after undelegatebw function to unstake the tokens and return them to the account.
Parameters
name | type | description |
---|---|---|
owner | string | account name to which the tokens will be returned |
Instance
1 | let r = dmc_client.transact_sync({ |
regproducer
Register as a block producer.
Parameters
name | type | description |
---|---|---|
producer | string | register as a block producer |
producer_key | string | register as a block producer |
url | string | block producer website |
location | uint16 | block producer server location area code, following the ISO 3166-1 standard. |
Instance
1 | let r = dmc_client.transact_sync({ |
unregprod
Unregister as a block producer.
Parameters
name | type | description |
---|---|---|
producer | string | account name |
Instance
1 | let r = dmc_client.transact_sync({ |
claimrewards
Block producer claims rewards.
Parameters
name | type | description |
---|---|---|
owner | string | block producer name |
Instance
1 | let r = dmc_client.transact_sync({ |