ZK Social Protocol
  • Introduction
  • UI Clients
  • 💻Developers
    • Overview
    • Identity
      • Pseudonymous Identity
    • Data
      • Schema
      • Simple Node
      • Archive
      • Eviction Policy
    • API
    • Libraries
      • zkitter-js
  • 📓FAQs
    • How to sign up with Metamask?
    • How to chat anonymously?
    • What is an Anonymous account?
    • How to create an anonymous user?
    • How to create a custom group?
    • How does moderation work?
    • What shows up in the global feed?
    • How to upload an image?
    • How to share a WebTorrent seed?
  • Resources
    • Links
Powered by GitBook
On this page

Was this helpful?

  1. Developers
  2. Data

Simple Node

Every domain name will store data in GUN as per the following schema:

const gun = Gun({
    peers: ['gun-seed-1.auti.sm/gun'],
});

gun.user().auth({
    pub: 'my-public-key',
    priv: 'my-private-key',
});

user.put({  
    message: {  
    	[messageHash]: Message  
    }  
});  

Anyone can run a client and observe the AutismRegister contract to get all names with a valid pubkey record, and then observe and store all updates from the public key associated with the identity to provide reliable data duplication for the network:

const contractABI = [
    {
        "anonymous": false,
        "inputs": [
            {
                "indexed": true,
                "internalType": "address",
                "name": "account",
                "type": "address"
            },
            {
                "indexed": false,
                "internalType": "bytes",
                "name": "value",
                "type": "bytes"
            },
            {
                "indexed": false,
                "internalType": "bytes",
                "name": "proof",
                "type": "bytes"
            },
            {
                "indexed": false,
                "internalType": "address",
                "name": "relayer",
                "type": "address"
            }
        ],
        "name": "RecordUpdatedFor",
        "type": "event"
    }
];

const contractAddress = "0x6b0a11F9aA5aa275f16e44e1D479A59dd00abE58";

const registrar = new new Web3().eth.Contract(
    contractABI,
    contractAddress,
);

const gun = Gun({
    peers: ['gun-seed-1.auti.sm/gun'],
});

registrar
    .getPastEvents('RecordUpdatedFor', {
        fromBlock: 2193241,
    })
    .forEach(event => {
        const pubkeyBytes = event.returnValues.value;
        const account = event.returnValues.account;
        const pubkey = Web3.utils.hexToUtf8(pubkeyBytes);
        const user = gun.user(ecdsaPubKey);
        
        user.get('message')
            .map((data, messageId) => {
                // data = Message
                // messageId = "<creator>/<messageHash>"
            });
    });
    

By default, we will run 2 full nodes in North America, 2 in Asia, and 2 in Europe to provide reliable global coverage. These 6 nodes will become the bootstrap peers for anyone trying to connect to Autism.

PreviousSchemaNextArchive

Last updated 3 years ago

Was this helpful?

💻