npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

decentralized-marketplace

v0.1.3

Published

A decentralized marketplace package provides generic methods which helps with not only the connectivity but with the complete interaction with the blockchain. This package contains some generic methods which are being described below:

Downloads

6

Readme

Decentralized Marketplace

A decentralized marketplace package provides generic methods which helps with not only the connectivity but with the complete interaction with the blockchain. This package contains some generic methods which are being described below:

Installation

npm install decentralized-marketplace

Quick Start

// index.js
import { signMessage, mint, sellNftMarket, buyNftMarket, cancelNft, openForAuction, acceptBid} from "decentralized-marketplace";

...

sign(Message).then((response)=>{
    console.log("response", response)
}).catch((err)=>{
    console.log("ops!", err)
})

signMessage(message)

Connection method of metamask which takes 'message' as parameter. It can be anything of a user, or a simple string which will show up on the connection popup on metamask.

mint(payload, contractAddress)

To mint a NFT and give rights to the marketplace is a must to send it to the blockchain. Before Selling or Opening the NFT for bidding, it needs to be minted first. After minting, the data of that particular item can't be changed.

This method takes in 2 parameters. Lets talk about these: 'payload' is of array type which contains an object

payload = [ { to: ownerAddress, uri: ownerImage ? ownerImage : ownerAddress, tokenId: nftTokenId, }, ];

'to' is a paramter which should have the ownerAddress of that item which is about to get minted to the blockchain. This field is of address type. 'uri' is basically a unique string of a user. It either takes the 'Image' string of the user or the Address as unique value(recommended is that address is being provided) 'tokenId' is the Id of that particular item. Its of integer type

'contractAddress' is the address of the contract. Look at the end of the documentation for info about contracts.

sellNftMarket(payload, contractAddress, payloadMarket)

SellNftMarket has 2 smart contract methods: 1- approve 2- openMarketForFixedType

approve funtion approves the item first openMarketForFixedType function opens the order of that particular item which is being approved. These function runs in a sequence

sellNftMarket takes in 3 parameters:

payload = { approved: marketAddress, tokenId: nftTokenId, };

'approved' is basically the address of the market against which we are approving. More info about market address can be found at the end of the documentation. 'tokenId' is the Id of that particular item. Its of integer type

'contractAddress' is the address which has the sellNftMarket function. More info at the end of the documentation.

And finally we have this 'payloadMarket' as parameter which is an object

payloadMarket = { nftContractId: contractAddress, tokenId: nftTokenId, price: NewPrice, };

'nftContractId' is an address against which we are opening the order 'tokenId' is the Id of the item 'price' is the price at which we are opening the order. Its of integer type

buyNftMarket(payload)

This method, by its name is a method for buying an item(which is being approved and sent to the blockchain first, basically the sellNftMarket method is being implemented on that item then we can buy it)

payload = { contractAddress: address, nftContractId: contractAddress, tokenId: nftTokenId, price: sellPrice, };

'contractAddress' is the parameter which contains the function buyNftMarket. Further info is provided at the end 'nftContractId' is the contractAddress of the user who is the owner of the item. 'price' is the price of integer type at which the item is selling at.

cancelNft(payload)

This method takes in payload object which. It is used to cancel the listing of the item from the blockchain.

contractPayload = { contractAddress: contractAddress, nftContractId: contractAddress, tokenId: nftTokenId,
};

'contractAddress' is the address which contains the cancelNft function 'nftContractId' is the address against which the item was approved and being put on the blockchain 'tokenId' is the Id of the item

openForAuction(payload)

openForAuction has 2 smart contract methods: 1- approve 2- openMarketForAuctionType

approve funtion approves the item first openMarketForAuctionType function opens the order of that particular item which is being approved and the bidding can be done on it. These function runs in a sequence

openForAuction takes in 3 parameters:

payload = { nftContractId: contractAddress, tokenId: nftTokenId, minPrice: minAmount, maxPrice: maxAmount, contractAddress: address, };

'nftContractId' is basically the address of the market against which we are approving. More info about market address can be found at the end of the documentation. 'tokenId' is the Id of that particular item. Its of integer type 'minPrice' is the minimum amount which can be bid on the item 'maxAmount' is the maximum amount which can be bid on the item 'contractAddress' is the address which has the openMarketForAuctionType function. More info at the end of the documentation.

acceptBid(payload)

openForAuction has 2 smart contract methods: 1- approve 2- openMarketForAuctionType

approve funtion approves the item first openMarketForAuctionType function opens the order of that particular item which is being approved and the bidding can be done on it. These function runs in a sequence

openForAuction takes in 3 parameters:

payload = { contractAddress: address, tokenId: nftTokenId, price: price, buyerAddress: buyerAddress, nftContractAddress: contractAddress, };

'contractAddress' is the address which has the acceptBid function. More info at the end of the documentation. 'tokenId' is the Id of that particular item. Its of integer type 'price' is the amount which is being bid on the item 'buyerAddress' is the address of the buyer 'nftContractAddress' is the address of the nft which has bid on

Addresses

WBNB => 0x6cfB4Daf6b2AbbfE7c0db97F0013bfB76E43D276 Custom MarketplaceNFT => 0xEdb8Ed342Fb457177F8e440F0924Df3964A51C63 lib Marketplace => 0x21795B124105b939d451cb713C83a4488A7A2a93

These are are list of addresses which contains all the BSC smart contract functions used in this package.