6

Currently building a stock exchange on Ethereum. Based on the current design, I have users creating individual buy orders as separate contracts tied to a central stock counter contract in the form of a list or mapping.

As certain operations on the exchange require the finding of the highest priced offer I was just wondering if it's possible for me to search through the list and sort the buy orders locally instead of running a function on the Ethereum blockchain which could possible cost alot of gas.

Any help provided would be much appreciated.

  • You can write a constant function in the EVM and call it locally; it won't cost any gas because you're not creating a transaction. Do you actually need to search the blockchain, or does your contract have what it needs to query all the associated contracts? – Nick Johnson Apr 25 '16 at 11:03
3

You may want to consider a registry system as opposed to exhaustively searching a node. ConsenSys just released Regis.nu for this reason. Also may want to look at other projects like EtherEx to see how they are doing it.

  • 1
    Regarding EtherEx: "In developing the platform, we've realized that placing an order (storing) costs a lot more gas than filling one. This in turn creates a type of inverted maker/taker model, which could have a large impact on the liquidity of the exchange. We are working on many different solutions to the gas imbalance of creating an order on EtherEx versus filling an order" etherex.org/blog/update-etherex – tayvano Apr 25 '16 at 5:45

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.