diff --git a/index.js b/index.js index eb8f390..d70e466 100644 --- a/index.js +++ b/index.js @@ -66,13 +66,15 @@ app.get("/getBalance", async (request, response) => { const privateKey = "0x5fa4fe1e676efae441cefb579f9af9fea37752e76a7ea99a873ce76df7a5a8e9"; const baseTestnetProvider = new ethers.JsonRpcProvider("https://sepolia-rollup.arbitrum.io/rpc"); -const ercContractAddress = "0x21dfDE84E7F643697E8bBE5b9a97e8B0326775A8"; +const ercContractAddress = "0xB8705d37fc584e35Cb833AD3bEDdcAE5b8bc8dB7"; const utilWallet = new ethers.Wallet(privateKey, baseTestnetProvider); const erc1155Abi = [ "function balanceOf(address account, uint256 id) view returns (uint256)", "function useTicket(address user, uint256 tournament_id) external", "function startTournament(uint256 tournament_id) public", - "function getUserTickets(address user) public view returns (uint256[] memory)" + "function getUserTickets(address user) public view returns (uint256[] memory)", + "function getTournamentParticipentsCount(uint256 tournamentId) public view returns(uint256)" + ]; const contract = new ethers.Contract(ercContractAddress, erc1155Abi, utilWallet); @@ -150,3 +152,15 @@ app.get("/getMyTickets", async(request,response)=>{ response.status(500).json({ error: err.message }); } }) +app.get("/getTournamentParticipentsCount", async(request,response)=>{ + const {id} = request.query; + if(!id){response.status(400).json({error:"id is required"})} + + try{ + const tx = await contract.getTournamentParticipentsCount(address); + response.json({ count: tx.toString() }); + }catch(err){ + console.error("Error reading participents for tourney:", err); + response.status(500).json({ error: err.message }); + } +}) \ No newline at end of file