Quantcast
Channel: Recent Questions - Solana Stack Exchange
Viewing all articles
Browse latest Browse all 7894

Error: Property 'all' does not exist on type 'ticket' account in Anchor program

$
0
0

I'm working on a Solana program using Anchor ("^0.30.1") and encountered an error while trying to fetch accounts with the all method. I want to retrieve all tickets for a specific lotteryId and filter them by the user's public key. However, I'm receiving the following TypeScript error:

Property 'all' does not exist on type '{ fetch: (address: PublicKey) => Promise<TicketAccount>; }'.ts(2339)

Here’s the relevant part of my code:

if (!wallet?.publicKey) return;const userTickets = await program.account.ticket.all([  {    memcmp: {      bytes: bs58.encode(        new BN(lotteryId).toArrayLike(Buffer, "le", 4)      ),      offset: 12,    },  },  {    memcmp: {      bytes: wallet.publicKey.toBase58(),      offset: 16,    },  },]);

How can I resolve this error? Does the all() method need additional setup, or should I use another approach for filtering accounts? Is there a better way to apply memcmp for on-chain filtering of accounts?

Thanks in advance :)


Viewing all articles
Browse latest Browse all 7894

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>