Developing a Small Scale Ethereum Exchange for Service Purposes
Why Would You Need a Small Scale Exchange?
There are two methods to provide service that utilize Ethereum as its backbone. The first method is to store all the logic and data within the Smart Contract, which result in a completely decentralized application. However, this method has limitations related to Ethereum’s transaction fee and process speed. It takes minutes to process a single action, and spending a couple of dollars every transaction does not sound pleasing.
In order to overcome these limitations, it is possible to create and benefit from a small scale exchange oriented towards services. More specifically, this means to make a currency that can be used within the service, while also being tradeable with Ethereum. If 1 Ethereum is deposited into the game, the game gives the user 1 Gold. Conversely, The user can use 1 Gold in order to gain 1 Ethereum. Going by this type of transaction system, there will be no transaction fees occurring, except when exchanging Gold for Ethereum. Furthermore, Gold is contained within the normal database, and thus, the transaction is rapidly processed as well.
Surely this is not a complete solution to our previous problem. The best scenario would be to quickly process transactions within the Ethereum network. That would be the only way to guarantee blockchain’s advantages of being a decentralized system while also protecting digital ownership. These advantages are dimmed when a personal small scale exchange is created.
However, the developers of Ethereum are aware of the rising limitations due to slow transaction process times and are attempting various methods to overcome these issues. Before these methods actually come to fruition, developers would have to create a small scale exchange in order to bypass the slow transactions. The difficulties that come with developing an exchange is the part where the system receives a transaction, and the part where the system manages the Ethereum. In this article, let’s discuss the part about receiving a transaction.
Methods to Receive a Transaction
If you receive Ethereum from many users, there are several methods. The first method is for each user to hand over his/her ID to the contract and send Ethereum. If this method is used, it is possible to leave the event that the contract needs, and thus, can be simply implemented. However, a disadvantage is that the user must be well aware of how to use an Ethereum wallet.
Another method would be to give a unique Ethereum deposit address to each user. If Ethereum is deposited into a certain Ethereum address, then it is processed as receiving money from the user that corresponds to that Ethereum address. Simply put, it is as if the owner of that address transferred from money to his own wallet. This method facilitates the sending process for users, and usually much more familiar. However, from the receiving standpoint, it is difficult to manage the Ethereum because they come through different addresses.
Many people still face difficulties in using an Ethereum wallet. In addition, normal exchanges usually assign unique Ethereum addresses for every user when sending Ethereum, making this process a lot more familiar to most people.
Writing Code that Watches Ethereum
It is a simple task to check that Ethereum was transferred to a certain address. After reading all the transaction information in one block, match whether the transaction’s “to” indicates that certain address or not. One block usually forms in about 10–20 seconds, and one block contains around 200–300 transactions at most. It is easy to check all the transaction data that has been produced.
Let’s take a more detailed look. Web3 Library’s getBlock function takes blockNumber as a parameter and returns the block’s information. If one uses this function, it brings the entire block’s transactions’ hashes’ list. Then, each transactions specific information is brought by using getTransaction function. Within the information brought by getTransaction, there is data about who is receiving the Ethereum, by how much quantity. These two information will suffice.
With this method, it is possible to watch when and how much Ethereum is entering through a specific address.
Points of Caution
Just because a block has been mined for Ethereum or Bitcoin, it does not that block is confirmed. Usually, after the block has been mined, it is safer to wait for a few more blocks to be produced afterwards. Thus, when getting a block’s transaction data, it is much safer to read the block that is much behind the most current block. It is possible to get the most current block’s number through web3’s getBlockNumber. However, there is another point to be cautious of when dealing with deposits. If the user deposits Ethereum through the Smart Contract, it is difficult to track down. Ethereum’s RPC protocol does not have an API that gives information about the transaction when that transaction calls the Smart Contract. Transaction information that is pulled via web3 only contains information about the function’s name and parameters. Consequently, users must be warned to not use the Smart Contract. Even famous exchanges do not deposit using the Smart Contract because of reasons discussed above.
This concludes the discussion of when a small scale exchange is needed when dealing with Ethereum. Furthermore, we also explored the ways of receiving Ethereum using those small scale exchanges.
Link: Korean Version
Last but not the least! Now it’s time to enjoy GoCryptobot.
Download from here :)
- App Store: https://apple.co/2KbMipn
- Google Play: https://bit.ly/2K5tYhx