0

I would like some advice on what approach with be best to take to achieve the following.

I want to release the contract with around 50,000 digital assets, think of it like pre filling a database with around x number of users. I want to then release a new asset every x amount of minutes, similar to CryptoKitties. Users can then purchase these newly released assets.

The asset may be structured as follows:

ID, Field 1, Field 2, Field 3

Now Im not to worried about the second part, my issue is how I go about pre loading the 50,000 digital assets. Im thinking in terms of gas costs etc as that many records might be expensive.

2 Answers 2

0

It's all possible, but the transaction costs are most likely going to blow up. You can find a rough estimate here.

Also, generating things randomly is not that easy in Ethereum, as the EVM is deterministic. You could use Oraclize.it though, as a source for a randomnes seed and use it to generate multiple items in one transaction.

0

If is it possible to calculate attributes of prepopulated assets based on their IDs, then you may generate pre-populated assets in a lazy way like this:

struct Asset {
  uint id;
  // Field 1, field 2, field 3 ...
}

// Maps asset ID to asset
mapping (uint => Asset) assets;

function getAssetByID (uint id) internal returns (Asset storage asset) {
  require (id > 0);
  asset = assets.get (id);
  if (asset.id == 0) {
    require (id <= 50000);
    prepopulateAsset (id, asset);
  }
}

function prepopulateAsset (uint id, Asset storage asset) internal {
  asset.id = id;
  // Prepopulate other asset fields based on asset ID
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.