From b8b956a5c398e21a68095a7998dcfad3e0237034 Mon Sep 17 00:00:00 2001 From: Sewmina Date: Tue, 1 Oct 2024 15:10:48 +0530 Subject: [PATCH] get participent address --- index.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 291b4d9..b48602d 100644 --- a/index.js +++ b/index.js @@ -74,8 +74,8 @@ const erc1155Abi = [ "function ticketPrice() view returns (uint256)", "function startTournament(uint256 tournament_id) public", "function getUserTickets(address user) public view returns (uint256[] memory)", - "function getTournamentParticipentsCount(uint256 tournamentId) public view returns(uint256)" - + "function getTournamentParticipentsCount(uint256 tournamentId) public view returns(uint256)", + "function getTournamentParticipants(uint256 tournamentId) public view returns(address[] memory)" ]; const contract = new ethers.Contract(ercContractAddress, erc1155Abi, utilWallet); @@ -179,6 +179,19 @@ app.get("/getTournamentParticipentsCount", async(request,response)=>{ try{ const tx = await contract.getTournamentParticipentsCount(id); response.json({ count: tx.toString() }); + }catch(err){ + console.error("Error reading participents count for tourney:", err); + response.status(500).json({ error: err.message }); + } +}) + +app.get("/getTournamentParticipants", async(request,response)=>{ + const {id} = request.query; + if(!id){response.status(400).json({error:"id is required"})} + + try{ + const tx = await contract.getTournamentParticipants(id); + response.json({ count: tx.toString() }); }catch(err){ console.error("Error reading participents for tourney:", err); response.status(500).json({ error: err.message });