Catalog npm
Back to packageRELEASE DETAILS

1.1.0

npm

0xorderbuilder

Llibrary for building orders to use the 0x protocol

0xrelayeramadeusrelayerethereumutilties
Published26 Jul 2018
Direct dependencies14
Transitive dependenciesNot calculated

README

Current package documentation

0xOrderBuilder

Llibrary for building orders to use the 0x protocol.

Types

  • ZeroExOrderBuilder: main class with the static methods:
    • buildQuoteProviderOrder: creating a order to use in Quote Provider relayer strategy. A relayer will be called to get conversion rate and fees.
    • buildSignedOrder: signing a order. You can use the order returned in previous method.
  • EthNetwork: enum, used to inform the desired Ethereum network.

Installation

npm install 0xorderbuilder --save

Use

Import

import { ZeroExOrderBuilder, EthNetwork } from "0xorderbuilder";
import { BigNumber } from "bignumber.js"; // used as parameter in buildQuoteProviderOrder method

buildQuoteProviderOrder

    static buildQuoteProviderOrder(maker: string, makerTokenAddress: string, takerTokenAddress: string, makerTokenAmount: BigNumber, 
        milisecondsToExpire: number, relayerUrl: string, network: EthNetwork): Promise<Order>;
  • maker: yours eth wallet address;
  • makerTokenAddress: the token address you wish to sell;
  • takerTokenAddress: the token address you wish to buy;
  • makerTokenAmount: the amount you wish to sell (in base units, e.g.: 1 ZRX => new BigNumber(1000000000000000000));
  • milisecondsToExpire: used to calculate the returned order expiration date;
  • relayerUrl: the relayer addres used to get conversion rate and fee;
  • network: the desired Ethereum network
  • return: a promise that will be return a JSON representing the order.

buildSignedOrder

    static buildSignedOrder(order: Order, privateKey: string): SignedOrder;
  • order: the unsigned order;
  • privateKey: the private key of the maker wallet. Note: this private WILL NOT be transfer to relayer or any other;
  • return: the signed order.

Example

import { ZeroExOrderBuilder, EthNetwork } from "0xorderbuilder";
import { BigNumber } from "bignumber.js";

function testZeroExOrderBuilder() {
    ZeroExOrderBuilder.buildQuoteProviderOrder("0xf60345bcff9feedb98bbdfc996b33cba00ee2c75", "0x6ff6c0ff1d68b964901f986d4c9fa3ac68346570", 
        "0xd0a1e359811322d97991e03f863a0c30c2cf029c", new BigNumber(1000000000000000000), 10000, 
        "http://localhost:3000/api/v0", EthNetwork.Kovan).then((order) =>
    {
        const signedOrder = ZeroExOrderBuilder.buildSignedOrder(order, "0x5edd9d13a5d62821bbda8ac6da7d7ca69a1b540dc99ac9232fefc04d09e28055");
        console.log(JSON.stringify(signedOrder));
    });
        
}

testZeroExOrderBuilder();

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Declared dependencies 14

Native requirements
14 direct targetsNot calculated transitive count
Package / targetRequirementRelationship
0x.js
Environment
{
  "local_name": "0x.js",
  "alias": false,
  "peer_metadata": null
}
0.33.6runtime
@0xproject/connect
Environment
{
  "local_name": "@0xproject/connect",
  "alias": false,
  "peer_metadata": null
}
^0.6.8runtime
@0xproject/types
Environment
{
  "local_name": "@0xproject/types",
  "alias": false,
  "peer_metadata": null
}
^0.5.0runtime
axios
Environment
{
  "local_name": "axios",
  "alias": false,
  "peer_metadata": null
}
^0.18.0runtime
ethereumjs-util
Environment
{
  "local_name": "ethereumjs-util",
  "alias": false,
  "peer_metadata": null
}
^5.1.2runtime
moment
Environment
{
  "local_name": "moment",
  "alias": false,
  "peer_metadata": null
}
^2.22.0runtime
rxjs
Environment
{
  "local_name": "rxjs",
  "alias": false,
  "peer_metadata": null
}
^5.5.8runtime
chai
Environment
{
  "local_name": "chai",
  "alias": false,
  "peer_metadata": null
}
^4.1.2development
mocha
Environment
{
  "local_name": "mocha",
  "alias": false,
  "peer_metadata": null
}
^5.0.5development
nyc
Environment
{
  "local_name": "nyc",
  "alias": false,
  "peer_metadata": null
}
^11.6.0development
rimraf
Environment
{
  "local_name": "rimraf",
  "alias": false,
  "peer_metadata": null
}
^2.6.2development
ts-node
Environment
{
  "local_name": "ts-node",
  "alias": false,
  "peer_metadata": null
}
^5.0.1development
tslint
Environment
{
  "local_name": "tslint",
  "alias": false,
  "peer_metadata": null
}
^5.9.1development
typescript
Environment
{
  "local_name": "typescript",
  "alias": false,
  "peer_metadata": null
}
^2.8.1development

Distribution files

1 collected
Distribution 1

Source distribution

Source file
Checksums from source
{
  "integrity": "sha512-fknoxZiUbKbdDk2m/PBErRNS6kzc/xdPqa1zO3Ri2L5wo9ynRArH5+zCivaClnZf3E0hDB0ldA4w32LOrgQr2A==",
  "shasum": "25722acf1bc9b1a31378440f2f649d6f9b2631df",
  "tarball": "https://registry.npmjs.org/0xorderbuilder/-/0xorderbuilder-1.1.0.tgz",
  "fileCount": 42,
  "unpackedSize": 66969,
  "npm-signature": "-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbWSqjCRA9TVsSAnZWagAAuEoP/AoGWuDlERRkBGvC2WI9\n1khahNYsTJnIOkYljMobNo85n0WCv3k2IMNR5yzQ+TvlMivijQFU6GNDoP0A\nXVpd/krjakYgY9Y1xnJ6gdqw5OMJhYV1x4HusLRcr/YdCvRmplrky7O7NDp8\nj0QH9L2uZJO/XrWkRoEWTcxDzTgjpWy8t+6jtZ+OPXZKJZYOonc+n6Rf/RXn\no2V8WAXLzWS3aEgLlRgsylNwkBh4L1AJqIADu2KRKtlhZ4puG9tzfDe9A8hd\n+CJeKnTLDd14rmzOXzQr8E8NUuC8tl2CtbQXdDTw7p2Cc903BMCJHHhzvWsO\neOQHsLzQRhoIFFaGQsJCKs1c0nBP/M217d2tjkJjsEVCnnYauBoPeQQWoMMD\nV5JbjxB0nJJM2Zg4MDjl9Fi7sXxttH+dM7Yy+1wliGBQTBNioGYcU5aTMDXd\n2XS1rRcs5fx+W+LueBDu1Tz5Y+UXaKHOQr5eXx46kyDWYTB5bgWYUmbeUAgM\nHg4rhlUFodnwPUJumDE9D2D/QQdLQCMcIP057nW7BBAnEcHlGfp3l6tyQUqc\ngC6/XmpYUUBmRn6Zf55MKP850G6fwznmUDq/3EsNiFYExxYVEWM73YYMHV2x\nWHVV1cCMaaxX3Jgz25eLJ7zdky8Lzc35j3GFo0vI8YbLB9u40jIen9Q3rZ7x\nzlPQ\r\n=glcx\r\n-----END PGP SIGNATURE-----\r\n",
  "signatures": [
    {
      "keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA",
      "sig": "MEUCIQCrgWB4VJTHAMrpJa1pgEd5d/b6w3qrAvQkGOsCWA+s7AIgEhQtKCoDraff40Zn2FbSIOTUzdWQckRS350aOgW/LxI="
    }
  ]
}

Repository

PENDING
amadeusrelay/0xorderbuilder

Shared repository data · GitHub

License detected in repository
Not collected

Metadata history

Meaningful changes
Current collected state Current

Observed since 20 Oct, 17:51 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package_version:0d8aa60f32ed597b807bc28ff9be7904f45ee09730eada0f715dea7936998f20

Other collected versions

1.0.725 May1.0.412 Apr1.0.29 Apr1.0.19 Apr1.0.08 AprView all collected versions →