This smart contract is a decentralized content management system built on the Internet Computer (IC) using Azle. The system allows authors to create articles, allows editors to publish the articles created by authors, and allows admins to manage users and categories.
You can always refer to The Azle Book for more in-depth documentation.
Clone this repository:
git clone https://github.com/ICPHubPH/content-management-system-icp.git
cd content-management-system-icp
dfx
is the tool you will use to interact with the IC locally and on mainnet. If you don't already have it installed:
npm run dfx_install
Next you will want to start a replica, which is a local instance of the IC that you can deploy your canisters to:
npm run replica_start
If you ever want to stop the replica:
npm run replica_stop
Now you can deploy your canister locally:
npm install
npm run canister_deploy_local
To call the methods on your canister:
npm run canister_call <METHOD_NAME>
Assuming you have created a cycles wallet and funded it with cycles, you can deploy to mainnet like this:
npm run canister_deploy_mainnet
To deploy the local Internet Identity instance, run:
npm run internet_identity_deploy_local
To generate declarations for your dapp, run:
dfx generate cms
- initOwner: This method is used to initialize the owner of the contract.
- createUser: This method is used to create a new user. There are two valid user roles,
author
for users who creates the articles andeditor
for editing and approval of the articles. - updateUser: This method is used to update the user's role. Only the owner of the contract can use this method.
- getUsers: This method is used to retrieve all users. Only the owner of the contract can use this method.
- getMe: This method is used to retrieve the current user.
- createArticle: This method is used to create a new article. Only users with the
author
role can use this method. - updateArticle: This method is used to update an article. The
author
can indefinitely edit the article as long as the editorId is None. - getActiveArticles: This method is used to retrieve all active articles.
- getInactiveArticles: This method is used to retrieve all inactive articles. Only
editor
can use this method. - getAllArticles: This method is used to retrieve all articles. Only the owner of the contract can use this method.
- getAllCategories: This method is used to retrieve all categories.
- createCategory: This method is used to create category. Only the owner of the contract can use this method.
- getActiveArticlesByCategory: This method is used to retrieve articles by categoryId.
- getArticlesOfAuthor: This method is used to retrieve all articles of an author. Only the author can use this method.
- getArticlesEditedByEditor: This method is used to retrieve all articles edited by the editor. Only the editor can use this method.
This smart contract is licensed under MIT License. Please see the LICENSE for more information.