Unlock the potential of decentralized applications with your own custom blockchain.
- Introduction
- Features
- Prerequisites
- Installation
- Running the Node
- Developing Smart Contracts
- Integrating the Frontend
- Project Structure
- Contributing
This project demonstrates how to build a Web3 application using Substrate and Rust. It includes:
- A custom Substrate blockchain node.
- Smart contracts developed with ink!.
- A frontend application interacting with the blockchain via the Polkadot.js API.
By following this guide, you'll set up a local blockchain network, deploy smart contracts, and integrate them with a frontend application.
- Customizable Blockchain Node: Modify and extend your blockchain's runtime.
- Smart Contract Support: Write and deploy smart contracts using ink!.
- Frontend Integration: Interact with your blockchain through a user-friendly interface.
- Modular Design: Easily add new pallets and functionalities.
Before you begin, ensure you have the following installed:
- Rust and Cargo: Install Rust
- Node.js and npm: Install Node.js
- Git: Install Git
- cargo-contract: For ink! smart contract development
git clone https://github.com/yourusername/yourproject.git
cd yourproject
Ensure that you have the latest stable Rust toolchain:
rustup install stable
rustup update
Follow the official Substrate installation guide for your operating system.
cargo install cargo-contract --force
cd backend
cargo build --release
Start your local blockchain node:
./target/release/backend-template --dev
This command runs the node in development mode with temporary state.
cd contracts/my_contract
cargo +nightly contract build
Use the Polkadot.js Apps UI to deploy your contract:
- Navigate to the Contracts tab.
- Upload your contract's
.contract
metadata file from thetarget
directory. - Follow the on-screen instructions to deploy.
cd frontend
npm install
Ensure the frontend is configured to connect to your local node. Update the WebSocket endpoint in your configuration file (e.g., config.js
):
module.exports = {
providerEndpoint: 'ws://localhost:9944',
};
npm start
Visit http://localhost:3000
in your browser to interact with your application.
yourproject/
├── node/ # Custom Substrate node
│ ├── src/
│ └── Cargo.toml
├── runtime/ # Runtime modules (pallets)
│ ├── src/
│ └── Cargo.toml
├── contracts/ # ink! smart contracts
│ └── my_contract/
│ ├── src/
│ └── Cargo.toml
├── frontend/ # Frontend application
│ ├── src/
│ ├── package.json
│ └── ...
├── scripts/ # Deployment and utility scripts
├── README.md
└── LICENSE
Contributions are welcome! Please follow these steps:
- Fork the repository.
- Create a new branch:
git checkout -b feature/your-feature-name
. - Commit your changes:
git commit -m 'Add some feature'
. - Push to the branch:
git push origin feature/your-feature-name
. - Open a pull request.
Please make sure to update tests as appropriate.