Skip to content

Buyoffers

hugomartinez edited this page Dec 11, 2023 · 1 revision

Buyoffers

Buyoffers allow users to lock in a price for a specific asset owned by another user. The buyer can then wait for the seller to accept the offer, or cancel it at any time. The seller can also decline the offer at any time.


Creating a Buyoffer

Buyoffers are paid from internal balance of the buyer. Therefore, the buyer first needs to deposit the necessary tokens (More Details).

After depositing the required tokens, the buyoffer can be created using the createbuyo action. The price needs to be in the symbol of the token that is used to pay for the buyoffer. The memo is optional and can be used to attach a message for the recipient of the buyoffer. (256 chars max.)

You can sell any number of assets in a single buyoffer. However, all assets need to belong to the same collection, and need to be transferable. Also, the recipient needs to own all the assets.

Accepting the Buyoffer

Accepting a buyoffer requires that the last created AtomicAssets offer to be from the recipient to the AtomicMarket account and need to offer the assets of the buyoffer and ask for nothing in return. The memo needs to be buyoffer.

It is then recommended to use the createoffer action in the AtomicAssets contract in the same transaction as the acceptbuyo action.

The offer previously created by the recipient is then accepted by the AtomicMarket contract, and the assets are consequently transferred to the buyer. The price is deducted from the buyer's balance and the seller / the marketplaces / the collection all have their share of the price added to their balance (Fee structure).


Cancelling Buyoffers

Buyoffers can be cancelled by the buyer using the cancelbuyo action, or declined by the recipient using the declinebuyo action.


Invalid Buyoffers

Not all buyoffers in the buyoffers table can actually be accepted. Inactive and invalid buyoffers should be displayed as such by marketplaces, as they would result in an error when attempting to purchase them.

Inactive Sales

There is only one thing that can make a buyoffer invalid:

  • If the recipient does not own all the assets of the buyoffer, because they transferred it away after the buyoffer was created, the offer can not be created and the AtomicMarket therefore can't get ownership of the assets, and the buyoffer is considered invalid.

A note about smart contract buyers

When a buyoffer is accepted, the AtomicAssets assets are transferred from the contract to the buyer. This triggers an inline notification to the sender of the offer = the buyer. The buyer could deploy a smart contract on their account that makes the transaction throw.

An attacker could for example list assets for way above market price, and then make every accept attempt throw through a smart contract deployed on their account. This is not harmful in and of itself, however it can cause a bad experience for the tricked seller who probably won't understand why they can't accept the offer.

When developing public marketplaces, we therefore advise not to display sales of accounts that have a smart contract deployed, or only display them from trusted smart contract accounts.