Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/elmariachi111/royalty-marketplace
https://github.com/elmariachi111/royalty-marketplace
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/elmariachi111/royalty-marketplace
- Owner: elmariachi111
- Created: 2022-04-18T21:26:19.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-04-25T10:20:02.000Z (over 2 years ago)
- Last Synced: 2023-03-30T03:07:45.633Z (over 1 year ago)
- Language: JavaScript
- Size: 223 KB
- Stars: 3
- Watchers: 1
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# royalty aware marketplace sample
`ClosedDesert` allows users to offer their NFTs for a fixed price.
The marketplace obeys the purchased collection's royalty rules
and distributes fees accordingly. It uses the general [Royalty Registry](https://royaltyregistry.xyz/)
fee lookup contract on mainnet.## running
To test this under real life conditions against arbitrary NFT collections, it's best executed on a local **fork of mainnet**. This is how you could achieve that using [truffle](https://trufflesuite.com/) and [ganache](https://github.com/trufflesuite/ganache):
- go to your favorite (real) marketplace and find two real world addresses that own ERC721 NFTs and some Eth for gas. Take a note of the NFT collection's contract address.
- get yourself an [Infura key](https://infura.io) to get access to mainnet nodes
- fork mainnet instantly on your local machine. Unlock the accounts that own NFTs (seller) or have Eth on them (buyer)```
npx ganache --fork https://mainnet.infura.io/v3/ --unlock <0x-seller-address> --unlock
```- compile the contracts
```
npx truffle compile
```- deploy contracts on your mainnet fork:
```
npx truffle migrate --network mainfork
```- adjust the collection / buyer / seller addresses in our test script according to the accounts you unlocked on your forked chain
```testMarketPlace.js
const azukiNftAddress = "0x-collection-address";
const tokenId = 1234;
const sellerAddress = "0x-seller-address";
const buyerAddress = "0x-buyer-address";
```- run the test script. It puts the seller's token on sale and will have the buyer account buy it.
```
npx truffle exec scripts/testMarketplace.js --network mainfork
```sample output for a collection that takes a 5% royalty:
```
owner of 0xed5af388653567af2f388e6224dc7c4b3241c544 #3157 0xDFe0CB7fbC3830C4D413a552A7c707270fD5C72B
Seller Balance (Eth): 0.1776181781880788
owner of 0xed5af388653567af2f388e6224dc7c4b3241c544 #3157 0x5E904A05033D728315dD23Bea210d17A68cA3d19
Seller Balance (Eth): 1.1276181781880788
Seller Balance Diff (Eth): 0.95
```