1

Understand that Ethereum or any other DLT for that matter is about provenance. I have a scenario where I need to insert a record/transaction row/item in the ledger.

Instead of appending this record to the ledger (which is like an update), is there some way to create? Because most of these new entries are not related to the last record/entry. i.e., they are new.

State variables in smart contract just updates (the U in the CRUD dimension) instead of create.

Is there a "Create" (Database CRUD) new entry/row item in Ethereum? How does one use Smart Contract to create a new item/transaction row?

1

There are some examples over here: Are there well-solved and simple storage patterns for Solidity?

And you might also be interested in an elaborated explanation of the more advanced pattern: https://medium.com/@robhitchens/solidity-crud-part-1-824ffa69509a

Hope it helps.

  • thanks Rob! This is amazing! You are amazing. Your article saved the day! Just one minor question -- is there any performance impact? – Nathan Aw Apr 12 '18 at 17:22
  • In summary, no. None. The tables can get as big as users are prepared to pay (for gas) to insert rows. One can't really decouple contract performance from the performance of ethereum itself. There's a separate discussion their about what thinks might happen as the chain grows over time. I'd say that's a valid topic that's more general than, say, finding opportunities to optimize those contracts. – Rob Hitchens - B9lab Apr 13 '18 at 0:23
  • Hi rob i tried your user CRUD in my private network. Tried to insert user was successful but was unable to get the record back. Getusercount returned 0 as well. Anything that I might have missed out? – Nathan Aw Apr 13 '18 at 12:15
  • No, nothing special. Wait for mined transaction ... – Rob Hitchens - B9lab Apr 13 '18 at 13:21
  • Hi Rob, i am using your quorum and it does not seem to work. is it due to the solidity version? the version of the code is pragma solidity ^0.4.6; – Nathan Aw Apr 16 '18 at 13:35

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.