resources
DMC resources are divided into two types: staked resources, including CPU and NET, and consumable resources called RAM or storage.
Users need to have sufficient RAM, CPU, and NET resources to deploy a contract.
RAM and Resources
RAM (Random Access Memory)
- RAM is a necessary resource for storing data on the blockchain and needs to be purchased by users. The more data you store, the more RAM you need.
- The price of RAM is determined by the market and automatically adjusts based on market conditions. When RAM is no longer needed, it can be released and sold at the current market price.
- Whether buying or selling RAM, it involves interaction between participants and system accounts, rather than direct market transactions. However, the price is determined by the Bancor algorithm.
Network Bandwidth
- Users can acquire more network bandwidth by staking more DMC. They can also unstake and reduce network bandwidth as needed, reclaiming their DMC.
- Network bandwidth can be compared to “data usage” in mobile data plans, allowing users to obtain it on-demand according to their needs.
CPU Bandwidth
- CPU bandwidth measures the computational time consumed during contract execution in the past 3 days (measured in milliseconds).
- CPU bandwidth, like network bandwidth, is a temporary consumption. As the number of invocations decreases, the consumption decreases and can be reduced to a minimum of 0.
- Users can stake DMC to obtain more CPU bandwidth or unstake to reduce CPU bandwidth, reclaiming their staked DMC.
How to Buy RAM and Stake Resources
Buying RAM
- Storing account information on the chain requires consuming memory. The creator needs to purchase memory for the account being created to store its information.
By calling the buyrambytes
method, the parameters and their explanations are as follows:
1 | var DMC = require('dmc.js'); |
To purchase storage resources, there is a distinction between buying a specific amount of tokens or buying a specific size of content.
By calling the
buyram
method, the parameters and their explanations are as follows:
1 | var DMC = require('dmc.js'); |
Staking Resources
The creator stakes DMC on behalf of the recipient to obtain CPU and NET resources, enabling the new account to perform transfers.
By calling the delegatebw
method, the parameters and their explanations are as follows:
1 | var DMC = require('dmc.js'); |
Unstaking Resources
To unstake, release resources, and reclaim tokens.
By calling the undelegatebw
method, the parameters and their explanations are as follows:
1 | var DMC = require('dmc.js'); |
Selling Resources
By calling the sellram
method, the parameters and their explanations are as follows:
1 | var dmc_client = DMC({ |