I'm getting this error
const key = signer.publicKey.toString();
^
TypeError: Cannot read properties of undefined (reading 'toString')
at Transaction.partialSign (/home/Abhi/xode/sol/testServer/testServer2/node_modules/@solana/web3.js/lib/index.cjs.js:3045:36)
at NodeWallet.signTransaction (/home/Abhi/xode/sol/testServer/testServer2/node_modules/@project-serum/anchor/dist/cjs/nodewallet.js:23:12)
at AnchorProvider.sendAndConfirm (/home/Abhi/xode/sol/testServer/testServer2/node_modules/@project-serum/anchor/dist/cjs/provider.js:83:32)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async MethodsBuilder.rpc [as _rpcFn] (/home/Abhi/xode/sol/testServer/testServer2/node_modules/@project-serum/anchor/dist/cjs/program/namespace/rpc.js:15:24)
at async file:///home/Abhi/xode/sol/testServer/testServer2/app.js:100:20
I'm trying to use this function
const freeze = await program.methods.freezeToken().accounts({
sender : sender,
senderAta : senderAta,
mint : mint,
vaultAccount : vaultAccount,
freezingConfig : freezingConfig,
tokenProgram : tokenProgram,
systemProgram : systemProgram,
rent : rent
}
).signers(walletWrapper.payer).rpc()
For the program account
#[derive(Accounts)]
pub struct FreezeToken<'info> {
///CHECK : Not dangerous
#[account(mut, signer)]
pub sender: AccountInfo<'info>,
#[account(mut)]
pub sender_ata: Account<'info, TokenAccount>,
pub mint: Account<'info, Mint>,
#[account(
init,
seeds =
[
b"vault".as_ref(),
mint.key().as_ref()
],
bump,
payer = sender,
token::mint = mint,
token::authority = sender,
)]
pub vault_account: Account<'info, TokenAccount>,
///CHECK : Not dangerous
#[account(
init,
seeds =
[
b"config".as_ref(),
mint.key().as_ref()
],
bump,
payer = sender,
space = 90
)]
pub freezing_config : Account<'info,FreezingConfig>,
/// CHECK: This is not dangerous because we don't read or write from this account
pub token_program: AccountInfo<'info>,
pub system_program: Program<'info, System>,
pub rent: Sysvar<'info, Rent>,
}
I feel i'm missing some parameters or arguments, but i can't figure it out.
The parameters i use are
const sender = new PublicKey("U4NHM8DNT3kCNrRtB9ymgt1mcR6RBaHwUHWLoxM4KTF");
const senderAta = new PublicKey("2zfkpS8VNWk2t8B2737B6xxFVw8WFNjF3qWXvtQAbgK4");
const mint = new PublicKey("9jcbX9YT6ZzvEsuUrfxcV8Chv3uz7TMmPo4MXXDc5UhV");
const vaultAccount = new PublicKey("9UgS3GBfQVmsEMVje5tniYgYszDs5G7orcw8r71Mdesb");
const freezingConfig = new PublicKey('FK81EDxxU7pPwm5BSs5oFQt5deoRxynuJwu8bnr4nbhf')
const tokenProgram = new PublicKey("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA");
const systemProgram = new PublicKey('11111111111111111111111111111111');
const rent = new PublicKey("SysvarRent111111111111111111111111111111111");
const walletWrapper =new anchor.Wallet(walletKeyPair);