@rsksmart/rif-marketplace-nfts v0.1.4
RIF Marketplace
Smart Contracts designed to support the buying and selling of NFT tokens using multiple payment options. A specific implementation for RNS domains has been included to be used by the RIF Marketplace .
RIF Name Service (RNS) enables the use of human readable names for blockchain addresses helping users to receive transactions in personalized domains. New RNS Domains can be obtained through the RNS Manager.
This contract allows users to list an NFT token for a fixed price in multiple payment methods (ERC-20, ERC-677, ERC-777, and R-BTC). The contract acts as an escrow, ensuring the NFT is released only when a valid payment is received, allowing the seller to keep control at all times.
Usage
npm i @rsksmart/rif-marketplace-nftsRun locally
Run tests:
npm testRun test linter:
npm run lintContracts
ERC721 Simple Placements
Place an NFT for a fixed price.
- Receives payments in:
- ERC-20
- ERC-677
- ERC-777
- Gas
To place an NFT:
1. Execute approve in NFT giving approval to Simple Placements contract.
2. Execute place with the desired price and payment token. Use token payment 0x00 address for gas payments.
To buy a placed NFT:
- Get the price with
placementmethod. - Via ERC-20:
- Execute
approvein token giving allowance of the price amount to Simple Placements. - Execute
buy.
- Execute
- Via ERC-677:
- Execute
transferAndCallwith parameters:
to: Simple Placements contract.amount: given by price -- leftover tokens are not returneddata: the token ID.
- Execute
- Via ERC-777:
- Execute
sendwith parameters:
to: Simple Placements contract.amount: given by price -- leftover tokens are not returneddata: the token ID.
- Execute
- Via gas:
- Execute
buymethod with transaction value paying for price.
- Execute
To unplace an NFT:
- Remove approval the ERC-721 token.
- Execute
unplacewith the toke id.
Admin:
- Ownable contract. The owner can:
- Set whitelisted tokens and their accepted methods with
setWhitelistedPaymentToken - Change gas payment allowance with
allowGasPayments - Set another owner with
transferOwnership
- Set whitelisted tokens and their accepted methods with
RNS Simple Placements
A specific implementation has been included for RNS which in addition to the basic features explained before it ensures to clean up the domain resolver and owner before transferring to the buyer.
TypeScript typings
There are TypeScript typing definitions of the contracts published together with the original contracts. Supported contract's libraries are:
web3version 1.* -web3-v1-contractsweb3version 2.* -web3-v2-contractstruffle-truffle-contractsethers-ethers-contracts
Troubleshot
- Problems installing
erc1820:- Workaround 1:
- Remove it from
devDependencies - Run
npm i - Run
npm i --save-dev erc1820
- Remove it from
- Workaround 2: use node
v10.16.0
- Workaround 1: