How to integrate Magic authentication with flutter and have Solana as our blockchain?

149 views Asked by At

I was trying to make a flutter app where I could have authentication done using Magic and then use it with Solana as my blockchain however the issue that I have been facing is the public address that I get from the magic-sdk flutter package is always ethereum one and not Solana one.

final _magic = Magic.instance;
final metadata = await _magic.user.getMetadata();
final publicAddress = metadata.publicAddress;

I even made a custom Magic class and gave the solana rpc url during instantiation.

Magic.instance = Magic.custom(
  MY_API_KEY,
  rpcUrl: "https://api.testnet.solana.com",
  chainId: 1,
);

Still no success. So any help will over this will be highly appreciated!.

1

There are 1 answers

2
Kyano On

You need to specify the extension. This is in JS, but I believe similar logic applies to flutter:

import { Magic } from 'magic-sdk';
import { SolanaExtension } from '@magic-ext/solana';

const magic = new Magic('YOUR_API_KEY', {
  extensions: [
    new SolanaExtension({
      rpcUrl: 'SOLANA_RPC_NODE_URL',
    }),
  ],
});

NOTE: The didToken will always adhere to the Ethereum method, but now the public key will be a Solana public key.