Need Help on implementing 0x protocol


I’ve been trying to send a order to
I’ve used ZeroEx api and @0xproject/connect to do this. And I’m using Ropstan Test Network.

Here is the flow and code I’ve used:

  1. firstly I’ve created an order object:
 var order = {
            maker: web3.eth.accounts[0],
            taker: "0x0000000000000000000000000000000000000000",
            makerTokenAddress: "0xa8e9fa8f91e5ae138c74648c9c304f1c75003a8d",
            takerTokenAddress: "0xc778417e063141139fce010982780140aa0cd5ab",
            makerTokenAmount: new BigNumber("1000000000000000000000"),
            takerTokenAmount: new BigNumber("700000000000000000"),
            expirationUnixTimestampSec: parseInt(
                (new Date().getTime()/1000) + duration
            salt: ZeroEx.generatePseudoRandomSalt()
  1. Then add exchangeContractAddress property to order object:

order.exchangeContractAddress =;

  1. Add some other fees properties with getFeesAsync method:
    var feePr = httpClient.getFeesAsync(order).then(function(feeResponse) {
        order.makerFee = new BigNumber(feeResponse.makerFee || 0); 
        order.takerFee = new BigNumber(feeResponse.takerFee || 0); 
        order.taker = feeResponse.takerToSpecify;
        order.feeRecipient = feeResponse.feeRecipient || ZeroEx.NULL_ADDRESS;
  1. Then Trying to sign the order so that I can send order to openrelay server:
    Promise.all([feePr]).then(() => {
		    var orderHash = ZeroEx.getOrderHashHex(order);
		    return zeroEx.signOrderHashAsync(orderHash, order.maker, false);
	    }).then((signature) => {
		    order.ecSignature = signature;
		    validSignature =;
		    return order;

Here is the problem I’m facing:
while trying to sign order from metamask popup, the “zeroEx.signOrderHashAsync” fucntion is returning false instead of returing a promise in which I should get the signature, rather than it is throwing an error of “INVALID SIGNATURE”. I’ve debugged the signOrderHashAsync function too where I found that the order hash and maker address sent to validated. In this function they try to get the maker address from orderhash and then check wheather it matches with the maker address that is passed as argument. but they dont match. From where I guesed that the order hash I’m generating is not right. But I’m using ZeroEx.getOrderHashHex function which is the api function. I’m confused where I’m doing wrong. Can you please help me guiding about where I’m doing wrong.

Btw The order object that I’m passing in getOrderHashHex function is :


Here I’m showing it by stringifying. but in code I’m sending it as object.
And the order hash I’m getting is:

Thank you in advance.


Can you try return zeroEx.signOrderHashAsync(orderHash, order.maker, true); ?

Also, it might be good to ask this question in the #dev channel on if you haven’t already. You should get a much faster response!


Thanks for your reply. Yeah I’ve tried your solutions and it works fine. Thanks a lot