You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// 1. Get LooksRare V1 listingconstcollection="0xBC4CA0EdA7647A8aB7C2061c2E118A18a936f13D";constlooksRareTokenId=1;constseaportTokenId=1;letoptions={method: "GET",headers: {accept: "application/json"}};letres=awaitfetch(`https://api.looksrare.org/api/v2/orders?collection=${collection}&itemId=${looksRareTokenId}`,options);letresponseJson=awaitres.json();constlooksRareOrder=responseJson.data[0];// 2. Get Seaport listingoptions={method: "GET",headers: {accept: "application/json","X-API-KEY": process.env.OPENSEA_API_KEY},};res=awaitfetch(`https://api.opensea.io/v2/orders/ethereum/seaport/listings?asset_contract_address=${collection}&token_ids=${seaportTokenId}&order_by=created_date&order_direction=desc`,options);responseJson=awaitres.json();constseaportOrder=responseJson.orders[0].protocol_data;// 3. Transform listings into LooksRare aggregator format (From the browser)constprovider=newethers.providers.Web3Provider(web3.currentProvider);constbuyer=provider.getSigner();// 3. Transform listings into LooksRare aggregator format (From ethers.js directly)constprivateKey='0x......';constrpcUrl='https://rpc.ankr.com/eth';constprovider=newethers.providers.JsonRpcProvider(rpcUrl);constbuyer=newethers.Wallet(privateKey,provider);constchainId=1;constaggregator=newLooksRareAggregator(signer,chainId);const{ tradeData, actions }: TransformListingsOutput=awaitaggregator.transformListings({seaport_V1_4: [],seaport_V1_5: [seaportOrder],looksRareV2: [looksRareOrder],});// Actions are required when the orders are paid in ERC-20 tokens and the buyer has not granted// sufficient allowances to the aggregator.awaitPromise.all(actions.map((action)=>action()));constisAtomic=false;awaitaggregator.execute(tradeData,buyer.address,isAtomic).call();