复制源代码
从eosio.contracts 项目中,复制eosio.contracts/eosio.system/src/exchange_state.cpp
,eosio.contracts/eosio.system/include/eosio.system/exchange_state.hpp
两个文件到你合约项目中。
并在你的合约中include
#include "common/exchange_state.hpp"
#include "common/exchange_state.cpp"
计算代码
uint64_t bcskill_contract::exchange_ram(eosio::asset quantity){
rammarket market(k_eosio, k_eosio.value);
auto it = market.find(k_ramcore_sym.raw());
eosio_assert(it != market.end(), "125");
auto tmp = *it;
/* Convert EOS amount to ram bytes */
auto out_ram_bytes = tmp.convert(quantity, k_ram_sym);
return out_ram_bytes.amount;
}
版权属于:区块链中文技术社区 / 转载原创者
本文链接:https://bcskill.com/index.php/archives/517.html
相关技术文章仅限于相关区块链底层技术研究,禁止用于非法用途,后果自负!本站严格遵守一切相关法律政策!