1

since a few days, I am receiving a Bad Request error (status code 400) when trying to sign and submit an order:

ERROR(status code 400): {
  "code": 100,
  "reason": "Validation Failed",
  "validationErrors": [
    {
      "field": "",
      "code": 1001,
      "reason": "should be array"
    }
  ]
}

I haven't changed anything in the code and it was working before. I observed this behavior on Ropsten and Polygon. status.0x.org shows that there is a major incident on Ethereum, but not on the other two mentioned networks.

Can someone from the 0x team help please?

const utils = require("@0x/protocol-utils");
const contractAddresses = require("@0x/contract-addresses");

function Sign() {
    
    async function sign() {
        
        const CHAIN_ID = 3; 
        const NULL_ADDRESS = "0x0000000000000000000000000000000000000000";
        const addresses = contractAddresses.getContractAddressesForChainOrThrow(CHAIN_ID);
    
        // Calculate value for order expiry parameter (here: 50 minutes)
        const getFutureExpiryInSeconds = () =>
        Math.floor(Date.now() / 1000 + 3000000).toString();
    
        // Unlock MetaMask
        const accounts = await window.ethereum.request({
        method: "eth_requestAccounts"
        });

        // Use currently connected MetaMask account as the maker account
        const maker = accounts[0];
        console.log("Maker address: " + maker)
    
        
        const order = new utils.LimitOrder({
            makerToken: "0xc03ce38bc55836a4ef61ab570253cd7bfff3af44", 
            takerToken: "0xad6d458402f60fd3bd25163575031acdce07538d", 
            makerAmount: "1000", 
            takerAmount: "1000", 
            maker: maker,
            expiry: getFutureExpiryInSeconds(),
            salt: Date.now().toString(),
            chainId: CHAIN_ID,
            verifyingContract: addresses.exchangeProxy, 
            takerTokenFeeAmount: "0",
            sender: NULL_ADDRESS,
            feeRecipient: "0x0000000000000000000000000000000000000000",
        });
        
        console.dir(order);

        // Sign order conforming to the EIP712 standard
        const signature = await order.getSignatureWithProviderAsync(
            window.ethereum, 
            utils.SignatureType.EIP712 
        );
        console.log(`Signature: ${JSON.stringify(signature, undefined, 2)}`);

        // Append signature object to order object for the post of the order
        const signedOrder = { ...order, signature };
        console.log(signedOrder)

        const resp = await fetch("https://ropsten.api.0x.org/orderbook/v1/order", {
            method: "POST",
            body: JSON.stringify(signedOrder),
            headers: {
                "Content-Type": "application/json"
            }
        });
    
        // Handle response
        if (resp.status === 200) {
            alert("Successfully posted order to SRA");
        } else {
            const body = await resp.json();
            alert(
                `ERROR(status code ${resp.status}): ${JSON.stringify(body, undefined, 2)}`
            )
        }
    }
    
      return (
          <button onClick={sign}>Sign and submit</button>
      );
    
  }
  
  export default Sign;`

1 Answer 1

0

Thanks for reporting this issue. Our teams are actively investigating why these 400s are showing up on Ropsten Orderbook. Will circle back when we understand more.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.