✧ Overview

Run your local Swaplace

Follow trhough this guide to learn how to run the Swaplace locally

Encoding data and making swap

Swaplace provides utility functions to efficiently encode and decode assets and configuration data, optimizing storage and retrieval processes. To encode an asset, it uses the encodeConfig( ) and make1155Asset( ) functions to convert ERC20, ERC721 and ERC1155 token IDs and amounts into a single data unit.

When making a swap, the smart contract needs to assemble a Swap struct with detailed parameters including the owner, allowed participants, expiry date, recipient, value, and the assets being offered and requested. This structured approach ensures that all necessary information is included for a successful swap.

Accepting and canceling swaps

Swaplace allows users to accept or cancel swaps with ease.

To accept a swap, ensure that the allowed address matches the caller's address or is set to zero, and that the expiry date is valid. Once a swap is accepted, its expiry is set to zero to prevent reuse.

If you need to cancel a swap, you can do so by setting its expiry to zero, provided that you are the owner and the expiry date is still valid.

Last updated