package module
Version: v0.0.0-...-2ed9416 Latest Latest

This package is not in the latest version of its module.

Go to latest
Published: Apr 11, 2020 License: MIT Imports: 24 Imported by: 0



The unofficial EtherDelta (and ForkDelta) client for Golang.

License Go Report Card GoDoc


Getting started

package main

import (

	ed ""

func main() {
	service := ed.New(&ed.Options{
		ProviderURI: "wss://",

	orders, err := service.GetOrderBook(&ed.GetOrderBookOpts{
		TokenAddress: "0x0d8775f648430679a709e98d2b0cb6250d2887ef",

	if err != nil {



A ForkDelta client is avaiable:

service := ed.NewForkDelta(&ed.Options{
  ProviderURI: "wss://",


Take a look at the tests.


You can pass the ProviderURI property to the EtherDelta constructor options. If this is not set, then the service will read the ETH_PROVIDER_URI environment variable, otherwise the Ethereum provider is set to wss:// by default.


go test -v ./...


  • Q: Why do I get empty results sometimes?

    • A: Sometimes the EtherDelta websocket connection randomly disconnects. It can be unreliable at times.
  • Q: It's completely not working anymore!

    • A: EtherDelta may have changed their API or websocket endpoint.







This section is empty.


This section is empty.


This section is empty.


type CancelOrderOpts

type CancelOrderOpts struct {
	PrivateKey string
	Order      *OrderPost

CancelOrderOpts Options for cancelling an order

type DepositEthOpts

type DepositEthOpts struct {
	Auth *bind.TransactOpts

DepositEthOpts Options for depositing ETH

type GetOrderBookOpts

type GetOrderBookOpts struct {
	TokenAddress string
	UserAddress  string

GetOrderBookOpts Options for getting order book

type GetTokenBalanceOpts

type GetTokenBalanceOpts struct {
	TokenAddress string
	UserAddress  string

GetTokenBalanceOpts Options for getting token balance

type GetTokenPriceOpts

type GetTokenPriceOpts struct {
	TokenSymbol string

GetTokenPriceOpts Options for getting token price

type GetTokenTickerOpts

type GetTokenTickerOpts struct {
	TokenSymbol string

GetTokenTickerOpts Options for getting token ticker

type MakeOrderOpts

type MakeOrderOpts struct {
	PrivateKey   string
	TokenAddress string
	UserAddress  string
	Amount       *decimal.Decimal
	EthCost      *decimal.Decimal

MakeOrderOpts Options for making an order

type MakeTradeOpts

type MakeTradeOpts struct {
	Auth    *bind.TransactOpts
	Order   *OrderPost
	EthCost *big.Int

MakeTrade Options for making a trade

type Options

type Options struct {
	ProviderURI string
	// contains filtered or unexported fields

Options service options

type Order

type Order struct {
	Id                  string `json:"id"`
	Amount              string `json:"amount"`
	Price               string `json:"price"`
	TokenGet            string `json:"tokenGet"`
	AmountGet           string `json:"amountGet"`
	TokenGive           string `json:"tokenGive"`
	AmountGive          string `json:"amountGive"`
	Expires             string `json:"expires"`
	Nonce               string `json:"nonce"`
	V                   int    `json:"v"`
	R                   string `json:"r"`
	S                   string `json:"s"`
	User                string `json:"user"`
	Updated             string `json:"updated"`
	AvailableVolume     string `json:"availableVolume"`
	EthAvailableVolume  string `json:"ethAvailableVolume"`
	AvailableVolumeBase string `json:"availableVolumeBase"`
	AmountFilled        string `json:"amountFilled"`

Order Individual order struct

type OrderBook

type OrderBook struct {
	Buys  []Order `json:"buys"`
	Sells []Order `json:"sells"`

OrderBook Order Book struct

type OrderPost

type OrderPost struct {
	AmountGet       string `json:"amountGet"`
	AmountGive      string `json:"amountGive"`
	TokenGet        string `json:"tokenGet"`
	TokenGive       string `json:"tokenGive"`
	ContractAddress string `json:"contractAddr"`
	Expires         int    `json:"expires"`
	Nonce           int    `json:"nonce"`
	User            string `json:"user"`
	V               int    `json:"v"`
	R               string `json:"r"`
	S               string `json:"s"`

OrderPost Order struct for posting a new order to EtherDelta

type PostOrderOpts

type PostOrderOpts struct {
	Order        *OrderPost
	TokenAddress string
	UserAddress  string

PostOrderOpts Options for posting an order

type Service

type Service struct {
	// contains filtered or unexported fields

Service service struct

func New

func New(opts *Options) *Service

New returns new service

func NewForkDelta

func NewForkDelta(opts *Options) *Service

NewForkDelta returns new ForkDelta service

func (*Service) CancelOrder

func (s *Service) CancelOrder(opts *CancelOrderOpts) ([]byte, error)

CancelOrder Cancel an order on EtherDelta

func (*Service) DepositEth

func (s *Service) DepositEth(opts *DepositEthOpts) ([]byte, error)

DepositEth Deposit ETH to EtherDelta

func (*Service) GetJSON

func (s *Service) GetJSON(url string) (string, error)

GetJSON Make a JSON request

func (*Service) GetOrderBook

func (s *Service) GetOrderBook(opts *GetOrderBookOpts) (*OrderBook, error)

GetOrderBook Get the Order Book

func (*Service) GetTokenBalance

func (s *Service) GetTokenBalance(opts *GetTokenBalanceOpts) (*big.Int, error)

GetTokenBalance Get token balance on EtherDelta for account

func (*Service) GetTokenPrice

func (s *Service) GetTokenPrice(opts *GetTokenPriceOpts) (*decimal.Decimal, error)

GetTokenPrice Get last trade price for token

func (*Service) GetTokenTicker

func (s *Service) GetTokenTicker(opts *GetTokenTickerOpts) (*TokenTicker, error)

GetTokenTicker Get ticker info for token

func (*Service) MakeOrder

func (s *Service) MakeOrder(opts *MakeOrderOpts) (string, error)

MakeOrder Generate an order and post it to EtherDelta

func (*Service) MakeTrade

func (s *Service) MakeTrade(opts *MakeTradeOpts) ([]byte, error)

MakeTrade Make an order trade on EtherDelta

func (*Service) ParseStringExpNotation

func (s *Service) ParseStringExpNotation(str string) string

ParseStringExpNotation Parse string in exponential notation

func (*Service) PostOrder

func (s *Service) PostOrder(opts *PostOrderOpts) (string, error)

PostOrder Post an order to EtherDelta

func (*Service) WithdrawToken

func (s *Service) WithdrawToken(opts *WithdrawTokenOpts) ([]byte, error)

WithdrawToken Withdraw token from EtherDelta

type TokenTicker

type TokenTicker struct {
	Ask           *decimal.Decimal `json:"ask"`
	BaseVolume    *decimal.Decimal `json:"baseVolume"`
	Bid           *decimal.Decimal `json:"bid"`
	Last          *decimal.Decimal `json:"last"`
	PercentChange *decimal.Decimal `json:"percentChange"`
	QuoteVolume   *decimal.Decimal `json:"quoteVolume"`
	TokenAddress  string           `json:"tokenAddr"`

TokenTicker Ticker infor for token

type WithdrawTokenOpts

type WithdrawTokenOpts struct {
	Auth         *bind.TransactOpts
	TokenAddress string
	TokenAmount  *big.Int

WithdrawTokenOpts Options for withdrawing token


Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL