EOSIO Dev Puzzle — What’s the max amount of RAM that can possibly be consumed by storing a single uint64

Let’s make the bear market a bit more fun. I’ll be posting some EOSIO developer puzzles from now on in irregular intervals. Here’s the first one:

What’s the max amount of RAM that can be consumed by an EOSIO contract when storing a single uint64_t variable?

Hint: It’s not 64 bits.

Imagine you have a struct with a single uint64_t class variable and you create a table that stores this structure. How much RAM can a single table.emplace call consume?

#include <eosio/eosio.hpp>

using namespace eosio;

CONTRACT puzzle1 : public contract {
using contract::contract;
puzzle1(eosio::name receiver, eosio::name code, eosio::datastream<const char *> ds)
: contract(receiver, code, ds) {}

struct [[eosio::table("puzzle")]] puzzle {
// only variable is this one
uint64_t value;

ACTION insert(uint64_t value) {
puzzle_t _puzzle(get_self(), name("puzzle").value);
_puzzle.emplace(get_self(), [&](auto &x) { x.value = value; });

❕ I’ll be giving away 5 EOS to the first person to post the correct answer on Twitter. 🤑

Here’s me calling the insert action that stores a single uint64_t value.

I’ll announce the winner and publish this transaction containing the correct answer in a week.

Originally published at cmichel.io

Medium Clap
Medium Clap

Written by

Full Stack Software Engineer #javascript #EOS. Into Recreational Math / CS 🤯 Just message me about anything, my mind is open.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store