Skip to content

NickGhignatti/stakeshare

Repository files navigation

StakeShare

Stakeshare is an application designed to facilitate the management of participation shares in various initiatives, leveraging blockchain notarization to ensure transparency and security. Developed in Rust and compiled into WebAssembly, Stakeshare runs on the Internet Computer Protocol (ICP). This solution enables users to digitally and decentrally register and exchange ownership or participation shares, with legal certification through the NFT standard (ICRC7). By utilizing smart contracts, Stakeshare automates agreements between parties and the distribution of proceeds, making the process of managing shares simpler, safer, and compliant with regulations.

In this project you can find:

  • An implementation of the Icrc7 standard
  • A factoryß to create Icrc7 token collection
  • A basic backend dapp to play with this kind of token

The backend allows a user (previous login with internet identity) to create a group, identified by a uuid4 with a leader, a name and some members in it. Members are basically users, with a name and an internet identity. When a group is created a partecipation token is assigned to the group leader and the group members, this ownership of those tokens is assigned at the application, and for the user is not tradable/transferrable. Events represent a generic in-real-life event, with an ID (still uuid4), a name and a description. When a user/group of user satisfy the requirements of an event, an event token is assigned to each member, the ownership of the token is of the user who received it.

All the functions in the backend have the same return type RequestResult, inspired by the standard Http response. This custom type is composed from a code, a message and a body, the body is a generic type, and contains what the function should return, the code and the message are a BigInt and a String.

Follows the table with the possible result code:

Code Meaning
200 All fine, the request went fine
400 Duplicate entry
404 The resource could not be find
499 Error while minting the NFT

Prerequisites

  • Rust
  • NodeJs
  • dfx

If you want to start working on your project right away, you might want to try the following commands:

# TODO
cd stakeshare/
dfx help
dfx canister --help

Running the project locally

If you want to test your project locally, you can use the following commands:

# Starts the replica, running in the background
dfx start  --clean --background

# Compile all the packages and create the interface
./script.sh > /dev/null 2>&1

# Deploys your canisters to the replica and generates your candid interface
dfx deploy

Once the job completes, your application will be available at http://localhost:4943?canisterId={asset_canister_id}.

If you have made changes to your backend canister, you can generate a new candid interface with

npm run generate

at any time. This is recommended before starting the frontend development server, and will be run automatically any time you run dfx deploy.

If you are making frontend changes, you can start a development server with

npm start

Which will start a server at http://localhost:8080, proxying API requests to the replica at port 4943.

Note on frontend environment variables

If you are hosting frontend code somewhere without using DFX, you may need to make one of the following adjustments to ensure your project does not fetch the root key in production:

  • setDFX_NETWORK to ic if you are using Webpack
  • use your own preferred method to replace process.env.DFX_NETWORK in the autogenerated declarations
    • Setting canisters -> {asset_canister_id} -> declarations -> env_override to a string in dfx.json will replace process.env.DFX_NETWORK with the string in the autogenerated declarations
  • Write your own createActor constructor

About

ICRC7 token sharing

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages