async function createCounter() {
const provider = getProvider();
if (!provider) {
console.error('Provider is not available');
return;
}
if (!baseAccount || !baseAccount.publicKey) {
console.log('Error: baseAccount or publicKey is missing.');
return;
}
if (!web3.SystemProgram.programId) {
console.log('Error: SystemProgram programId is missing.');
return;
}
// Get the connected Phantom wallet's public key
const connectedPublicKey = provider.wallet.publicKey;
const contract = JSON.stringify(idl);
const instance = JSON.parse(contract);
const program = new Program(instance, idl.metadata.address, provider);
try {
console.log("baseAccount",baseAccount)
console.log(baseAccount.publicKey)
const init = await program.rpc.initialize(1, {
accounts: {
authority: provider.wallet.publicKey,
pool: baseAccount.publicKey,
vault: baseAccount.publicKey,
owner: provider.wallet.publicKey,
poolSigner: connectedPublicKey,
systemProgram: web3.SystemProgram.programId,
},
signers: [baseAccount],
});
console.log('Pool Initialized:', init);
const account = await program.account.myAccount.fetch(baseAccount.publicKey);
console.log('account: ', account);
}
catch (err) {
console.log("Transaction error: ", err);
}
}
Transaction error: Error: unknown signer: 149J5z7P1MLvbUMepVf2DCxESoRPN5cQHFdA7dwCW121
facing this issue while initilize smart contract
Here is my account struct
[derive(Accounts)]
#[instruction(nonce: u8)]
pub struct Initialize<'info> {
/// CHECK
pub authority: UncheckedAccount<'info>,
owner: Signer<'info>,
#[account(
seeds = [
pool.to_account_info().key.as_ref(),
],
bump = nonce,
)]
/// CHECK
pool_signer: UncheckedAccount<'info>,
#[account(mut)]
/// CHECK
pool: Box<Account<'info, Pool>>,
#[account(
mut,
seeds = [
pool.to_account_info().key.as_ref(),
],
bump = nonce,
)]
/// CHECK
vault: AccountInfo<'info>,
system_program: Program<'info, System>,
}