I want to calculate the ram usage when I conduct an action in contract, if ram is over the limit, I will let the action fail automatically.
How can I get the current ram usage in contract?
EOS.IO Stack Exchange is a question and answer site for users and developers of distributed applications built on top of the blockchain operating system, EOS.IO. It only takes a minute to sign up.
Sign up to join this communityFrom resource_limits.cpp
, it seems like in eosio
code, they use _db
to retrieve the resource consumption, which needs access to the chainbase database running.
As far as I know, this cannot be accessed from smart contract directly, thus, assuming all RAM usage for your contract can be tracked, two suboptimal solutions would be:
cleos get account
data)Interested in hearing about better solutions as well.