New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@intercoin/community

Package Overview
Dependencies
Maintainers
0
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@intercoin/community

Smart contract for managing community membership and roles

latest
Source
npmnpm
Version
1.2.2
Version published
Maintainers
0
Created
Source

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 git@github.com: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 namerole index
owners1
admins2
members3
alumni4
visitors5

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:

method namecalled bydescription
grantRolesAny role which manage "roles"adding members to new "roles"
revokeRolesAny role which manage "roles"removing members from "roles". Revert if any roles can not be managed by sender
createRoleonly `owners`Creating new role
manageRoleonly `owners`allow account with "byRole" setup "ofRole" to any another account
getAddressesanyoneReturns all accounts belong to "role"
getRolesanyoneReturns all roles which account belong to
addressesCountanyoneReturns number of all members belong to "role"

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:

nametypedescription
accountsaddress[]account's address
rolesuint8[]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:

nametypedescription
accountsaddress[]accounts's address
rolesuint8[]indexes of roles

createRole

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

Params:

nametypedescription
rolestringname 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:

nametypedescription
byRoleuint8index of source role
ofRoleuint8index of target role
canGrantRoleboolif true then byRole can grant ofRole to account, overwise - disabled
canRevokeRoleboolif true then byRole can revoke ofRole from account, overwise - disabled
requireRoleuint8target account should be in role requireRole to be able to obtain ofRole. if zero - then available to everyone
maxAddressesuint256amount of addresses that be available to grant in duration period(bucket) if zero - then no limit
durationuint64if 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:

nametypedescription
roleuint8index of role.

getRoles

Returns all roles that a member belongs to.

Params:

nametypedescription
accountaddressaccount's address. [optional] if not specified returned all roles

addressesCount

Returns the number of all accounts belonging to a role.

Params:

nametypedescription
roleuint8index of role.

Example to use

visit wiki

License

MIT

FAQs

Package last updated on 08 Jul 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts