Introduction

Welcome to the Polkadot SDK Best Practices guide. This book compiles essential insights and best practices derived from BlockDeep's comprehensive code reviews across various Polkadot projects. The purpose of this guide is to help developers, reviewers, and contributors understand and address common issues that can arise in blockchain development when building with Polkadot SDK.

Why this guide?

Polkadot SDK is a powerful and flexible framework, but developing robust, secure, and efficient blockchain applications requires attention to detail and adherence to best practices. This guide serves as a practical reference to help you avoid common pitfalls, enhance code readability, and ensure optimal performance and security.

Structure

This guide is organized by issue severity to help prioritize improvements. Each section covers a severity level:

  • Critical: Issues that pose significant security or performance risks and require immediate action.
  • High: Issues that may not be catastrophic but could impact performance, security, or stability.
  • Medium: Issues that affect maintainability, readability, and efficiency, important to address for a well-optimized codebase.
  • Low: Minor concerns that can improve code clarity and efficiency, but with limited immediate impact.
  • Informational: Suggestions and recommendations that help maintain best practices but are not essential.

Each issue is presented with:

  • Description: An overview of the issue and its potential impact.
  • What should be avoided: Examples illustrating the risks or inefficiencies of poor implementation.
  • Best practice: Suggested best practices, often with code snippets, to guide proper implementation.

How to use this guide

Whether you are conducting a code review, refactoring, or writing new Substrate pallets, this guide is designed to provide actionable insights and practical solutions. We encourage readers to consult this guide regularly to maintain high standards of quality, security, and efficiency in their projects.

Let’s get started!

This introduction sets the purpose and structure of the guide, encouraging readers to use it actively in their development and review processes.