Skip to content
This repository has been archived by the owner on Jan 4, 2023. It is now read-only.
/ 0x-go Public archive

[Experimental] A collection of tools relating to Ethereum's 0xProject (v2)

License

Notifications You must be signed in to change notification settings

linki/0x-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

0x-go

Build Status Coverage Status GitHub release go-doc

A collection of tools relating to Ethereum's 0xProject.

Overview

It currently has a single command that calculates the hash of a given order. More commands will be added.

Calculate an order's hash.

$ go run main.go orders hash \
  --exchange-contract-address=0x12459c951127e0c374ff9105dda097662a027093 \
  --maker=0xc9b32e9563fe99612ce3a2695ac2a6404c111dde \
  --taker=0x0000000000000000000000000000000000000000 \
  --maker-token-address=0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2 \
  --taker-token-address=0xe41d2489571d322189246dafa5ebde1f4699f498 \
  --fee-recipient=0xa258b39954cef5cb142fd567a46cddb31a670124 \
  --maker-token-amount=18981000000000000 \
  --taker-token-amount=19000000000000000000 \
  --maker-fee=0 \
  --taker-fee=0 \
  --expiration-unix-timestamp-sec=1518201120 \
  --salt=58600101225676680041453168589125977076540694791976419610199695339725548478315

=> 0x10d750751d98bc8a9c29542118fbcf2fdb5b4977a3e5abf7cf38d03a6c149942

Compare it with the order on RadarRelay. The order below was created through RadarRelay which also calculated the hash, presumably using 0x.js. Since both hashes are the same we can assume that the Go version is correct as well.

curl -Ss https://api.radarrelay.com/0x/v0/order/0x10d750751d98bc8a9c29542118fbcf2fdb5b4977a3e5abf7cf38d03a6c149942 | jq .
{
  "ecSignature": {
    "v": 28,
    "r": "0x2ffe986adb2ba48a800fe153ec0ec2af8b65856a34a67648e65a4bd6639c54d9",
    "s": "0x44ea4220aec0676a41ae7d0bc2433407f2ce892217be30e39d4e44dcde127709"
  },
  "exchangeContractAddress": "0x12459c951127e0c374ff9105dda097662a027093",
  "expirationUnixTimestampSec": "1518201120",
  "feeRecipient": "0xa258b39954cef5cb142fd567a46cddb31a670124",
  "maker": "0xc9b32e9563fe99612ce3a2695ac2a6404c111dde",
  "makerFee": "0",
  "makerTokenAddress": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
  "makerTokenAmount": "18981000000000000",
  "salt": "58600101225676680041453168589125977076540694791976419610199695339725548478315",
  "taker": "0x0000000000000000000000000000000000000000",
  "takerFee": "0",
  "takerTokenAddress": "0xe41d2489571d322189246dafa5ebde1f4699f498",
  "takerTokenAmount": "19000000000000000000"
}

Requirements

  • go 1.11
  • go-ethereum (geth) 1.9

Warning

This is a trivial implementation, the author is not a cryptographer, and the code has not been reviewed. Use at your own risk.

About

[Experimental] A collection of tools relating to Ethereum's 0xProject (v2)

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published