npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@intercoin/community

v1.2.2

Published

Smart contract for managing community membership and roles

Downloads

15

Readme

CommunityContract

This repository contains the Community Contract, a smart contract that manages roles and permissions within a community.

The list of basic features:

  • The owner can create roles and manage roles and permissions for other roles.
  • When a role is granted to a user, the user obtains an NFT for each role.
  • Supports the protocol of Native Meta Transactions (ERC-2771).
  • Supports the ownable interface from the OpenZeppelin library, accessible to any user in the "owners" role.
  • Uses the standard for representing ownership of non-fungible tokens (ERC-721) with small changes:
    • Every person who has a role also has an NFT that represents belonging to this role. Such an NFT cannot be transferred or burnt. However, when an admin revokes a role from the user, the NFT also disappears.

Installation

You can clone the repository from GitHub:

git clone [email protected]:Intercoin/CommunityContract.git

or install it using npm:

npm i @artman325/community

Deploy

Any user can create their own community by calling the produce method of the CommunityFactory contract: produce(hook, invitedHook, name, symbol).

Link for the factory below

Factory's addresses depend of networks

Overview

There are 6 predefined roles:

role name| role index --|-- owners|1 admins|2 members|3 alumni|4 visitors|5

The owners role is a single role that can manage itself, meaning one owner can add or remove other owners.

The contract can be used as external storage for getting a list of members.

Any user obtains an NFT with tokenID = (roleid << 160) + walletaddress.
Anyone who can manage a certain role can set up the tokenURI for this role by calling setRoleURI.

Full methods for each contract can be found here: Community. The most usable methods will be described below:

Methods

grantRoles

Adds accounts to new roles. Can be called by any role that manages roles. Reverts if any roles cannot be managed by the sender.

Params: name | type | description --|--|-- accounts|address[]| account's address
roles|uint8[]| indexes of roles

revokeRoles

Removes roles from certain accounts. Can be called by any role that manages roles. Reverts if any roles cannot be managed by the sender.

Params: name | type | description --|--|-- accounts|address[]| accounts's address
roles|uint8[]| indexes of roles

createRole

Creates a new role. Can only be called by owners.

Params: name | type | description --|--|-- role|string| name of role

manageRole

Allows an account with byRole to set up ofRole for another account with the default role (members). Can only be called by owners.

Params: name | type | description --|--|-- byRole|uint8| index of source role ofRole|uint8| index of target role canGrantRole|bool| if true then byRole can grant ofRole to account, overwise - disabled canRevokeRole|bool| if true then byRole can revoke ofRole from account, overwise - disabled requireRole|uint8| target account should be in role requireRole to be able to obtain ofRole. if zero - then available to everyone maxAddresses|uint256| amount of addresses that be available to grant in duration period(bucket) if zero - then no limit duration|uint64| if zero - then no buckets. but if maxAddresses != 0 then it's real total maximum addresses available to grant

getAddresses

Returns all accounts belonging to a role.

Params: name | type | description --|--|-- role|uint8| index of role.

getRoles

Returns all roles that a member belongs to.

Params: name | type | description --|--|-- account|address | account's address. [optional] if not specified returned all roles

addressesCount

Returns the number of all accounts belonging to a role.

Params: name | type | description --|--|-- role|uint8| index of role.

Example to use

visit wiki

License

MIT