5

I am new to blockchain and smart contract technology.

I want to understand the overall flow on how decentralized marketplace work. Let's say we have a decentralized marketplace built using smart contracts for listing creation, escrow, etc. Questions:

  1. I assume all the listings are stored on Ethereum blockchain. If so, does that mean anyone who wants to view the listings (clients) need to have Ethereum client running on the machine? Is there a way to not have Ethereum client running on the machine and be able to browse the listings?
  2. What's the difference between building a decentralized marketplace on blockchain vs. P2P approach?

One approach is using a blockchain directly. These markets will place product listing information directly into a blockchain, allowing buyers to reference the blockchain and purchase from there. Another method is to create a network of nodes that all talk to each other directly and don’t reference a blockchain, similar to BitTorrent. Original article

  1. Using smart contracts to achieve decentralized marketplace, is it blockchain approach or P2P approach?
  2. With P2P approach, does that mean you rely your network to run the node and keep the system up? Or anyone with Ethereum node running can do the same?
  3. How do you achieve "searching" if the listings' data are decentralized stored on the blockchain? I see Augur and OpenBazzar have searching function. How did they achieve this?
  4. If I build API for interacting with smart contracts, does that mean my API is not decentralized because it'll be hosted on some server such as AWS or Azure? Will this API be talking to one of the node we hosted on our own?
  5. How does a web client interact with the marketplace? Web client makes API requests then API interacts with smart contract on the node hosted by me?

Any help is greatly appreciated!

3

Here's a go :

  1. If you're not particularly authenticating to the client and just want to see the data, your ethereum client could be on a website back end system - that way locally you're just browsing the web (and in fact, you could authenticate to your website as well)

  2. If you share the market data via a P2P protocol, pretty quickly you'll want a transaction system so you can establish consistency (see the CAP theorem) between your nodes and consensus on what's happened / who has something to sell that hasn't been sold yet etc. At that point you might as well just use a blockchain.

  3. Smart contracts as they are today need a blockchain to run on. And most blockchains use P2P protocols under the hood.

  4. P2P and Ethereum would need network connectivity. But all of these protocols are pretty resistant to dropouts / being offline. If you were offline for a long time they would need some time to catch up before you could fully engage again.

  5. You can either parse the entire blockchain every search (slow), or have some special nodes whose job it is to constantly parse the chain and pick out the transactions of interest (and probably do some validation too), these nodes could perform local searches of their cut down list of transactions.

  6. Your smart contract can be considered an API in itself ('here's the set of rules for interacting with me'). Or you can design an API layer on top of someone else's interface, that extends it to give you some blockchain functionality, and publish it for the 3rd party to add into their system. Your API will probably be interacting with at least one of the blockchain nodes (via a smart contract, or by parsing the chain data) to do the interesting bits

  7. Yes web client can talk to an API for a function which you or someone else is hosting, that knows how to interact with the blockchain smart contracts. Or they can just go straight to the smart contract (subject to suitable identity system etc).

0

You're asking "how does blockchain work?" without asking "how does blockchain work?" To answer your question requires a literal lesson on how Ethereum works. It's clear that you've not taken the time to understand the fundamentals of blockchains or network design. If you seriously want to understand or develop on blockchains, I highly recommend you get used to reading ALL of the documentation before you ask any questions. This is still novel technology. Start with the white and yellow paper, then read all the documentation on their site if you really care about this. I'm only answering this because I'm writing an article on creating a 100% Ethereum-based marketplace, and can copy and paste most of the info, I would be flagging as low quality, which I don't do often.

What have you tried? What resources have you already read? What's the context of why you're asking the question? What information do you seek to gain?

I still recommend reading all of the official Ethereum documentation, consider how much time it took people to put it together, and reflect on that before asking vague questions.

Your Answers, Sir/Madam/Zer/Zim/Non-Binary/Astral/Zoologic/or fluid-gendered member of the Human species:

  1. For the context of your question, think of Ethereum network like the back-end software of any program (DApps in this case). This back-end is the Ethereum Virtual Machine (EVM) which is powered by nodes; they are responsible for ensuring the data passed through the EVM is valid, but you don't need one to use the network. Users interact with code on the EVM using software clients which use code libraries like Web3.js to "talk" to the blockchain. It's like making API calls, with a few differences. Check out MetaMask as a good example of an Ethereum client.

  2. A decentralized marketplace is a P2P market, but a P2P market does not have to be a decentralized marketplace. The difference is a general P2P market can use any software stack it wants to accomplish the end result. As long as the client software can communicate data with other instances of the software, and there is no middle-man (peers are interacting directly with each-other), you have a P2P network.

A decentralized, blockchain marketplace has specific requirements. Changes of any kind within the market (adding a product, accepting payment, adding admin, adding user-accounts, price changes, inventory checks, etc., etc.) each require a smart contract to handle the process. Smart contract calls are like API calls, with one major difference: In order to incentivize nodes to take the data you send, run data-intensive calculations to verify it, and add it to the blockchain, all contract calls have an associated gas fee (amount of ETH). The higher gas fee, the more incentive a node has to include that transaction, as the fee goes to them. This gas fee can be changed by the user (increased to make it more lucrative to take, or decreased if time is not a constraint). By requiring that every action cost an asset with real-world value, it helps get people to play nice.

There are pros and cons to each. For example, a 100% Ethereum blockchain could do things like utilize any ERC-20 token as payment. The data is secure due to the size of the network and the consensus algorithms being used. A hacker cannot simply find a loophole in the Ethereum network itself and cause trouble like they could if the market was a Web app or a desktop client. This benefit is also the main drawback, every action requires payment. If ETH is expensive ($1200 at the time of writing), and the contracts are intensive and require a lot of gas things can get expensive.

For example, right now a simple call just to tell the EVM that I authorize a smart contract to utilize my assets in a passive-income DApp costs over $12 worth of ETH to accomplish in less than 10 minutes. Once that's done, I'll need to make an even more complex call to a contract that allocates my funds, this will likely be close to $50 if I want it done quickly.

  1. It's Blockchain, and it's both. Smart contracts are the code of the EVM, just like Java or C# or any other language is the code of any P2P network. The blockchain itself is nothing more than a large, distributed network who's purpose is to run cryptographic consensus algorithms. A blockchain is P2P by definition, there is no "under the hood". It is a network of tens of thousands of people who don't know each other, spread all around the world, all running the same software to keep the same network running so that data can be compiled and irreversibly, publically, and permanently added to the network.

By design, this network also functions as a ledger of every transaction that has ever happened on it.

  1. P2P is so broad, it can be accomplished with any tech stack. You don't need a node. You can have a server, make a web app that connects users, and run it like a normal website and it's still P2P. You can create a client that runs on a specific port using a specific protocol to allow users to perform P2P actions. Keeping the system up, whether it's Ethereum (nodes) or a web app (the internet) is dependent on whatever system it's built for. Ethereum is just a network like the internet that uses a different consensus method to validate data.

  2. Blockchains are public. Whenever data gets validated by a node, it gets added to a block. Unless you're running a node and can enter the queries into the console, you need a client app or UI. Node operators can get raw data from their computers. Most users need a website or program that is designed using a code library that can interact with the blockchain. Again, a blockchain is just a network. A search engine of any type requires three things: A search function like box or filters in the user-interface, a source of raw data like a network back-end or blockchain, and a code library that bridges the two (an API, or in the case of blockchains, ABI).

  3. The smart contract is the API (ABI actually). It is decentralized. The software people use to interact with the contracts is not. Unless you're running the blockchain, you will never talk to a node directly. In order to search for data on a blockchain, it must have been validated by the nodes at some point in the past. When you make a call to the smart contract, it talks to the entire network. The nodes work behind the scenes, they validate the data.

Sure, you could technically make a protocol that finds a specific ETH node, checks what transactions it's putting together to include in a block, and look at that. It not only won't do you any good because it might not even bee the node to solve the block and therefore all the transactions it was working to include in a block remain pending or were validated by another node, but it's a topic that requires a chapter in a textbook to understand completely.

  1. It uses code libraries, like every other software to achieve things without reinventing the wheel. Web3.js is a common library designed to interpret the compiler code from the blockchain into human-readable and interactive uses.

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.