2

I want to fetch data from the anchor program in my flutter mobile app. Since the Anchor library is written in typescript is it possible to use it with Dart Flutter.

2 Answers 2

2

You can fetch data from the Solana network using Solana's JSON RPC API.

https://docs.solana.com/developing/clients/jsonrpc-api

You can get balances, account info, etc...

But you need to parse data accounts manually, e.g. parsing from buffer to JSON or class. This will require you to interpret the binary data yourself and read and interpret it accordingly.

1

I few months ago I was on a situation like this, we tried to use the Solana web3 sdk but there is no way to use it without porting it Flutter.

Flutter and Typescript are not compatible AFAIK, in fact js interoperability is an experimental feature right now and not available for mobile, so looks like there is no way to use anchor or any ts library without porting it to Flutter.

2
  • Or you could leverage the base library and build your own anchor flutter library with it. github.com/cryptoplease/cryptoplease-dart
    – Pratik.js
    Aug 2, 2022 at 7:21
  • Yeah but at the end you have to face the same thing with all libs, serum, saber or whatever lib out there. In our case, we didn't want that but it's awesome to see ppl working on Dart implementations to onboard Solana developers. Aug 2, 2022 at 18:08

Not the answer you're looking for? Browse other questions tagged or ask your own question.