This guide explains how to fetch and verify whitelist data stored on a Universal Profile (UP). We will provide an overview of the approach, its benefits, and a step-by-step implementation.
The whitelist is stored on the Universal Profile using the . The whitelist data is uploaded to IPFS, and the corresponding IPFS hash is linked to the Universal Profile. This method ensures that the whitelist is:
Decentralized
Transparent
Easily verifiable
Problem It Solves
Traditionally, whitelists are managed using centralized tools like Google Docs or private servers. These approaches have significant drawbacks:
Lack of Transparency: Changes can be made without notifying participants.
Risk of Manipulation: Centralized whitelists can be tampered with.
Limited Verifiability: Users cannot independently verify the authenticity of the list.
By leveraging the LUKSO's ERC725Y JSON Schema and IPFS, we ensure:
Decentralization: The whitelist is stored in a tamper-proof manner.
Transparency: Changes are visible and trackable.
Verifiability: Anyone can fetch the whitelist and verify its contents.
Step-by-Step Implementation
Below is a guide on how to fetch the whitelist from and verify the authenticity of the list.
1. Set Up ERC725 and IPFS Configuration
First, initialize the ERC725 schema and configure the RPC and IPFS gateway.
This guide demonstrates how to implement a decentralized and transparent whitelist system using the LUKSO's ERC725Y JSON Schema and IPFS. By storing whitelist data in an immutable and verifiable way, you can enhance trust and security for your users.
Full Code Example
Below is the complete implementation:
import { ERC725JSONSchema } from "@erc725/erc725.js";
// Declare this WhitelistSchema
export const WhitelistSchema: ERC725JSONSchema[] = [
{
name: 'WhiteList',
key: '0x8a96b1a0dbdd35b030216c09625f7daecb85a7c60ab106ad8fc7b9ca633a8a70',
keyType: 'Singleton',
valueType: 'bytes',
valueContent: 'VerifiableURI',
},
];
// Import the WhitelistSchema and create an instance
// import WhitelistSchema from "path/to/WhitelistSchema";
const whitelistInstance = new ERC725(
WhitelistSchema, // Your ERC725 schema for whitelist data
"0xCBD67524Db534D16C3C91E54B3e306Cd5561D8f6", // Finance Bros Universal Profile
'https://42.rpc.thirdweb.com', // Mainnet RPC endpoint
{
ipfsGateway: 'https://api.universalprofile.cloud/ipfs/', // IPFS gateway
}
);
const whitelistData = await whitelistInstance.getData('WhiteList');
const ipfsHash = whitelistData?.value?.url.replace('ipfs://', '');
// Fetch data from IPFS
const response = await fetch(`https://api.universalprofile.cloud/ipfs/${ipfsHash}`);
const jsonData = await response.json();
console.log(jsonData);