steemit / devportal

Steem Platform Developer Documentation.
https://developers.steem.io
MIT License
122 stars 74 forks source link

Recipe: to calculate RC transaction cost #335

Closed TimCliff closed 6 years ago

TimCliff commented 6 years ago

As a developer, I would like to know how to calculate the RC cost of a transaction.

relativityboy commented 6 years ago

-> https://steemd.com/@username has resource credit info.

Below is example of a community member's calculation

function (account) {
      var totalShares = parseFloat(account.vesting_shares) + parseFloat(account.received_vesting_shares) - parseFloat(account.delegated_vesting_shares);

      var elapsed = CURRENT_UNIX_TIMESTAMP - account.voting_manabar.last_update_time;
      var maxMana = totalShares * 1000000;
      // 432000 sec = 5 days
      var currentMana = parseFloat(account.voting_manabar.current_mana) + elapsed * maxMana / 432000;

      if (currentMana > maxMana) {
        currentMana = maxMana;
      }

      var currentManaPerc = currentMana * 100 / maxMana;

      return currentManaPerc;
}
pauliusuza commented 6 years ago

I created a feature request for adding an RC estimation endpoint

roboza commented 6 years ago

https://github.com/steemit/rcdemo

relativityboy commented 6 years ago

@pauliusuza regarding steemit/steem#2979, did you see steemit/steem#2982