Swaplace
  • About Swaplace
    • Manifesto
    • Overview
    • Roadmap
    • Tokenomics (🚧)
    • Start swaping with Swaplace
    • Marketplace
    • Call for contributors
      • ✧ How to start
      • ✧ Incentives
    • Community & Links
  • Developers
    • Guides
      • ✧ Overview
      • ✧ Setting up your local environment
      • ✧ Preparing
        • Encode config
        • Encode ERC1155 Asset
        • Make Swap
      • ✧ Creating
        • ERC20/ERC721
        • ERC1155
        • Native Ether
      • ✧ Accepting
      • ✧ Canceling
    • Technical Reference
      • ✧ Overview
      • ✧ Swaplace
      • ✧ SwapFactory
      • ✧ Interfaces
        • ✧ IERC165
        • ✧ IErrors
        • ✧ ISwap
        • ✧ ISwapFactory
        • ✧ ISwaplace
    • Deployments
Powered by GitBook
On this page
  • Run your local Swaplace
  • Encoding data and making swap
  • Accepting and canceling swaps
  1. Developers
  2. Guides

✧ Overview

PreviousGuidesNext✧ Setting up your local environment

Last updated 11 months ago

Run your local Swaplace

Follow trhough 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 and functions to convert ERC20, ERC721 and ERC1155 token IDs and amounts into a single data unit.

When , 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 or 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.

this
encodeConfig( )
making a swap
accept
cancel
make1155Asset( )