I'm using Solana PDAs to build a hashmap-like structure, using users' wallet addresses as one of the seeds. The PDA is called MyNodes, and contains some data specific to the user, including accrued rewards.
Now I'm trying to build a referral system. I have a user's MyNodes PDA, and I want to store the address of another user's PDA inside that first PDA. So one user's PDA will point to another user's PDA, its "referrer" or "affiliate". I need that connection in order to handle affiliate rewards properly both for the referrer and for the one that is being referred.
However, when trying to build the account struct with anchor, I'm running into problems.
#[account]
pub struct MyNodes {
xyz: u32,
abc: u32,
etc: u64,
aff_account: Account<MyNodes>,
}
But it's giving my compile errors:
BPF SDK: /Users/bb/solana/bin/sdk/bpf
cargo-build-bpf child: rustup toolchain list -v
cargo-build-bpf child: cargo +bpf build --target bpfel-unknown-unknown --release
warning: profiles for the non root package will be ignored, specify profiles at the workspace root:
package: /Users/bb/app/nodestore/programs/nodeshop/Cargo.toml
workspace: /Users/bb/app/nodestore/Cargo.toml
Compiling nodeshop v0.1.0 (/Users/bb/app/nodestore/programs/nodeshop)
error[E0106]: missing lifetime specifier
--> programs/nodeshop/src/lib.rs:129:26
|
129 | aff_account: Account<MyNodes>,
| ^ expected named lifetime parameter
|
help: consider introducing a named lifetime parameter
|
123 ~ pub struct MyNodes<'a> {
128 | last_unclaimed: u64,
...
error[E0106]: missing lifetime specifier
--> programs/nodeshop/src/lib.rs:129:26
|
129 | aff_account: Account<MyNodes>,
| ^ expected named lifetime parameter
|
help: consider introducing a named lifetime parameter
|
122 ~ #[account]<'a>
123 | pub struct MyNodes {
...
For more information about this error, try `rustc --explain E0106`.
error: could not compile `nodeshop` due to 3 previous errors
None of the compiler suggestions work. Will result in new errors.
How can I properly link PDAs to each other using Anchor?