A Solana program built with Anchor that manages admin data with the ability to extend accounts with additional u128 values.
- Initialize admin data account
- Set admin manually with a list of Pubkeys
- Extend account data with additional u128 values
- Automatic account reallocation for dynamic data storage
- Node.js (v16 or later)
- Yarn
- Rust
- Solana CLI
- Anchor Framework
- Clone the repository:
git clone <repository-url>
cd set_admin- Install dependencies:
yarn install- Build the program:
anchor buildThe program consists of three main instructions:
- Initialize: Creates the admin data account
- Set Admin: Manually sets the list of admin Pubkeys
- Extend Account: Adds additional u128 values to the account data
#[account]
pub struct AdminData {
pub admin: Vec<Pubkey>, // List of admin public keys
// Additional u128 data is stored after the structured data
}import { Program } from "@coral-xyz/anchor";
import { SetAdmin } from "./target/types/set_admin";
// Initialize program
const program = new Program(idl, provider);
// Initialize admin data
await program.methods
.initialize()
.accounts({
adminData: adminDataPda,
user: wallet.publicKey,
programData: programDataAddress,
systemProgram: SystemProgram.programId,
})
.rpc();
// Set admin manually
await program.methods
.setAdminManual([pubkey1, pubkey2, pubkey3])
.accounts({
adminData: adminDataPda,
user: wallet.publicKey,
programData: programDataAddress,
systemProgram: SystemProgram.programId,
})
.rpc();
// Extend account with additional data
await program.methods
.extendAccount([123n, 456n, 789n]) // u128 values as BigInt
.accounts({
adminData: adminDataPda,
user: wallet.publicKey,
programData: programDataAddress,
systemProgram: SystemProgram.programId,
})
.rpc();Run the test suite:
anchor testThe tests cover:
- Program initialization
- Setting admin data
- Extending account data with additional u128 values
- Multiple extend operations
anchor buildanchor deployanchor deploy --provider.cluster devnetset_admin/
├── programs/
│ └── set_admin/
│ └── src/
│ └── lib.rs # Main program logic
├── tests/
│ └── set_admin.spec.ts # Test suite
├── services/
│ └── utils.ts # Client utilities
├── app/
│ └── src/ # Frontend (if applicable)
├── Anchor.toml # Anchor configuration
├── package.json # Node.js dependencies
└── README.md # This file
Creates the initial admin data account.
Sets the admin list to the provided Pubkeys.
Appends additional u128 values to the account data.
admin: Vec<Pubkey>- List of admin public keys- Additional u128 data stored after the structured data
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Ensure all tests pass
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
For questions or issues, please open an issue on the GitHub repository.