Ways to enable token gated matchmaking with tokens as NFT rewards:
1. ERC721: tokens are moved to an escrow account, afterwards a match room is created. Tokens are moved to match winners after match completion.
2. ERC7066: tokens are locked in user wallets to create a match room and transferred to the match winner.
Added advantage of using ERC7066 is project access to integration-less NFT liquidity solutions requiring 0 dev efforts.
Steps:
Get signer
// function to get user signer from walletuser.signer=streamSDK.getWalletSigner()
// function to get user signer from privatekeyuser.signer=streamSDK.getSigner(privateKey)
Join room
// function to create/join a room// @param user.id is userId of player// @param user.address user wallet address// @param tokenAddress contract address of NFT// @param tokenId token Id owned by user// @param user.signer provides a wallet instance to sign txn// @param roomSize number of players needed to create a room// @returns userId of winnerawaitstreamSDK.joinRoom(user.id,user.address, tokenAddress, tokenId,user.signer, roomSize) returns {roomId,userId}
Claim match reward
// function to share winnings to winner// @param roomId roomId of match// @param user.address user wallet addressawaitstreamSDK.winnerClaim(roomId,user.address);