0

Did anybody succeed with building a Flutter App that can communicate with the Cardano Blockchain? I would be happy if I could get some more guidance.

I'm trying to build a cross-platform Dapp, so I do not want to rely on running a full node. So Blockfrost.io comes in handy. Unfortunately there seems to be no official Dart Package.

I've already tried with this blockfrost package but somehow I did not manage to put everything together correctly. Did it work for any of you?

I wanted to reach out before I try to build Flutter-Plugins for Android and iOS using the official Java-/Kotlin-/Swift-SDKs provided by Blockfrost.

2
  • It appears that blockfrost is having a few issues atm. A blockfrost dev commented on my question here cardano.stackexchange.com/questions/6934/….
    – Roofi
    Commented Feb 12, 2022 at 7:07
  • That's not what I'm facing. It's not that I get errors from Blockfrost API. I'm struggling to setup the communication in the first place. I might have to ask that question in a Flutter-specific forum maybe. Anyway I thought maybe someone can help. If not I will update this post and let others know.
    – Dani_Rango
    Commented Feb 12, 2022 at 13:20

2 Answers 2

0

I would check out this package, https://pub.dev/packages/blockfrost. I know this package is being used in at least one place for the Manzano app which can be found here, https://manzano.studio/#/

1
  • This is the correct answer. Use the library. I just struggled with the setup. If others struggle with Flutter/Cardano aswell I'm answering what I've been doing to get things going.
    – Dani_Rango
    Commented Feb 16, 2022 at 22:05
0

I got it working for me, these steps may work for you.

  1. Work through this tutorial from flutter.dev
  2. Afterwards it should be easy for you to change the code. Instead of class Album you want to have class CurrentBackendTime. Instead of the function <Future>Album fetchAlbum() you want to have <Future>CurrentBackendTime fetchCurrentBackendTime() and so on. From the API-Docs for GET /health/clock you can learn how to parse data from JSON, which datatypes are required and what data you will get.
  3. Since GET /health/clock requires authentication (see API-Docs again) you need to create an HTTP-Header within your <Future>CurrentBackendTime fetchCurrentBackendTime() function:
    final Map<String, String> authHeader = Map<String, String>();
    authHeader['project_id'] = 'PUT YOUR BLOCKFROST API KEY IN HERE!'
    
    and then you just add the header to your http.get()-Call:
    final response = await http.get(
     Uri.parse('https://cardano-mainnet.blockfrost.io/api/v0/health/clock'),
     headers: authHeader,
    );
    
  4. You could now create more classes like class AccountRewardHistory, class AddressDetails for all the objects you want to GET from blockfrost's API. Or you just use what you've learnt, and apply it when using a library like blockfrost.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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