0

As stated in the documentation there are 3 types of storage in the Ethereum VM (EVM) The storage, the memory, and the stack

Each account has a data area called storage, which is persistent between function calls and transactions. Storage is a key-value store that maps 256-bit words to 256-bit words. It is not possible to enumerate storage from within a contract and it is comparatively costly to read, and even more to modify storage. A contract can neither read nor write to any storage apart from its own.

Let's say I want to store key-values pairs of millions of records e.g cars and owners, does this mean it will be extremely costly to do so ? Or the concept of storage is totally different of what I'm looking for ?

2

The short answer is yes, it is presently extremely costly. And, yes, storage is what you're looking for. Storage is the only persistent mechanism.

Suppose each car is identified using a four-byte identifier (up to 4B cars) and each owner by a five-byte identifier (up to 1T people). Ignoring overhead for storing a sparse dataset, you're still looking at roughly 9 bytes per vehicle or ~9 MB for a million records. According to this, you're looking at around 640M gas which isn't going to be cheap. And directly using key-value storage is 20K of gas per write.

If you're using this to tokenization of physical objects like cars or houses, the per-unit cost is probably quite affordable: adding an extra $1 of overhead to a $10K sale is a percent of a percent.

Depending on your application, there might be other ways (including non-blockchain) solutions that are better suited to your situation.

  • What if I want to implement a smart contract that tracks the ownership of small goods like shoes, clothes, any other small belongings, even let's say smallest things like plastic bottles – Adelin Dec 20 '18 at 12:07
0

This article summarizes all what is needed to be know about Gas

As explained in the introduction, Gas is a unit that measures the amount of computational effort that it will take to execute certain operations.

Most of the smart contracts that run in the EVM are coded using Solidity (Ethereum is planning to move on to Viper from Solidity in the future). Each and every line of code in Solidity requires a certain amount of gas to be executed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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