The eosfinex Smart Contract Plugin

Organizing interactions between user & smart contract

As we approach the upcoming launch of eosfinex, we continue with our weekly series looking at various developments taking place within eosfinex.

Today we introduce the eosfinex plugin — an integral piece in our architecture — which allows users to interact with the matching engine in a fast and intuitive way.

In the following article we walk through a high-level overview of how the eosfinex plugin interacts with the smart contract. Additionally, we take a look at the two different ways of signing transactions using the plugin. Finally, we take a look at how client connections are handled and what decision we made to handle a large number of connections in the most efficient way possible.

The eosfinex plugin is designed to organize interactions between the user and smart contract that that act as the foundation of eosfinex.

The use of the plugin allows users to abstract and collect details from the EOS blockchain. Additionally, the eosfinex plugin allows users to send/receive market requests in a relatively simplistic manner, removing otherwise significant barriers to entry associated with this area.

Our ultimate goal is to allow anyone, regardless of their levels of experience and expertise, to interact with eosfinex and the EOS blockchain.

A major advantage of the eosfinex plugin is that it will make use of an API very similar to the existing Bitfinex API, making it simple for existing clients to modify their trading setups to suit eosfinex.

Users can connect to the plugin via a WebSocket protocol to receive market data and send requests for placing and canceling orders across eosfinex.

The API is very similar to that of Bitfinex, with one significant difference. When the initial connection is established, the user has the choice of either passing his secret key during the login operation, upon which the plugin will sign all transactions that the user sends, or the client can sign transactions on their side and send them to the plugin. The latter option is the most secure as there is no potential possibility for the secret key to be disclosed to other users.

The scheme of interaction (client — plugin — smart contract) can be modeled as follows:

Figure 1. Overview of the interaction between client and smart contract

Depending on the current number of active users, a different number of plugins can be used to reduce latency and increase system throughput.

As mentioned before, we’ll now take a closer look at the inner workings of the plugin.

The following diagram shows the interaction of the plugin with the smart contract and connected users:

Figure 2. Overview of the eosfinex plugin

As made apparent by figure 2, each client has its own buffer for incoming messages to the exchange. This ensures that a single client will not be able to use all the computing resources of the host and will not be able to affect the work of other clients.

After the clients' request is parsed it is transferred (if necessary) to the eosfinex smart contract. As soon as the response from the smart contract is received it is immediately sent to the user, together with information pertaining to the trades, market data and wallet updates. This way we can ensure high performance and low latency for connected clients.

As an on-chain trading experience, eosfinex will facilitate a highly-scalable network of peer-to-peer value exchange, unconstrained by borders and built around a foundation of speed, transparency, and integrity.

Stay up to date with developments below as we approach our March 2019 launch.