@rsksmart/rif-marketplace-nfts
v0.1.4
Published
RIF NFTs Marketplace
Downloads
34
Readme
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-nfts
Run locally
Run tests:
npm test
Run test linter:
npm run lint
Contracts
ERC721 Simple Placements
Place an NFT for a fixed price.
- Receives payments in:
- ERC-20
- ERC-677
- ERC-777
- Gas
To place an NFT:
- Execute
approve
in NFT giving approval to Simple Placements contract. - 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
placement
method. - Via ERC-20:
- Execute
approve
in token giving allowance of the price amount to Simple Placements. - Execute
buy
.
- Execute
- Via ERC-677:
- Execute
transferAndCall
with parameters:
to
: Simple Placements contract.amount
: given by price -- leftover tokens are not returneddata
: the token ID.
- Execute
- Via ERC-777:
- Execute
send
with parameters:
to
: Simple Placements contract.amount
: given by price -- leftover tokens are not returneddata
: the token ID.
- Execute
- Via gas:
- Execute
buy
method with transaction value paying for price.
- Execute
To unplace an NFT:
- Remove approval the ERC-721 token.
- Execute
unplace
with 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:
web3
version 1.* -web3-v1-contracts
web3
version 2.* -web3-v2-contracts
truffle
-truffle-contracts
ethers
-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: