Reading Onchain Points
To read data for a given Social Club, you only need its collectionId
. Once you have that, you can query points for a given address
.
How to get the collectionId for a Social Club
From the Social Club page
On a creator's Social Club page, you can get the collectionId
from the tag icon on the bottom right of the badge card, under Rewards.
MadFi Club URL | https://madfi.xyz/creators/madfinance
From the subgraph
If you know the club creator's address
and Lens profileId
you can query our subgraph or check the playground.
API URL | https://api.thegraph.com/subgraphs/name/mad-finance/madfi-subgraph
Reading the onchain points for a Social Club member
Once you have a collectionId
you can use it to query the onchain points for a specific member/ badge holder with just their address
.
From the subgraph
API URL | https://api.thegraph.com/subgraphs/name/mad-finance/madfi-subgraph
From the MadSBT contract
Contract Address (Polygon) | 0x22209D6eAe6cEBA2d059ebfE67b67837BCC1b428
Function interface
With viem
Reading total units distributed in a Social Club
If you want to calculate a given holder's points proportional to the total units distributed in the club, you need to also query the total units distributed. This value can only be read onchain.
Function interface
Calculating the proportional points with viem (same setup as above)
⚠️ NOTE: the totalRewardUnits
function also includes "interim points" - points which the creator has distributed to non-badge holders as an incentive to join. If you wish to exclude these from the calculation, make an onchain call using the following interface and subtract totalInterimRewardUnits
from totalPoints
Last updated