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

@artman325/community

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@artman325/community

Smart contract for managing community membership and roles

latest
Source
npmnpm
Version
1.2.0
Version published
Maintainers
1
Created
Source

CommunityContract

Smart contract for managing community membership and roles. Also has implemented NFT Interface. When role granted to user, user obtained NFT for each role. User can customize own NFT and specify ExtraURI

Deploy

Any user can create own community by call method produce of CommunityFactory contract: produce(hook, name, symbol)

Latest contract instances in test networks

20220630
Ethereum Rinkeby Testnet
CommunityFactory

Binance SmartChain TestNet
CommunityFactory

ABI
factory abi instance abi


Binance SmartChain TestNet
TBD
# Old versions

Overview

There are 6 predefined roles:

role namerole index
relayers1
owners2
admins3
members4
alumni5
visitors6

Role relayers is web servers X which can register new accounts in community via invite by owners/admins or some who can manage.

Roles owners is a single role that can magage itself. means one owner can add(or remove) other owner.

Contract can be used as external storage for getting list of members.

Any user obtain NFT with tokenID = (roleid <<160)+walletaddress Any who can manage certain role can setup tokenURI for this role by calling setRoleURI.
Also any member can setup personal URI for his role by calling setExtraURI.

Full methods for each contracts can be find here Community Most usable method 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"
invitePrepareonly "relayers"storing signatures of invite
inviteAcceptonly "relayers"accepting admin's invite
inviteViewanyoneReturns tuple of invite stored at contract

Methods

grantRoles

adding accounts to new roles. Can be called any role which manage roles. Revert if any roles can not be managed by sender

Params:

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

revokeRoles

removing roles from certain accounts. Can be called any role which manage roles. Revert if any roles can not be managed by sender

Params:

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

createRole

Creating new role. Сan called by owners

Params:

nametypedescription
rolestringname of role

manageRole

allow account with byRole setup ofRole to another account with default role(members). Сan called only 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 belong to role

Params:

nametypedescription
roleuint8index of role.

getRoles

Returns all roles which member belong to

Params:

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

addressesCount

Returns number of all accounts belong to role

Params:

nametypedescription
roleuint8index of role.

invitePrepare

Storing signatures of invite

Params:

nametypedescription
sSigbytesadmin's signature
rSigbytesrecipient's signature

inviteAccept

Accepting admin's invite

Params:

nametypedescription
pstringadmin's message which will be signed
sSigbytesadmin's signature
rpstringrecipient's message which will be signed
rSigbytesrecipient's signature

inviteView

Returns tuple of invite stored at contract

Params:

nametypedescription
sSigbytesadmin's signature

Return Tuple:

nametypedescription
sSigbytesadmin's signature
rSigbytesrecipient's signature
gasCostuint256stored gas which was spent by relayers for invitePrepare(or and inviteAccepted)
reimbursedENUM(0,1,2)ReimburseStatus (0-NONE,1-PENDING,2-DONE)
usedboolif true invite is already used
existsboolif true invite is exist

Example to use

visit wiki

FAQs

Package last updated on 16 May 2023

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