Gated Access

🚪 Follow the steps and you will be able to connect to your wallet and verify the signature!

## Single Token Gated Documentation

Step 1: Clone Repositories

Clone the repositories from the following URL:

20482048

Step 2: Obtain Contract ID and Get a Valid Token

  • You will need to set up a token to test against with the Mojito team.
  • Using the contract and token address(es) we can create a contractID to test against
  • Those values will be handed off by the Mojito Team
  • Update the key:value pairs in the ConnectWallet.tsx file to the contractID and your wallet address.
20482048

Step 3: Connect your Wallet

  • In order to test this implementation you'll need to connect your wallet.
  • Navigate to your localhost after running the reference-app from your IDE
  • Tap to connect wallet options.
20482048
  • Select MetaMask & connect the valid wallet account.
20482048

Step 4: Verifying Signature & Token owner

Once the wallet is connected, the checkTokenOwner mutation will verify that the connected wallet has a valid token, within the range set, and pass the user along.

  1. verifySignature mutation - This verifies the user has signed into their wallet on the backend.
  2. checkTokenOwners(contractID, walletAddress, rangeStart, rangeEnd) - This mutation verifies and returns valid tokens given the parameters set.

If there are valid tokens, the user will land on the success page which can be edited to display desired content, tokens, code, etc.

720720

Step 5: Disconnect the Wallet

20482048

Step 6: Failure Case

  • Select 'Disconnect' from the Wallet Button dropdown menu.
  • Follow Step 3 and select a wallet that doesn't not have a valid token, or one within the range set.
  • If there are no valid tokens that meet the parameter set, the user will be re-directed to a failure page which can also be set to desired content.
720720

Multi Token Gated Documentation

The Multi-Token implementation setup is similar to single token listed above

  • Below is a sample mutation call to verify tokens contained in the contractID "0xD2fb4DE7e5866888A03Da47311C9AA89CCd4ba27"
  • We include parameters for a date range and ID.
mutation {
  listWalletsWithToken(contractAddress: "0xD2fb4DE7e5866888A03Da47311C9AA89CCd4ba27", startDate: "2022-05-01", endDate: "2022-05-20", networkId: "c8cc718d-94a9-4605-a4bb-05d5aa067fd3") {
    tokenId
    walletAddress
  }
}
  • This mutation checkTokenOwners returns a list of token ids based on a given contractID. If owner-address is valid and matched with the given start and end range, the token array will be returned.
  • This allows for multi-token and multi-gated access for end users.
  • An example of how the customer can use this to provide benefits would be:
    -- Wallet owner A has tokens in the 1-50 range of a contract. When they connect they see the gated content with 'A' items exposed
    -- Wallet owner B has tokens in the 51-100 range of a contract. When they connect they see the gated content with 'B' items exposed
    -- Wallet owner C has tokens in the 1-50 && 51-100 range(s) of a contract. When they connect they see the gated content with 'A' && 'B' items exposed

-- What is Range:

  • There are two parts to it
    a. The values which we pass as input is considered as "Find tokens based on this address between rangeStart(1)-rangeEnd(10)"
    b. We loop through the tokens in the wallet and check against the valid tokens held against the contractID.

  • Implementation:
    -- 1. We loop through the given range where we pass a token to the deployed contract (owner address) and find out the given token, and who is the owner. Similarly, we are passing a token ID here to find out the owner of the given token.
    -- 2. When we fetched the owner address based on the given token, then we compare the owner address with given input walletAddress. In case both the addresses matched based on a given range. We add the token to the token found list.
    -- 3. When all the token owners are found based on the step 2 scenario, we return the token list as a response or else empty list if not token found for given wallet address