You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

customizer-nft

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

customizer-nft

customizer nft

2.1.0
latest
Source
npmnpm
Version published
Weekly downloads
0
-100%
Maintainers
1
Weekly downloads
 
Created
Source

customizer-nft v2.1.0

The Customizer NFT is a library for get all NFTs

Installation

Using npm:

  $ npm i customizer-nft

Code Example

import {useCustomizerNFT} from "customizer-nft";

function App() {
    const [address, setAddress] = useState(null);
    const [listNFTs, setListNFTs] = useState(null);

    const {
        isWalletInstalled,
        eventChangeAccount,
        getAllNFTs,
        connectWallet,
    } = useCustomizerNFT();

    useEffect(() => {
        isWalletInstalled().then(account => setAddress(account));
    }, []);

    useEffect(() => {
        eventChangeAccount(setAddress);
    }, []);

    useEffect(() => {
        getAllNFTs(address).then(NFTs => setListNFTs(NFTs));
    }, [address]);

    const handleConnectWallet = () => {
        connectWallet().then(r => setAddress(r));
    };

    return (
        <div className="App">
            <button onClick={handleConnectWallet}>Connect Wallet</button>

            <div className="list">
                {
                    listNFTs !== null ? listNFTs.map((nft, index) => {
                        return <img src={nft}/>
                    }) : null
                }
            </div>
        </div>
    );
}

export default App;

Package Reference

useCustomizerNFT

returns object with all functions

const {
    isWalletInstalled,
    eventChangeAccount,
    getAllNFTs,
    connectWallet,
} = useCustomizerNFT();

isWalletInstalled

check if wallet is installed and connected

useEffect(() => {
    isWalletInstalled().then(account => setAddress(account));
}, []);

eventChangeAccount

check if user changed account in metamask

useEffect(() => {
    eventChangeAccount(setAddress);
}, []);
ParameterTypeDescription
dispatchDispatch<SetStateAction<string>>Required. Set address state

getAllNFTs

get all NFTs used user address and return array with images link

useEffect(() => {
    getAllNFTs(address).then(NFTs => setListNFTs(NFTs));
}, [address]);
ParameterTypeDescription
addressstringRequired. user address from metamask
netmainnet testnetNot Required. Default state is mainnet, looking for all nfts in mainnet. Second state is testnet looking for nfts in testnet
formatsFilterstring[]Not Required. Default is []. Filter with image format. Example ['.png', '.svg', '.jpg']
limitnumberNot Required. Default is 200 and this max value. Get 200 nfts from account for 1 request. If user has more than limit, make requests after not get all nfts from account

connectWallet

connect wallet after click button event

const handleConnectWallet = () => {
    connectWallet().then(r => setAddress(r));
};

Keywords

customizer

FAQs

Package last updated on 21 Jul 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts