I'm looking for any help og pointers, as to the possibility of creating a contract that would act as a "middleman" in a token/eth transaction between 2 users.

Considering a website, were users can list their assets (tokens) for sale at a given rate, and other can give their bid, and if the parties agrees to complete the deal, a smart contract should handle the transaction, to ensure trust in the deal.

Through the website, both seller and buyer calls a function on the smart contract, and thereby sending tokens / Eth to the contract. When both have done so, the last transfer calls an exchange function which will exchange the assets between the users.

I can't see any other way, than the website needs to control and monitor the transactions, this is in essence my question. What would be the best way to create such a transaction in terms of design?

1 Answer 1


It looks like you are trying to build a decentralized exchange of sorts.

Fortunately, these already exist, and most of them have their source code and smart contract open source:

Unfortunately, these systems are relatively complicated and handle many things which seem out of scope for what you are trying to do.

In terms of doing your own more simple project, yes it can totally be done, and depending on the complexity of your supported scenarios, could actually be pretty easy to integrate into a smart contract.

When you say:

the website needs to control and monitor the transactions

I think you really mean the smart contract back-end needs to store the funds (escrow), and determine when to ultimately resolve the trade.

The website front-end should be a single page application which uses web3.js to talk to the smart contract and relay information to and from the users interacting with the contract.

These may be hard concepts to jump into as a new dApp developer, so I suggest that you start with fixed tutorials which may not do exactly what you want, but will start to prepare you to develop in this space. I like cryptozombies.io personally.

  • Thank you taking your time to give me some pointers. Appreciate it :-) DEx.top looks interesting.
    – Dyvel
    Oct 31, 2018 at 19:23

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.