2

Is it possible to create global mutable variables in a Solana program? I want to have a global mutable variable that stores some integer, and I'm getting a compilation error when doing so

1 Answer 1

3

Rust typically doesn't use global variables, except for constants, because of its memory management model.

In Solana, variables can't persist between instructions anyways, so a variable that's in scope in an instruction handler is about as global as it gets.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.