This is a simple PoC Solana Program that initializes, resizes and updates a PDA Account.
The PDA Account's data contains a message that the client sets and gets (echos).
Install the Solana CLI and dependencies:
curl --proto '=https' --tlsv1.2 -sSfL https://raw.githubusercontent.com/solana-developers/solana-install/main/install.sh | bashAfter installation you should see output similar to the following:
Installed Versions:Rust: rustc 1.84.1 (e71f9a9a9 2025-01-27)Solana CLI:
solana-cli 2.0.26 (src:3dccb3e7; feat:607245837, client:Agave)Anchor CLI:
anchor-cli 0.30.1Node.js: v23.7.0Yarn: 1.22.1Create a solana config:
solana config set --url devnetThis will ensure that you are connected to the devnet and can test your program without spending your valuable SOL.
Generate a keypair:
mkdir -p ~/.config/solana/
solana-keygen new -o ~/.config/solana/id.jsonThis will ensure that your wallet is created and can be used to sign transactions.
Get your wallets public key:
solana-keygen pubkey ~/.config/solana/id.jsonGet some SOL:
solana airdrop 5If that fails, you can use the faucet at https://faucet.solana.com/ (Be sure to
select devnet).
Ensure you're in the root directory of the project's repository.
Build the program:
anchor buildsolana program deploy target/deploy/resizable_pda.soGo to the directory
cd idl-converterBuild the program
cargo build --relaseRun the conversion (the conversion is in-place)
./target/release/idl-converter ../target/idl/resizable_pda.jsonFrom the root directory of the project, go to the app direcotry.
-
Ensure that you have
pyenvinstalled. -
Install Python 3.13
pyenv install 3.13- Install poetry
pip install poetry- Install the dependencies
poetry install --no-root- The program's help:
poetry run ./app.py --helpShould output the following:
Usage: app.py [OPTIONS] MESSAGE
CLI command to create or update a PDA with a given message.
Arguments:
MESSAGE The message to store in the PDA. [required]
Options:
--nonce INTEGER The nonce for PDA derivation (default: 1).
[default: 1]
--install-completion [bash|zsh|fish|powershell|pwsh]
Install completion for the specified shell.
--show-completion [bash|zsh|fish|powershell|pwsh]
Show completion for the specified shell, to
copy it or customize the installation.
--help Show this message and exit.- Run the program with the message "Hello, World!"
poetry run ./app.py "Hello Wolrd!" --nonce 1Note: Be sure to use a different nonce each time you run the program (the
program's resizing function doesn't work yet).
Note: Size changes are made in increments of up to 10 kB.