{"id":19303814,"url":"https://github.com/web3w/looksrare-js","last_synced_at":"2026-01-05T20:02:01.138Z","repository":{"id":47815212,"uuid":"508612926","full_name":"web3w/looksrare-js","owner":"web3w","description":"SDK for the LooksRare protocol","archived":false,"fork":false,"pushed_at":"2022-08-25T08:05:57.000Z","size":2173,"stargazers_count":2,"open_issues_count":1,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-02T16:04:20.943Z","etag":null,"topics":["blockchain","ethereum","nfts","sdk"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/web3w.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-06-29T08:42:51.000Z","updated_at":"2024-11-19T03:18:58.000Z","dependencies_parsed_at":"2023-01-16T16:45:32.059Z","dependency_job_id":null,"html_url":"https://github.com/web3w/looksrare-js","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/web3w%2Flooksrare-js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/web3w%2Flooksrare-js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/web3w%2Flooksrare-js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/web3w%2Flooksrare-js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/web3w","download_url":"https://codeload.github.com/web3w/looksrare-js/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245200707,"owners_count":20576674,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["blockchain","ethereum","nfts","sdk"],"created_at":"2024-11-09T23:27:39.742Z","updated_at":"2026-01-05T20:02:01.064Z","avatar_url":"https://github.com/web3w.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# looksrare-js\u003c!-- omit in toc --\u003e\n\nSDK for the LooksRare protocol\nhttps://web3w.github.io/looksrare-js/\n\n## Installation\n\nIn your project, run:\n\n```bash\nnpm i looksrare-js\n```\n\n## Getting Started\n\nTo get started, create a new OpenSeaJS client, called an Openlooksrare 🚢, using your chainId and address:\n\n```JavaScript\nimport {LooksRareSDK} from 'looksrare-js'\nimport {Web3Wallets} from 'web3-wallets'\n\nconst {chainId, address} = new Web3Wallets({name:'metamask'})\n\nconst looksrare = new LooksRareSDK({chainId,address})\n```\n\nIn the browser environment, only the chainId and address need to be configured，If you want to use the bash environment,\nconfigure the private key and RPC\n\n```ts\ntype WalletInfo = {\n    chainId: number;\n    address: string;\n    privateKeys?: string[];\n    rpcUrl?: RpcInfo; // User-defined RPC information of the provider\n}\n\ntype APIConfig = {\n    apiKey?: string; //opensea api key\n}\n``` \n\nAdvanced Settings\n\n```ts\ntype WalletInfo = {\n    offsetGasLimitRatio?: number; // Set the GAS limit offset of the wallet to be greater than 1 eg：1.2\n}\n# TODO\n```\n\n### Fetching Assets\n\nAssets are items on OpenSea. They can be non-fungible (conforming to standards like ERC721), semi-fungible (like ERC1155\nassets), and even fungible (ERC20).\n\nAssets are represented by the `Asset` type, defined in TypeScript:\n\n```TypeScript\n/**\n * Simple, unannotated non-fungible asset spec\n */\nexport interface Asset {\n    // The asset's token ID, or null if ERC-20\n    tokenId: string | undefined;\n    // The asset's contract address\n    tokenAddress: string;\n    // 'erc20' | 'erc721' | 'erc1155' | 'cryptokitties' | 'ensshortnameauction' | 'cryptopunks'\n    schemaName: string;\n    // Optional for fungible items\n    name?: string;\n    data?: string;\n    decimals?: number;\n    chainId?: number;\n    collection?: {\n        \"royaltyFeePoints\": 500,\n        \"royaltyFeeAddress\": \"0x9F7A946d935c8Efc7A8329C0d894A69bA241345A\"\n    };\n}\n\n```\n\nThe `Asset` type is the minimal type you need for most marketplace actions. `SchemaName` is optional. If omitted, most\nactions will assume you're referring to a non-fungible, ERC721 asset. Other options include 'ERC20' and 'ERC1155'.\n\nYou can fetch an asset using the `OpenSeaAPI`, which will return an `OpenSeaAsset` for you (`OpenSeaAsset`\nextends `Asset`):\n\n```TypeScript\n\n\n\n\nconst assetsQuery = {\n    assets: [{\n        asset_contract_addresses,  // string\n        token_ids //string | number | null\n    }],\n    include_orders: true,\n} as AssetsQueryParams\n\nconst assetFee = await looksrare.getAssetsFees([asset_contract_addresses])\n\n```\n\n#### Checking Balances and Ownerships\n\nThe nice thing about the `Asset` type is that it unifies logic between fungibles, non-fungibles, and semi-fungibles.\n\nOnce you have an `Asset`, you can see how many any account owns, regardless of whether it's an ERC-20 token or a\nnon-fungible good:\n\n```JavaScript\n\nconst asset = {\n    tokenId: '9',\n    tokenAddress: '0xb556f251eacbec4badbcddc4a146906f2c095bee',\n    schemaName: 'ERC721'\n}\n\nconst balance = await looksrare.getAssetBalances(asset, accountAddress)\n\n```\n\nYou can use this same method for fungible ERC-20 tokens like wrapped ETH (WETH). As a convenience, you can use this\nfungible wrapper for checking fungible balances:\n\n```JavaScript\nconst balanceOfWETH = await looksrare.getTokenBalance({\n    accountAddress, // string\n    tokenAddress: \"0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2\"\n})\n```\n\n### Making Offers\n\nOnce you have your asset, you can do this to make an offer on it:\n\n```JavaScript\n// Token ID and smart contract address for a non-fungible token:\nconst {tokenId, tokenAddress} = YOUR_ASSET\n\nconst offer = await looksrare.createBuyOrder({\n    asset: {\n        tokenId,\n        tokenAddress,\n        schemaName // WyvernSchemaName. If omitted, defaults to 'ERC721'. Other options include 'ERC20' and 'ERC1155'\n    },\n    // Value of the offer, in units of the payment token (or wrapped ETH if none is specified):\n    startAmount: 1.2,\n})\n```\n\n### Making Listings / Selling Items\n\nTo sell an asset, call `createSellOrder`. You can do a fixed-price listing, where `startAmount` is equal to `endAmount`,\nor a declining [Dutch auction](https://en.wikipedia.org/wiki/Dutch_auction), where `endAmount` is lower and the price\ndeclines until `expirationTime` is hit:\n\n```JavaScript\n// Expire this auction one day from now.\n// Note that we convert from the JavaScript timestamp (milliseconds):\nconst expirationTime = Math.round(Date.now() / 1000 + 60 * 60 * 24)\n\nconst listing = await looksrare.createSellOrder({\n    asset: {\n        tokenId,\n        tokenAddress,\n        schemaName,\n        \"collection\": {\n            royaltyFeeAddress,\n            royaltyFeePoints\n        }\n    },\n    startAmount: 3,\n    // If `endAmount` is specified, the order will decline in value to that amount until `expirationTime`. Otherwise, it's a fixed-price order:\n    endAmount: 0.1,\n    expirationTime\n})\n```\n\n### Posting Order\n\n```ts\n// const orderStr = JSON.stringify(offer)\nconst orderStr = JSON.stringify(listing)\nconst order = await looksrare.postOrder(orderStr).catch((err: any) =\u003e {\n    throw err\n}) \n```\n\n### Fetching Orders\n\nTo retrieve a list of offers and auction on an asset, you can use an instance of the `OpenSeaAPI` exposed on the client.\nParameters passed into API filter objects are underscored instead of camel-cased, similar to the\nmain [OpenSea API parameters](https://docs.opensea.io/v1.0/reference):\n\n```JavaScript\nimport {OrderSide} from 'looksrare-js'\n\n// Get offers (bids), a.k.a. orders where `side == 0` \nconst query = {\n    asset_contract_address: tokenAddress, //\n    token_ids: [tokenId]\n}\nconst {orders, count} = await looksrare.api.getOrders(query)\n\n// Get page 2 of all auctions, a.k.a. orders where `side == 1`\nconst {orders, count} = await looksrare.api.getOrders({\n    asset_contract_address: tokenAddress,\n    token_ids: [tokenId],\n    side: OrderSide.Sell\n}, 2)\n\n// Get Owner Orders\nconst {orders, count} = await looksrare.getOwnerOrders()\n```\n\nNote that the listing price of an asset is equal to the `currentPrice` of the **lowest valid sell order** on the asset.\nUsers can lower their listing price without invalidating previous sell orders, so all get shipped down until they're\ncancelled or one is fulfilled.\n\nTo learn more about signatures, makers, takers, listingTime vs createdTime and other kinds of order terminology, please\nread the [**Terminology Section**](https://docs.opensea.io/reference#terminology) of the API Docs.\n\nThe available API filters for the orders endpoint is documented in the `OrderJSON` interface below, but see the\nmain [API Docs](https://docs.opensea.io/reference#reference-getting-started) for a playground, along with more\nup-to-date and detailed explanantions.\n\n```TypeScript\n/**\n * Attrs used by orderbook to make queries easier\n * More to come soon!\n */\nmaker ? : string, // Address of the order's creator\n    taker ? : string, // The null address if anyone is allowed to take the order\n    side ? : OrderSide, // 0 for offers, 1 for auctions\n    owner ? : string, // Address of owner of the order's asset \n    asset_contract_address ? : string, // Contract address for order's asset \n    token_ids ? : Array \u003c number | string \u003e\n\n    // For pagination\n    limit ? : number,\n    offset ? : number\n```\n\n### Buying Items\n\nTo buy an item , you need to **fulfill a sell order**. To do that, it's just one call:\n\n```JavaScript\nconst orders = await looksrare.api.getOrders({side: OrderSide.Sell, ...})\nconst tx = await looksrare.fulfillOrder(JSON.stringify(orders[0]))\nconsole.log(tx.hash)\nawait tx.wait()\n\nconst orderList = [{orderStr: JSON.stringify(order[0])}, {orderStr: JSON.stringify(order[0])}]\nconst res = await sdk.fulfillOrders({orderList})\nconsole.log(res.hash)\nawait res.wait()\n```\n\nNote that the `fulfillOrder` promise resolves when the transaction has been confirmed and mined to the blockchain. To\nget the transaction hash before this happens, add an event listener (see [Listening to Events](#listening-to-events))\nfor the `TransactionCreated` event.\n\nIf the order is a sell order (`order.side === OrderSide.Sell`), the taker is the *buyer* and this will prompt the buyer\nto pay for the item(s).\n\n### Accepting Offers\n\nSimilar to fulfilling sell orders above, you need to fulfill a buy order on an item you own to receive the tokens in the\noffer.\n\n```JavaScript\nconst orders = await looksrare.api.getOrders({side: OrderSide.Buy, ...})\nconst tx = await looksrare.fulfillOrder(JSON.stringify(orders[0]))\nconsole.log(tx.hash)\nawait tx.wait()\n```\n\nIf the order is a buy order (`order.side === OrderSide.Buy`), then the taker is the *owner* and this will prompt the\nowner to exchange their item(s) for whatever is being offered in return. See [Listening to Events](#listening-to-events)\nbelow to respond to the setup transactions that occur the first time a user accepts a bid.\n\n### Transferring Items or Coins (Gifting)\n\nA handy feature in OpenSea.js is the ability to transfer any supported asset (fungible or non-fungible tokens) in one\nline of JavaScript.\n\nTo transfer an ERC-721 asset or an ERC-1155 asset, it's just one call:\n\n```JavaScript\n\nconst transactionHash = await looksrare.transfer({\n    asset: {tokenId, tokenAddress},\n    fromAddress, // Must own the asset\n    toAddress\n})\n```\n\nFor fungible ERC-1155 assets, you can set `schemaName` to \"ERC1155\" and pass a `quantity` in to transfer multiple at\nonce:\n\n```JavaScript\n\nconst transactionHash = await looksrare.transfer({\n    asset: {\n        tokenId,\n        tokenAddress,\n        schemaName: \"ERC1155\"\n    },\n    toAddress,\n    quantity: 2,\n})\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fweb3w%2Flooksrare-js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fweb3w%2Flooksrare-js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fweb3w%2Flooksrare-js/lists"}