From 052ea4d3175ebcdd476a5ed5860edb63d309375e Mon Sep 17 00:00:00 2001 From: Tony C Date: Tue, 19 Aug 2025 23:53:05 +0400 Subject: [PATCH 1/3] Elaborate on Frontend integration --- .../integration/frontend-integration/page.mdx | 176 ++++++++++++++++++ 1 file changed, 176 insertions(+) create mode 100644 src/app/integration/frontend-integration/page.mdx diff --git a/src/app/integration/frontend-integration/page.mdx b/src/app/integration/frontend-integration/page.mdx new file mode 100644 index 0000000..af6aa7c --- /dev/null +++ b/src/app/integration/frontend-integration/page.mdx @@ -0,0 +1,176 @@ +--- +description: Information on how to integrate on the frontend with Biomapper. +--- + +import { Tabs, Callout } from "nextra/components"; + +# Frontend Integration + +Integrating on the frontend with Biomapper on Humanode chain is a simple process of 2 contract calls. + + + Ignoring [generations](/generations) could lead to Sybil attacks. + + +This page describes integration with Biomapper on Humanode chain only. +To integrate with Biomapper on other chains check [Bridging page](/bridging) +and `Frontend` section of a [bridged chain](/#bridged-chains). + +## Simple Example + +Here is an example of how to check if a wallet is biomapped in the last generation +on Humanode Biomapper. + +### Get contract ABI + +The proper way is to create ABI from `IBiomapperLogRead` interface in `@biomapper-sdk/core`. + +Alternatively you can use these 2 functions: + + +> + + ```ts + const biomapperAbi = parseAbi([ + "function generationsHead() external view returns (uint256)", + "function generationBiomapping(address account, uint256 generationPtr) external view returns (uint256)", + ]); + ``` + + + + ```ts + const biomapperAbi = [ + "function generationsHead() external view returns (uint256)", + "function generationBiomapping(address account, uint256 generationPtr) external view returns (uint256)", + ]; + ``` + + + +### Get contract address + +Look up the [contract addresses](/contract-addresses) page for `BiomapperLog` contract address info. + +For the Biomapper on Humanode Mainnet: + +```ts +const biomapperContractAddress = "0x877Bb6c2d22918563c4688e68b62c2F678Cc0BFD"; +``` + +For the Biomapper on Humanode Testnet 5: + +```ts +const biomapperContractAddress = "0x3f2B3E471b207475519989369d5E4F2cAbd0A39F"; +``` + +### Get current biomapping generation + + +> + + See more about `readContract` function on https://viem.sh/docs/contract/readContract. + + ```ts + const lastGeneration = await publicClient.readContract({ + address: biomapperContractAddress, + abi: biomapperAbi, + functionName: "generationsHead", + }); + ``` + + + + See more about how to read Ethers contracts on https://docs.ethers.org/v6/getting-started/#cid_56. + + ```ts + // Prepare re-usable contract definition. + const biomapperContract = new Contract(biomapperContractAddress, biomapperAbi, provider); + + const lastGeneration = await biomapperContract.generationsHead(); + + ``` + + + + +### Get biomapping status in the last generation + +To get biomapping status for some address `addressToCheck` in the last generation + + +> + + ```ts + const biomappingPtrInLastGeneration = await publicClient.readContract({ + address: biomapperContractAddress, + abi: biomapperAbi, + functionName: "generationBiomapping", + args: [addressToCheck, lastGeneration], + }); + ``` + + + + ```ts + const biomappingPtrInLastGeneration = + await biomapperContract.generationBiomapping( + addressToCheck, + lastGeneration + ); + + ``` + + + + +`biomappingPtrInLastGeneration` is the block number on +Humanode Mainnet (or Humanode Testnet 5) +of biomapping tx in the last generation for specified address, +or zero if such address is not biomapped. + +```ts +const biomappingStatus = biomappingPtrInLastGeneration !== 0n; +``` + +## Alternative way + +To get biomapping status in an example above 2 functions are used: + +1. `generationsHead` to get block number of the last generation change tx; +2. `generationBiomapping` to get block number of biomapping tx in the last generation. + +The other way to get the status is: + +1. the same `generationsHead`; +2. `biomappingsHead` to get block number of the last biomapping tx for a specified account; +3. compare these block numbers. + +The ABI will be + +```json +[ + "function generationsHead() external view returns (uint256)", + "function biomappingsHead(address account) external view returns (uint256)" +] +``` + +In this case `biomappingStatus` will be calculated like this: + +```ts +const biomappingStatus = lastBiomapping > lastGeneration; +``` + +## Generations + +While this example can be helpful to show if the account is biomapped now, +in real dApps the generations should be taken into account. + +A restriction to a specific generation only could be sufficient +to prevent Sybil attacks. From 7c77a30693b03a1c5c3e93d90510fdcdf3fa9b3e Mon Sep 17 00:00:00 2001 From: MOZGIII Date: Wed, 27 Aug 2025 20:19:30 +0400 Subject: [PATCH 2/3] Move the pages around --- src/app/integration/_meta.ts | 2 ++ .../{frontend-integration => humanode}/page.mdx | 7 ++++--- 2 files changed, 6 insertions(+), 3 deletions(-) rename src/app/integration/{frontend-integration => humanode}/page.mdx (95%) diff --git a/src/app/integration/_meta.ts b/src/app/integration/_meta.ts index a334a2a..be58198 100644 --- a/src/app/integration/_meta.ts +++ b/src/app/integration/_meta.ts @@ -9,6 +9,8 @@ export default { href: links.biomapperSdkDocs, }, + humanode: "Humanode", + chains: { // This is not really a separator, it get overwritten by our hacks // at `pageMap.ts`. diff --git a/src/app/integration/frontend-integration/page.mdx b/src/app/integration/humanode/page.mdx similarity index 95% rename from src/app/integration/frontend-integration/page.mdx rename to src/app/integration/humanode/page.mdx index af6aa7c..df22fd0 100644 --- a/src/app/integration/frontend-integration/page.mdx +++ b/src/app/integration/humanode/page.mdx @@ -1,12 +1,13 @@ --- -description: Information on how to integrate on the frontend with Biomapper. +title: Integrating with Humanode Biomapper on Humanode. --- import { Tabs, Callout } from "nextra/components"; +import { stages } from "../../../data/stages"; -# Frontend Integration +# Humanode -Integrating on the frontend with Biomapper on Humanode chain is a simple process of 2 contract calls. +Integrating with Humanode Biomapper on Humanode network. Ignoring [generations](/generations) could lead to Sybil attacks. From 4f9dd48405dedc28b6fb47521cac21e210887daa Mon Sep 17 00:00:00 2001 From: MOZGIII Date: Wed, 27 Aug 2025 20:24:49 +0400 Subject: [PATCH 3/3] Use double quotes and proper addresses --- .../chains/[bridgedChainId]/content.mdx | 4 ++-- src/app/integration/humanode/page.mdx | 15 +++++++++------ 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/app/integration/chains/[bridgedChainId]/content.mdx b/src/app/integration/chains/[bridgedChainId]/content.mdx index 5e64378..07599bb 100644 --- a/src/app/integration/chains/[bridgedChainId]/content.mdx +++ b/src/app/integration/chains/[bridgedChainId]/content.mdx @@ -94,7 +94,7 @@ For the Biomapper on {props.bridgedChain.generalDisplayName} Mainnet: {/* prettier-ignore */} - const biomapperContractAddress = '{stages[mainStageId].bridged[props.bridgedChainId]?.addresses.bridgedBiomapper}'; + const biomapperContractAddress = "{stages[mainStageId].bridged[props.bridgedChainId]?.addresses.bridgedBiomapper}"; @@ -103,7 +103,7 @@ For the Biomapper on {stages["testnet5"].bridged[props.bridgedChainId]?.displayN {/* prettier-ignore */} - const biomapperContractAddress = '{stages["testnet5"].bridged[props.bridgedChainId]?.addresses.bridgedBiomapper}'; + const biomapperContractAddress = "{stages["testnet5"].bridged[props.bridgedChainId]?.addresses.bridgedBiomapper}"; #### Get current biomapping generation diff --git a/src/app/integration/humanode/page.mdx b/src/app/integration/humanode/page.mdx index df22fd0..af128a4 100644 --- a/src/app/integration/humanode/page.mdx +++ b/src/app/integration/humanode/page.mdx @@ -4,6 +4,7 @@ title: Integrating with Humanode Biomapper on Humanode. import { Tabs, Callout } from "nextra/components"; import { stages } from "../../../data/stages"; +import { MDX } from "../../../components/mdx"; # Humanode @@ -57,15 +58,17 @@ Look up the [contract addresses](/contract-addresses) page for `BiomapperLog` co For the Biomapper on Humanode Mainnet: -```ts -const biomapperContractAddress = "0x877Bb6c2d22918563c4688e68b62c2F678Cc0BFD"; -``` +{/* prettier-ignore */} + + const biomapperContractAddress = "{stages.mainnet.humanode.addresses.biomapperLog}"; + For the Biomapper on Humanode Testnet 5: -```ts -const biomapperContractAddress = "0x3f2B3E471b207475519989369d5E4F2cAbd0A39F"; -``` +{/* prettier-ignore */} + + const biomapperContractAddress = "{stages.testnet5.humanode.addresses.biomapperLog}"; + ### Get current biomapping generation