I am using Sol Cerberus to manage the access to my Solana program, but I don't know how can I call my instruction in javascript to test the access using an NFT collection.
For instance this is my Solana program:
use sol_cerberus_macros::rule;
declare_id!("MY_PROGRAM_ID");
#[program]
pub mod sol_cerberus_demo {
use super::*;
#[rule(Stats, View)]
pub fn view_stats(ctx: Context<Add>) -> Result<()> {
instructions::view::view(ctx)
}
}
How can I execute view_stats in my web3 application using an NFT to authenticate the request?
You have a good example in the docs. For instance if you have created the role
"Authorized"and assigned it to your NFT collection address"MY_NFT_COLLECTION_MINT_ADDRESS"in the SC Manager, then you can do something like this:If you don't know in advance NFT addresses, you can easily fetch them following Solana's cookbook example.