Sismo Hub Guide: Create Data Groups Programmatically
Developer tutorial
Last updated
Developer tutorial
Last updated
This beginner-friendly tutorial will walk you through the creation of a .
Group Generators are functions that enable the creation of at the center of the Sismo protocol. Groups are the foundation of all that you can create with .
You can find the pull request associated with this tutorial . It will give you a good feeling of what we are going to create in this tutorial! 👌
Don't hesitate to join our and ping us during a hackathon. We would love to talk to you and meet you there. Don't hesitate to send your PR there as well, we will quickly review and merge it (usually under 1 hour).
Groups are composed of Data Sources:
Web2 accounts: Twitter, GitHub, Telegram
Web3 accounts: Ethereum addresses, ENS, Lens handles
In order to create a Group, we need to build a . This tutorial will guide you through the process of creating one.
There are 3 different ways to define the data of a Group generator, you can use:
A hardcoded list of Data Source (e.g. )
(e.g. )
Already existing (e.g. )
If you want more info on Groups, check out this .
Here is an instance of a Sismo Connect App that has been implemented using the proof-of-humanity Group:
This Sismo Connect App allows you to gate contents/features of your app to Proof of Humanity registrants without revealing the registered addresses.
Here's a sample of the Group and the metadata you will get at the end of the tutorial:
Let's build our Group now 🧑💻
First, clone the Sismo Hub repository and cd
into it:
You can now install all the dependencies with the yarn
command:
Go to the group-generators/generators
folder and create a new folder and a file inside.
You will build your Group in the index.ts
file.
Before creating our tutorial use case, let's create a simple Group with a basic hardcoded list of accounts:
Once your Group Generator is built, you will then need to reference it in the generators
folder:
You can now generate the first version of the tutorial-sismo-early-interactors
Group!
NB: You can add
--help
to know all the commands forgenerate-group
If the group generation went well, here is the log you should see on your terminal:
As you can see we successfully generated the Group, and it contains the 3 elements (red box), these are the 3 accounts you defined in the jsonListData0
variable.
Now that you have an overview of the process of creating a Group, let's move on to the tutorial use case! 🧑💻
And... 🥁 It's already finished!
As you may notice, the data
field is where the Group of Data Sources is stored, and its type is a FetchedData
:
And here's an example of what a FetchedData
object looks like:
Here there is only "0x123...
" type addresses but the fetchedData
object can also contain other different types of accounts:
ENS (e.g. "sismo.eth":"1"
)
Lens handles (e.g. "sismo.lens":"1"
)
GitHub accounts (e.g. "github:leosayous21":"1"
)
Twitter accounts (e.g. "twitter:leosayous21":"1"
)
Telegram accounts (e.g. "telegram:pelealexandru":"1"
)
Last but not least, you may have noticed the "1"
at the end of each account in a Group. This is called: the value and it allows you to add granularity to your Group. For our tutorial, we don't want to make a distinction between each account in the Group, but if we wanted to, we could set a value of 2 for all collectors for instance.
You can now, once again, generate the tutorial-sismo-early-interactors
Group:
If the Group generation went well, here is the log you should see on your terminal:
The Group has been successfully generated and it contains 1550 accounts (red box) at the time of the tutorial. But you may have a different number depending on the number of new collectors from the Sismo Lens post.
As you can see on the screenshot, after the generation, the command returns us some information about the Group you just generated.
You can retrieve the Group data at the path indicated in yellow, and if you want to see a sample of the Group you just generated:
Then the 2 others blue paths are API endpoints that allow you to get from the Group its data and metadata. To use the API:
Your Group Generator is now ready, so it's time to push it in prod!
Then you will have to add a new remote to your repo:
You can also create a new branch for your work:
In this tutorial you should have 2 different files changed:
1 file created: group-generators/generators/tutorial-sismo-early-interactors/index.ts
1 file changed: group-generators/generators/index.ts
Next, add all your changes and push them to your fork:
You will then see on your forked repository the following message, you can click on "Compare & pull request" to begin creating your pull request:
Finally, your Group will be available in the Sismo Hub and anyone will be able to use it to create Badges or Sismo Connect apps, great job! 💪
Now that you have your Group, you can build the following with it:
You can find here boilerplates to run on your computer.
If you want to know how to contribute to the Sismo Hub by creating Groups don't hesitate to check the .
A Group can be used for a .
Let's take the Group as an example and look at these use cases:
After this tutorial, you will be able to create a from your Group through the .
This tutorial will show you how to create a Group and make it usable for a Sismo Connect App through the .
In the course of this tutorial, you will build your first Group named tutorial-sismo-early-interactors
, containing all the collectors of the and all voters of one of the first .
You can install yarn
easily .
As previously stated, we want to fetch all the collectors of the and all voters of one of the first .
To fetch all the accounts we want, you will use the 2 different :
The : it will allow you to fetch all the collectors of the . (1.)
If you want more info on how Data Provider works and how to create one, there is a tutorial for you . This tutorial makes you create a Lens data provider and a function that fetch all Lens post collectors (It's a good time, isn't it 😉)
The: it will allow you to fetch all the voters of one of the first on Snapshot. (2.)
Once this data has been fetched, you'll need to merge it using . A few different Data Operators that allow you to make operations on the data exist. Here you want to keep all the collectors and voters in the Group, so you will use the Union Data Operator. (3.)
During the Group generation, all accounts are resolved into an Ethereum address through a . There is a resolver for each type of Data Source.
For this tutorial, you only use Lens and Snapshot Data Providers which don't require API key. But for other Data Providers (e.g. , ...) or resolvers (e.g. ) an API key is required. So if you want to set an API key for the Data Provider you want to use, you need to create an environment variable. And here is how to do it:
For instance, If you want to add Twitter accounts to your group, you will need a Twitter API Key. Here's how to get one :
Type on your web browser: <blue-link>
NB: You can go to to see the main endpoints of the Sismo Hub API
You don't have to store anything or launch anything on your side. You will just have to add to see your Group Generator live! 😁
First, you will have to the :
You will finally see your branch being compared to the main branch of the repository (blue boxes). You can review your changes and add a meaningful title and comments, and when you are happy with your PR, click "Create Pull request". 😇
For example, here is a valid pull request:
When your PR is merged your Group generator will be registered in the Sismo Hub, and your Group will be generated and sent onchain (through the ).
Don't hesitate to join our and ping us during hackaton. We would love to talk to you and meet you there. Don't hesitate to send your PR there as well, we will quickly review and merge it (usually under 1 hour).
:
using the
creating by yourself using the .
And tutorials that shows how to build Sismo Connect apps.
You want to contribute but you don't have any ideas for Groups to create? Check out the current for some interesting ideas.
If you have any questions or you need help regarding your Group creation process, do not hesitate to join our and ask us in #dev-support or ou . We will be glad to answer you 🤗