Trading
Methods used for trading ERC20 and NFT between peers. This includes creating trades and accepting trades in addition to configuring the visibility of the trades.
Creating Offers
When creating an offer, the user has the option to either post it on the PintSwap public orderbook for every pint user connected to the network OR privately share it with other individuals.
First, start by creating your first offer with the function below:
Broadcast Offer
Inserts an order into a pint user's peer data instance, pintswap.offers
map, such that it can be traded against, using the structure below:
For NFT trades it is possible to use a field similar to tokenId: '0x01'
instead of the amount
field in either the gets
or gives
field of the offer.
Public Orderbook
To publish offers to the public orderbook, the publishOffers()
function can be used like so:
Publish Offers
Starts and stops publishing the orderbook stored in pintswap.offers
Uses libp2p GossipSub on the /pintswap/0.1.2/publish-orders
topic.
Subscribe to Public Offers
Starts listening for existing and new public orderbook offer publishes.
Accepting Offers
Individual Offer
Appropriate method when accepting and fulfilling an individual offer. This method is most appropriate for NFT and OTC trades.
Requires a PeerId
instance as first argument followed an offer of the structure:
Multiple Offers
Method capable of accepting one or multiple offers at once. Most appropriate for accepting multiple orderbook offers.
Requires a PeerId
instance as first argument followed by an array of order fills of the structure:
Last updated