EOS WiKi Bilingual News & Info Of EOS, Vote for us: eosdotwikibp

EOSfinex:采用去中心化链上交易模式的WebSockets/EOSfinex: WebSockets for a decentralised, on-chain exchange




This image has an empty alt attribute; its file name is 1*pK3AbzHt5KUXmM48Iyt9xg.png







以下部分将展示EOSfinex WebSocket端口传送的交易更新信息。


[ ‘0’, 
  [ ’10’, 
    1 ] ]


为了能通过WebSockets 完成交易,我们必须连接WebSocket端口。该端口本身作为EOS原生插件,在紧邻合约的EOS节点之上运行。交易商在将其发送给端口前,提前用私钥完成订单签署。










若您想知道Sunbeam如何发挥作用,请参阅以下内容。该内容对Apache License 2.0完全公开。

Contribute to bitfinexcom/sunbeam development by creating an account on GitHub.github.com



With the launch of EOSfinex right around the corner, we’re here to give a sneak peek into the mechanics powering the exchange.

EOSfinex is a high-performance decentralised exchange built on EOSIO which will run fully on-chain — custody, order book, and matching engine are all part of the EOS contracts. EOSfinex is set for full launch in Q1 of 2019.

In the below article, we will take a look at the additional WebSocket protocols which we are offering to traders, as well as using the gateway in practise.

EOS On WebSockets

Usually, EOS contracts offer an HTTP-based API, which will be one way of trading on EOSfinex. In addition to this, we will also support low latency WebSockets. WebSockets allow users to react quickly to drastic market movements and are at the same time a web standard.

The WebSocket protocol for EOSfinex is based on the v2 protocol that is in use at Bitfinex. To make trading in the decentralised environment possible, we added a few changes.

We’ve designed the gateway to be capable of high-performance, and to make it simple for existing Bitfinex users to use it.

The following section shows a trade update message from the EOSfinex WebSocket gateway.

Looks pretty familiar to our API v2 messages, doesn’t it?

[ '0', 
[ '10',
1 ] ]

Auth & Pre-Signing

To be able to trade via WebSockets, we have to connect to the WebSocket gateway. The gateway itself runs as a native EOS plugin, on an EOS node next to the contract. The trader presigns the orders with their private key before sending it to the gateway.

The gateway then applies it to the contract. This way, no private keys ever leave the traders machine.

Our WebSocket library currently supports private key based signing and Scatter. In the future, we will add hardware wallet support.

Below is a sample message, sent from the client to the gateway, which would submit a trade:


By nature, all updates are public for an on-chain exchange. But how can one decide which trade update message belongs to the right user? This is an important question required for sending the right message to their socket.

For this reason we have added a special endpoint to our contract. The name of the EOS action is validateSunbeam, our WebSocket library uses it as part of an auth process.

By calling auth(), Sunbeam sends a locally signed message to the websocket gateway. The message sent to the validate action itself is empty and does not trigger anything.

The gateway only uses it to verify the user by comparing the signed message with their public keys on-chain. With an successful auth, we receive “private” wallet messages, trades and order updates.

Below you will find a brief demonstration of Scatter:

If you are curious as to how Sunbeam functions, feel free to take a look below. It is fully open-sourced under Apache License 2.0.bitfinexcom/sunbeam
Contribute to bitfinexcom/sunbeam development by creating an account on GitHub.github.com

We hope you enjoyed this quick preview and are excited as us about the upcoming launch of EOSfinex.

原文链接/Original URL:


About the author

By user
EOS WiKi Bilingual News & Info Of EOS, Vote for us: eosdotwikibp

Recent Posts