Skip to content

A smart contract that allows a PB Account to declare itself a member of a PB Group

License

Notifications You must be signed in to change notification settings

FigureTechnologies/group-member-approval-smart-contract

Repository files navigation

Group Member Approval Smart Contract

This smart contract provides a way for group members to assert, on chain, their intention to become a member of a Provenance Blockchain Group.

This solves an issue in the groups module: any admin of any group can add a member to a group without their knowledge.
In order to create an ecosystem that respects group member involvement, this grants group members the ability to explicitly state that they intended to become a member of a group.

Status

Latest Release Apache 2.0 License

Documentation

For more information on the internal composition of the contract, view the published documentation.

Contract Instantiation

To instantiate a new instance of the contract, the following parameters are required:

  • contract_name: This name will identify the contract when separate instances are deployed on chain. It can be found via the query_contract_state query.
  • attribute_name: The Provenance Blockchain Name Module name that will be bound to the contract. When the approve_group_membership execution route is invoked, a Provenance Blockchain Attribute will be bound to the invoking account that includes the specified group id as its INT value.
  • bind_attribute_name: If specified as true, the value specified in attribute_name will be automatically bound as a Provenance Blockchain Name to the contract during the instantiation process. If this is omitted, the same name specified in attribute_name must manually be bound after the contract is instantiated. This is useful in circumstances where the name will be bound using a restricted name module namespace.

Example instantiation payload:

{
  "contract_name": "Sample identifying name for auxiliary contract",
  "attribute_name": "somename.sc.pb",
  "bind_attribute_name": true
}

Contract Execution

In order for a member to verify their membership in a group, they must simply invoke the contract's sole execution route with the following payload (with the appropriate group id):

{
  "approve_group_membership": {
    "group_id": "1"
  }
}

Contract Query

The contract currently provides a single query route for verifying its version and naming conventions. It can be queried with the following payload:

{
  "query_contract_state": {}
}

Contract Migration

In order to migrate the contract to new versions, run the migrate command with the following payload:

{
  "contract_upgrade": {}
}

Development Setup

This assumes the user is running Mac OSX.

  • To start developing with Rust, follow the standard guide.
  • The contract uses wasm-pack with its make build command. Use this installer command to install it.
  • To build the contract locally with its make optimize, a Docker Environment is also required.