Integrate with OpenSea using the OpenSea-JS library for seamless interaction with the OpenSea API and smart contracts. This project provides JavaScript functions for various actions, including getting wallet balances, fetching asset details, creating offers, listing assets for sale, and more.
-
Clone the repository:
git clone https://github.com/PrantaDas/opensea-js.git
-
Change to the project directory:
cd opensea-js-integration
-
Install dependencies:
npm install or yarn
-
Create a
.env
file and add the necessary environment variables:MNEMONIC_PHRASE=your_mnemonic_phrase INFURA_API_KEY=your_infura_api_key WALLET_ADDRESS=your_wallet_address
Import the functions you need from the opensea.js
module and use them in your project. Make sure to handle errors appropriately.
const {
getBalance,
getAsset,
getAseetBalance,
getTokenBalance,
createOffer,
listAsset,
getCollectionStat,
placeOrder,
transferAsset,
getAllOrder
} = require('./opensea/opensea');
// Use the functions as needed in your application
// Example: Get wallet balance
const balance = await getBalance('0x12d9c5fd9e271d2ccc3d8697ff9d2d139d534108');
console.log('Wallet Balance:', balance);