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.

1
  • 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? Commented Apr 25, 2016 at 11:03

1 Answer 1

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
  • 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 Commented Apr 25, 2016 at 5:45

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.