Understanding Order Cancellations

Cancelling orders based on a 0x contract is an on-chain event.

For the order you wish to cancel validate that the order you wish to cancel has not been filled yet.

await contractWrappers.exchange.validateFillOrderThrowIfInvalidAsync(sraOrder, takerAssetAmount, taker);

As long as the order is still valid sign the transaction hash so that you are the taker of your own order and submit it to the chain using fillOrderAsync.

txHash = await contractWrappers.exchange.fillOrderAsync(sraOrder, takerAssetAmount, taker);
await web3Wrapper.awaitTransactionSuccessAsync(txHash);

The Web3Wrapper submits this transaction to the Ethereum blockchain making the same address both the maker and the taker; effectively cancelling the order. For more details see the 0x documentation on Github