Algem Documentation
🇬🇧 English

Internal practices

Product architecture design workflow

Security is rooted in a sturdy product architecture design. The core principles driving Algem's research and planning approach are:
  • Hacker-Proof Framework: This involves a holistic product security perspective and the integration of features and tools that effectively minimize adverse outcomes.
  • Economic Resilience: This encompasses incentivizing positive behavior, establishing robust ALGM tokenomics and mechanics, protecting the interests of Algem stakeholders, and mitigating various economic risks.
  • Isolation: Ensuring segregation between dApp products and components.
Guided by these principles, the product architecture design workflow unfolds as follows:
  1. 1.
    Problem Identification and Initial Architecture Overview: Initiate the process by identifying the problem to be solved and outlining the initial architecture overview.
  2. 2.
    Information Gathering and Analysis: Collect data through competitor analysis, user statistics, behavior analysis, community feedback, and relevant research. This information provides valuable insights.
  3. 3.
    Internal Review and Discussions: Engage in internal discussions to evaluate the gathered data and refine the initial architecture overview.
  4. 4.
    Update Architecture Overview: Update the initial product architecture overview based on the insights gained from data and internal discussions.
  5. 5.
    Specialist Collaboration: Collaborate with domain experts such as security specialists and economic researchers to scrutinize and enhance the proposed architecture. Formally document the refined architecture design.
  6. 6.
    Community Engagement: Engage with the community through public discussions, gathering feedback on the proposed architecture. Valid suggestions lead to adjustments in product mechanics.
  7. 7.
    Final Architecture Design: Formalize the final product architecture design based on the refined insights, community input, and specialist contributions.
  8. 8.
    Transition to Development: Move from the design phase to the development phase, using the finalized architecture design as the foundation.
  9. 9.
    Publication and Documentation: Once development is completed, publish the product architecture in the documentation. This documentation serves as a reference for stakeholders.

Development workflow

Smart Contract Design: Plan the architecture, logic, and interfaces of contracts meticulously, incorporating the insights derived from the planning phase.
Contract Implementation: Begin writing contracts using Solidity, adhering to the established design. Craft clear, concise, and readable code that accurately embodies the intended functionalities. Abide by best practices, emphasizing modularity and efficient data management to ensure maintainability.
Comprehensive Unit Testing: Develop an extensive suite of unit tests employing frameworks like Mocha or Chai and Foundry. Encompass various scenarios and use cases to validate contract behavior. Rigorous unit testing catches issues early and prevents regressions.
Local Development Testing: Utilize local blockchain networks such as Ganache and Anvil to deploy and interact with contracts throughout the development process. Test diverse scenarios to confirm contract accuracy and efficiency, all without incurring gas costs.
Security Auditing: Execute meticulous security audits of smart contracts, combining manual code reviews and automated analysis tools. The goal is to pinpoint vulnerabilities like reentrancy, integer overflows, and access control concerns. Rigorous auditing mitigates security risks post-deployment.
Deployment Process: Initially deploy contracts to a test network (testnet) to validate behavior in a genuine blockchain setting. Following thorough testing and verification, deploy the finalized contracts to the main network (e.g., Astar network).
Continuous Monitoring and Maintenance: Maintain a vigilant watch over deployed contracts, detecting any unexpected issues or anomalies that may arise during their active usage.
Documentation: Provide comprehensive documentation elucidating contract functions and their usage. This resource ensures that users can effectively understand and interact with the deployed contracts.

Pre-Audit Preparations: Ensuring Contract Integrity

A sequence of meticulous pre-audit procedures are in place to guarantee the operational reliability of the contracts. These steps encompass, yet extend beyond:
Thorough Documentation: Compile comprehensive documentation, featuring UML diagrams that elucidate the architecture. Incorporate Natspec and function header comments to clarify function and contract objectives, alongside their parameters.
Code Alignment with Style Guide: Align the code with the Solidity Style Guide's Contract Layout Recommendations, ensuring a coherent and standardized codebase.
Mathematical Formulas Clarity: Document any utilized mathematical formulas transparently, ensuring their clear comprehension.
Static Analysis Utilization: Employ static analysis tools like Slither and Mythx.io to unearth and resolve rudimentary issues within the pre-audit codebase.
Comprehensive Testing Regimen: Implement a multifaceted testing regime, comprising:
  • Unit Testing: Thoroughly examine basic functions in isolated units.
  • Fuzz Testing: Introduce random data into functions to uncover unexpected outcomes.
  • Regression Testing: Stress-test the system by deploying a beta version onto the testnet.
  • Integration Testing: Conduct tests to ensure the system functions harmoniously as a whole.
Test Integration into Repository: Embed the developed tests into the GitHub repository, enhancing transparency and collaborative contribution.
User Interface Integration: Seamlessly link contracts with the user interface, facilitating live tests to validate real-time functionality.
Community-Driven Pre-Launch Testing: Collaborate with the community to execute comprehensive pre-launch tests, validating system performance and identifying potential anomalies.

Code Refinement: Prerequisites for Development Progression

To ensure seamless advancement in development, a set of pertinent questions must be addressed for the code:
Appropriate Naming Conventions: Are the naming conventions chosen for the code both descriptive and simplistic? If complexity arises, do they find elucidation in a project glossary?
Uniform Style Consistency: Does the code maintain consistent styling throughout the entire codebase, enhancing readability and comprehension?
Modularity Integration: Is the code used in contracts modular? Have intricate operations been divided into smaller, more comprehensible functions? If core functionalities span multiple libraries or contracts, is encapsulation well-executed, facilitating seamless navigation?
Code Readability and Organization: Is the code organized methodically, grouping operations that share similar behaviors? Is it written in a readable manner, fostering ease of understanding?

Smart-Contract Readiness Checklist: Ensuring Thorough Preparation

Prior to proceeding, cross-check the following points:
  • Have all requisite tests been formulated and integrated into the repository containing the contracts?
  • Is documentation outlining the test and contract execution process included in the repository?
  • Have any necessary mathematical formulas and supplementary data been appropriately documented and appended to the repository?
  • Are you aligned with the Solidity Style Guide's Contract Layout Recommendations?
  • Are there no extraneous comments, unused code blocks, or lingering TODOs?
  • Have redundant variables and functions been eliminated?
  • Have adequate access control settings been instituted?
  • Has the code undergone scrutiny via static analysis tools?
  • Has another developer reviewed the code for quality assurance?
  • Is the Solidity version compatibility verified?

Deployment Stages: Ensuring Contract Success

Contract Creation: Begin by crafting the Solidity smart contract code that embodies the desired functionality.
Compilation: Compile the code to generate bytecode, essential for the subsequent deployment process.
Contract Deployment: Initiate a transaction that includes the bytecode, instigating the formation of a new contract instance within the blockchain.
Testing: Rigorously test the deployed contract's functionality on the blockchain, exploring various scenarios and use cases.
Interacting with the Contract: Facilitate user interaction by enabling them to invoke functions and engage with the deployed contract.
Upgrades and Maintenance: Consider the future by contemplating potential updates or fresh iterations of the contract to meet evolving needs.

Post-Deployment Checks and Protocols: Ensuring Excellence

Functionality Testing: Rigorously test various functions and interactions within the live contract, confirming their seamless operation on the actual blockchain.
Security Audit: Collaborate with a seasoned security audit firm to scrutinize the contract's code, pinpointing vulnerabilities, errors, and potential threats.
Gas Usage Optimization: Analyze the gas consumption of contract functions, meticulously optimizing for economical transaction costs.
Access Control Review: Conduct a comprehensive review of access controls, affirming that only authorized users can engage with specific functions and data.
Documentation Review: Reassess and update the contract's documentation, ensuring its alignment with the deployed functionality.
Monitoring and Event Tracking: Enforce event logs and monitoring tools, effectively tracking contract usage and promptly addressing any unusual occurrences.
User Communication: Promptly notify users about the successful contract deployment, providing lucid instructions for interacting with the contract's live version.