Skip to content

jpchauvel/resizable_pda

Repository files navigation

Small PoC Solana Program and Python anchorpy client

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).

Installation

Solana

Install the Solana CLI and dependencies:

curl --proto '=https' --tlsv1.2 -sSfL https://raw.githubusercontent.com/solana-developers/solana-install/main/install.sh | bash

After 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.1

Create a solana config:

solana config set --url devnet

This 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.json

This 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.json

Get some SOL:

solana airdrop 5

If that fails, you can use the faucet at https://faucet.solana.com/ (Be sure to select devnet).

Deploy the Solana Program (Optional)

Ensure you're in the root directory of the project's repository.

Build the program:

anchor build
solana program deploy target/deploy/resizable_pda.so

Use IDL Converter to Generate the Proper IDL Version (Optional)

Go to the directory

cd idl-converter

Build the program

cargo build --relase

Run the conversion (the conversion is in-place)

./target/release/idl-converter ../target/idl/resizable_pda.json

Testing the Program with anchorpy Client

From the root directory of the project, go to the app direcotry.

Install dependencies

  1. Ensure that you have pyenv installed.

  2. Install Python 3.13

pyenv install 3.13
  1. Install poetry
pip install poetry
  1. Install the dependencies
poetry install --no-root

Run the program

  1. The program's help:
poetry run ./app.py --help

Should 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.
  1. Run the program with the message "Hello, World!"
poetry run ./app.py "Hello Wolrd!" --nonce 1

Note: 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.

About

A small Solana Program (with anchorpy client included) that initializes, resizes and updates an account with a given data (message)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors