0

I have been using the @0x/contract-wrappers to sign a limit order as the taker but I can't find a way to configure a provider that can accept a private key to sign the order rather than using Metamask through the browser. Does anybody have any advice on how to "take" a limit order using a headless server?

2 Answers 2

0

You don't have to sign anything to take/fill a limit order. As a taker, you pass in the order and the signature (both created by the maker) to fillLimitOrder() on the Exchange Proxy.

Signing transactions with a private key depends on what library you're using. If you are using 0x providers, you can use the PrivateKeyWalletSuprovider as part of a Web3ProviderEngine. If you're using ethers, create a Wallet signer with the private key. If you're using web3js you can call web3.eth.accounts.wallet.add()`.

1
  • Hi Lawrence. Thanks for taking the time to reply. This is the code I was following: const exchange = new ContractWrappers.IZeroExContract( addresses.exchangeProxy, supportedProvider ); const tx = await exchange .fillLimitOrder(order, signature, new BigNumber(order.takerAmount)) .callAsync(); } In the example the supportedProvider is Metamask. I have been using ethers.js Wallet to sign transactions, but this doesn't seem to be the correct type to pass in as a supportProvider. I will look into the PrivateKeyWallerSubprovider if that is the way to go.
    – DangarStu
    Jan 20, 2022 at 23:04
0

Edit: The following guide is only for “making” orders, not “taking” orders. Apologies for the confusion.

This gist is a guide on how to create, hash, sign, fill, get state, and cancel a 0x v4 RFQ order. Note that the method of signing an order is the same for limit orders (/orderbook) and RFQ orders (/swap), just the payload is different: https://gist.github.com/PirosB3/8141b51fbb307bca265866ef1cef564f

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.