I have the contract
use anchor_lang::prelude::*;
declare_id!("kek");
#[constant]
pub const MEDIA_TAG: &[u8] = b"MEDIA_STATE";
#[account]
#[derive(Default)]
pub struct MediaState {
pub authority: Pubkey,
pub name: String,
}
#[program]
pub mod publisher {
use super::*;
pub fn create_media(ctx: Context<CreateMedia>, name: String) -> Result<()> {
msg!("Media name: {}", name);
let media_state = &mut ctx.accounts.media_state;
media_state.authority = ctx.accounts.authority.key();
media_state.name = name;
msg!("Media created");
Ok(())
}
}
#[derive(Accounts)]
#[instruction()]
pub struct CreateMedia<'info> {
#[account(mut)]
pub authority: Signer<'info>,
#[account(
init,
seeds = [MEDIA_TAG, authority.key().as_ref()],
bump,
payer = authority,
space = 8 + std::mem::size_of::<MediaState>(),
)]
pub media_state: Box<Account<'info, MediaState>>,
pub system_program: Program<'info, System>,
}
and I`d like to get the MediaState/CreateMedia discriminator in my javascript code
const publisher = new web3.PublicKey(
"kek"
);
const connection = new web3.Connection(web3.clusterApiUrl("devnet"));
const accounts = await connection.getProgramAccounts(publisher, {
filters: [{ memcmp: { offset: 0, bytes: ?????????? } }],
});
I don`t want use anchor in my js code bc i need only the getProgramAccounts
Thanks
filters: [{ memcmp: { offset: 0, bytes: "FtoqZ3bt1he" } }] - it works. But I don`t know how I can get "FtoqZ3bt1he". I stole it from SolanaPlayground (network devtools)