Read Sismo Badges
Sismo Badge contract is a Non-Transferable ERC1155 contract. Each badge has it own tokenId. It means that to check whether a user has a specific badge, you just need to fetch their balance for the badge's tokenId.
To use existing Sismo Badges here are all their token ids:
  • Proof of Humanity ZK Badge: 10000009
  • Ethereum Power Users ZK Badge: 10000005
  • Sismo Masquerade Bloomer ZK Badge: 10000004
  • Synaps Lineveness ZK Badge: 30000001
For our two environments, you can find all badges on OpenSea and their metadata on our API endpoints:
Polygon-Playground
Polygon

Check if an user owns the Ethereum Power User badge

Here is a complete example written in typescript for the Ethereum Power Users Badge on the playground environment:
The Ethereum Power Users Badge is available to mint for the top 50k accounts that sent the most transactions between December 31th 2016 and December 31th 2021 (more info on this badge in this Twitter thread). You can find the badge on Opensea. The tokenId for this badge is 10000005.
import { Contract } from "ethers";
import BadgesABI from "./BadgesABI.json"; // Link at the end of the tutorial
import { Badges } from "./BadgesType"; // Link at the end of the tutorial
const provider = new ethers.providers.InfuraProvider(137, [YOUR API KEY])
// Badges contract address on Polygon Playground
const badgesContractAddress = "0x71a7089C56DFf528f330Bc0116C0917cd05B51Fc"
const badgesContract = new Contract(
badgesContractAddress,
BadgesABI,
provider
) as Badges;
const aliceAddress = "0xF61CabBa1e6FC166A66bcA0fcaa83762EdB6D4Bd";
// token id of the Ethereum Power User badge
const EthereumPowerUserTokenId = 10000005;
// query the balance of Alice
const balance = await badgesContract.balanceOf(aliceAddress, EthereumPowerUserTokenId);
// check if the balance of Alice is greater than zero
if (balance.gt(0)) {
console.log("You have the Ethereum Power User badge, well done!")
} else {
console.log("You don't have the Ethereum Power User badge.")
}
The balance of the badge can be used to encode an information or provide a score 😁
And that’s it! 🎉
Now you are able to read Sismo badges in your app.
To let your users mint badges, you can read the next tutorial "Mint a badge from your app" 💜
Here are the resources needed in the snippet:
BadgesABI.json
12KB
Code
ABI of the Badges contract
BadgesType.ts
27KB
Binary
Type generate with Typechain
Copy link