wealthineer-program-metadata

Crates.iowealthineer-program-metadata
lib.rswealthineer-program-metadata
version0.1.0
sourcesrc
created_at2024-12-01 12:59:26.228696
updated_at2024-12-01 12:59:26.228696
descriptionA CLI tool for Solana metadata operations
homepage
repositoryhttps://github.com/solana-developers/idl-program/tree/main/rust_sdk
max_upload_size
id1467426
size257,021
Lukas (a.k.a. Wealthineer) (Wealthineer)

documentation

README

Metadata Rust CLI

This CLI is used to interact with the metadata program.

Usage

program-metadata [SUBCOMMAND]

Commands

IDL Management

# Upload an IDL from local file
program-metadata idl upload <IDL_PATH> <PROGRAM_ID> [OPTIONS]

# Upload an IDL from URL
program-metadata idl upload-url <URL> <PROGRAM_ID> [OPTIONS]

# Download an IDL
program-metadata idl download <PROGRAM_ID> [OUTPUT_PATH]

Options:
  -k, --keypair <PATH>           Path to keypair file (optional, defaults to config)
  -p, --priority-fees <NUMBER>   Priority fees per compute unit (default: 0)
  --help                         Print help information

Metadata Management

# Upload metadata from local file
program-metadata metadata upload <METADATA_PATH> <PROGRAM_ID> [OPTIONS]

# Upload metadata from URL
program-metadata metadata upload-url <URL> <PROGRAM_ID> [OPTIONS]

# Download metadata
program-metadata metadata download <PROGRAM_ID> [OUTPUT_PATH]

Options:
  -k, --keypair <PATH>           Path to keypair file (optional, defaults to config)
  -p, --priority-fees <NUMBER>   Priority fees per compute unit (default: 0)
  --help                         Print help information

Examples:

# Upload IDL using default keypair
program-metadata idl upload ./target/idl/my_program.json GrAkz4CQ4zKm9KhZ9Q7PkCmqDP7JuSGbpwGY8dxKt6Kj

# Upload IDL from URL with custom keypair and priority fees
program-metadata idl upload-url https://example.com/my_idl.json GrAkz4CQ4zKm9KhZ9Q7PkCmqDP7JuSGbpwGY8dxKt6Kj -k ./my-keypair.json -p 1000

# Upload metadata using default keypair
program-metadata metadata upload ./metadata.json GrAkz4CQ4zKm9KhZ9Q7PkCmqDP7JuSGbpwGY8dxKt6Kj

# Download IDL to default path (idl.json)
program-metadata idl download GrAkz4CQ4zKm9KhZ9Q7PkCmqDP7Ju

# Upload metadata from URL
program-metadata metadata upload-url https://example.com/metadata.json GrAkz4CQ4zKm9KhZ9Q7PkCmqDP7JuSGbpwGY8dxKt6Kj

# Download metadata to custom path
program-metadata metadata download GrAkz4CQ4zKm9KhZ9Q7PkCmqDP7JuSGbpwGY8dxKt6Kj ./my-metadata.json

Testing the Rust CLI against a local validator from within this repository

Start your local validator:

solana-test-validator --reset

Make sure you point your cluster to localnet and fix the program id in Anchor.toml. Fix the program id in programs/upload-idl-program/src/lib.rs and rust_cli/src/codama_sdk/programs.rs. Deploy the metadata program using anchor:

anchor build
anchor deploy

Airdrop SOL to your keypair - make sure to point your solana cli to localnet:

solana config set --url localhost
solana airdrop 20 -k tests/wallet.json  

Deploy any program using the keypair in tests/wallet.json:

 solana program deploy <path/to/any-program>.so -k tests/wallet.json

Run the CLI upload for the program you just deployed:

cargo run -- idl upload tests/testidl.json <program-id> -k tests/wallet.json -p 0
Commit count: 0

cargo fmt