ethereum / solidity-examples

Loose collection of Solidity example code
MIT License
532 stars 161 forks source link

Create the contracts for beta #6

Closed androlo closed 6 years ago

androlo commented 7 years ago

These are the contracts, and how likely it is that they will be included in the beta release.

  1. Bits
  2. Bytes
  3. Unsafe
  4. Strings
  5. Patricia Trie
  6. Token interface

Progress

Assessments

Bits, bytes and strings

Bits and bytes are essential, and only has fairly simple functions in them so is not really a problem. The only reason strings is not in that list, is because it is a question of what to take in, and if including an advanced string manipulation library is sending the right signals. I used to be very much for this, but the question is if string usage is something that should be encouraged. I can not recall a single time when I chose a string over a bytes32 (or a fixed size array of bytes32) in production code, because of how much more efficient and storage-friendly it is. Maybe a library that makes working with strings in the form of bytes32 and bytes32[N] is a good complement (or even a substitute).

Strings are already in the library though (arachnid string-utils), so i guess it might as well just be added. Lots of code for working with runes rather then bytes, which could be adapted to work for bytes32 as well.

Unsafe

The Memory library seems a necessary evil since there are libraries that works with memory directly. May scale it back and only keep methods for allocating, copying, converting to and from bytes/strings, and doing equals checks.

Ethereum tech

Patricia tree should be part of the library i think - perhaps with parts of it broken out and put into a library. RLP seems a bit unnecessary and i only added it because i had the code laying around. It might not make it in, or could perhaps be added later.

Seems like an EIP20 compliant token interface contract would be appropriate. I am not too fond of the idea of adding an implementation though - or at least not to write one. Several token contracts already exists, and are written and maintained by teams who works with tokens all the time. If a token implementation is added then it should be maintained by a person with a lot of experience working with tokens. #24

androlo commented 6 years ago

Done. More info in the individual issues.