-
I'm trying to cancel an order using web3.js.
Here is how I called it:
Is there an example of how this method can be implemented? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
I think the type of your In your screenshot, you have an order containing the This order needs to be converted to the correct structure. So far, the only way I could do that is to use a function orderToStruct in the Try including the SDK and use the following. // Import the function from '@rarible/protocol-ethereum-sdk/build/order/sign-order'
import { orderToStruct } from '@rarible/protocol-ethereum-sdk/build/order/sign-order'
...
contract.methods.cancel(orderToStruct(orderJson)).send({ from:selectedAddress }) This should send the right structure to the smart contract and mark this order as canceled in the exchange to make sure no one can fill it again. |
Beta Was this translation helpful? Give feedback.
-
Thanks, it works now! |
Beta Was this translation helpful? Give feedback.
I think the type of your
orderJson
is not the right one. To cancel the order, you need to have the structure of the order as defined here in the cancel function.In your screenshot, you have an order containing the
type
, which is not part of the structure defined in the smart contract.This order needs to be converted to the correct structure. So far, the only way I could do that is to use a function orderToStruct in the
@rarible/protocol-ethereum-sdk
that is used to fill the order but can be used to cancel it as well.Try including the SDK and use the following.