Questions tagged [vec]
The vec tag has no usage guidance.
6 questions
1
vote
2
answers
35
views
How to Calculate Space for PDA Accounts with Dynamic Vectors in Solana?
I am working on a NFT staking program. I need to create a PDA account with a structure that includes a dynamic Vec.
Here's the structure:
#[account]
pub struct UserNftStakeAccount {
pub user: ...
1
vote
1
answer
42
views
In solana anchor, how to use max_len macro to define multi-dimensional vector?
I'm using anchor to build solana program.
In account struct, I have multi-dimensional vector.
#[max_len(2,50)]
element: Vec<Vec<MyType>>,
In this case, what is the meaning of (2, 50)?
I ...
1
vote
1
answer
143
views
Nested vector in PDA account not being properly serialized
I am creating a PDA account that stores a string and a vector. Inside this vector, there is another vector. This is the structure of my account:
#[account]
pub struct Monster {
pub seed : ...
2
votes
1
answer
588
views
how to delete an element in a Vector Struct at Rust Anchor
Vec remove method
{
"publicKey": "8bu8S247Z1mcQnkWqNVLrU3L2VwWQ4hg2sEyjK4a9oiG",
"account": {
"adminKey": "BUa8iJi3PzkKDgDreyc4NG3BruYCTqmiRjPg1g8p2jHz&...
5
votes
1
answer
117
views
Getting an IDLError when I try to create a vector of a defined Struct
I currently have defined a Ship struct in my backend code, as well as a Port struct which contains an attribute ships_berthed that is of type Vec.
However, on my frontend (Svelte), when I try to call ...
1
vote
1
answer
48
views
Iterate through Vec data and modify a field
I have the following code. Its a loop of an account's stored Vec that have an address and a number on it structure. Inside the loop, if a vec's address is the payer addres, then I want to substract 1 ...