Smart Mining V1

Smart Mining V1: A flexible on-demand mining mode


As one of the digital financial derivatives on, mining provides crypto holders with stable, secure and reliable services for investment product subscription and redemption. Smart Mining V1, also known as flexible mining, is an important part of's mining service. It distributes rewards according to the share of users' staked assets in the mining pool's total stake amount. And users can redeem their assets anytime.

Explanation's mining service distributes token rewards at an even inflation rate within a certain period of time, as shown in the graph below.

Changes in the total staked assets in the mining pool at the time point ti will lead to changes in rewards for individual users, who are rewarded according to the following formula:

f(ti,tn)=i=1n(titi1)rtUiSi1f(t_i,t_n)=\sum_{i=1}^{n}(t_i-t_{i-1})r_t * \frac {U_i}{S_i}(1)

rtr_t denotes the expansion factor of token rewards, tit_i denotes the i-th change, SiS_i denotes the total staked assets during the period from ti−1 to ti, and UiU_i denotes users' staked assets during the period from ti1t_{i-1} to tit_i.

According to the above formula, changes in the mining pool’s total staked assets will affect the distribution of rewards for all users. In order to avoid high gas fees incurred from updating the reward distribution for every user, the above formula is altered to the following one:

f(ti,tn)=i=1mUij=startiendi(titi1)rtSi2f(t_i,t_n)= \sum_{i=1}^{m}U_i \sum_{j=start_i}^{end_i}\frac{(t_i-t_{i-1})r_t}{S_i}(2)

When the total staked assets in the mining pool have changed while the users' staked assets have not during the period from starti to endi, only the following summation formula needs to be updated:

j=startiendi(titi1)rtSi3\sum_{j=start_i}^{end_i} \frac{(t_i-t_{i-1})r_t}{S_i}(3)

Contract code

modifier updateReward(address account) {
    rewardPerTokenStored = rewardPerToken();
    lastUpdateTime = lastTimeRewardApplicable();
    if (canNext && block.timestamp > periodFinish && DURATION_NEXT > 0) {
        rewardRate = rewardNext.div(DURATION_NEXT);
        uint256 nextRound = (block.timestamp - periodFinish) / DURATION_NEXT + 1;
        periodFinish = periodFinish.add(nextRound * DURATION_NEXT);
        rewardPerTokenStored = rewardPerToken();
        lastUpdateTime = lastTimeRewardApplicable();
        rewardNow = rewardNext;
        emit RewardAdded(nextRound * rewardNext);
    if (account != address(0)) {
        userInfo[account].rewards = earned(account);
        userInfo[account].rewardPerTokenPaid = rewardPerTokenStored;

Mining pools

2pool farm

Mainnet contract address:TFpg63byqDwniXnyxVYpSzBfWGBwZExM9J


Mainnet contract address:TCkNadwxyik1D66qCGmavuneowDRXPgdkL

Contract interaction

We use TronWeb to interact with contracts. One can easily interact with online contracts after initializing TronWeb instances.

const TronWeb = require('tronweb')
const privateKey = process.env.PRIVATE_KEY
const apiKey = process.env.API_KEY

var tronWeb = new TronWeb({
	fullHost: "",
	headers: { "TRON-PRO-API-KEY": apiKey },
	privateKey: privateKey,

Get mining pool information

View addresses of fixed-term/on-demand mining pools

  • Function: reward_contract()

>>> let contract = await tronWeb.getContract('TFpg63byqDwniXnyxVYpSzBfWGBwZExM9J')
>>> await contract.methods.reward_contract().call()

View rewards of on-demand mining pools

  • Function:earned(address)

  • Parameter: user's address

>>> let contract = await tronWeb.getContract('TUgVp8FzZcFLHwruuncXaQo2js5Ym2GqSj')
>>> await contract.methods.earned('TF5MekHgFz6neU7zTpX4h2tha5miPDUj3z').call()

Transaction execution


  • Function:deposit(uint256)

  • Parameter:Deposit amount

>>> let contract = await tronWeb.getContract('TFpg63byqDwniXnyxVYpSzBfWGBwZExM9J')
>>> await contract.methods.deposit(1000000000000000000).send()


  • Function:withdraw(uint256)

  • Parameter:Withdrawal amount

>>> let contract = await tronWeb.getContract('TFpg63byqDwniXnyxVYpSzBfWGBwZExM9J')
>>> await contract.methods.withdraw(1000000000000000000).send()

Last updated