| Crates.io | pda-counter |
| lib.rs | pda-counter |
| version | 0.1.1 |
| created_at | 2025-07-29 11:18:05.600548+00 |
| updated_at | 2025-07-29 11:29:17.700164+00 |
| description | A minimal Solana smart contract using Anchor to demonstrate PDA-based counter logic. |
| homepage | https://github.com/Webrowse/pda_counter |
| repository | https://github.com/webrowse/pda_counter |
| max_upload_size | |
| id | 1772226 |
| size | 66,187 |
Version: 0.1.0
License: MIT
This project is a minimal smart contract on the Solana blockchain, built using the Anchor framework. It allows users to create and manage their own on-chain counter using a Program Derived Address (PDA). Each counter is tied to a specific user and supports incrementing, resetting, and automatic closure.
Install dependencies:
yarn install
Build the program:
anchor build
Deploy to devnet (optional):
anchor deploy
Make sure your wallet is funded:
solana airdrop 2
Run the test suite:
anchor test
This will:
Below is a screenshot of the successful test run using anchor test:

pda_counter
├── programs/
│ └── pda_counter/ Rust smart contract
│ └── src/lib.rs
├── tests/
│ └── pda_counter.js JavaScript test suite
├── Anchor.toml Anchor config
├── Cargo.toml Workspace config
├── package.json JS dependencies and scripts
├── LICENSE MIT license
└── README.md This file
initialize: Creates a new counter PDA with the caller as the owner.increment: Increases the counter by one. Only the owner can call this.reset: Resets the counter and closes the account, returning rent to the user.Each user’s counter is stored at a deterministic PDA derived using:
Seed: "counte"
Key: [ "counte", user public key ]
Bump: Automatically computed by Anchor
Note: The seed "counte" (not "counter") was used to avoid PDA conflicts during testing.
This project is licensed under the MIT License. See the LICENSE file for details.
This is a clean example of a complete Solana program using Anchor. It demonstrates:
The project can serve as a learning reference or a base for more advanced Solana applications.
Maintained by Adarsh