Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/onemoongate/sss-flutter-sdk
Flutter Web3 Authentication SDK by MoonGate. Authenticate your users using Social & Cross-Chain logins.
https://github.com/onemoongate/sss-flutter-sdk
authentication ethereum siwe solana tezos web3
Last synced: 3 months ago
JSON representation
Flutter Web3 Authentication SDK by MoonGate. Authenticate your users using Social & Cross-Chain logins.
- Host: GitHub
- URL: https://github.com/onemoongate/sss-flutter-sdk
- Owner: onemoongate
- License: gpl-3.0
- Created: 2023-03-06T12:04:05.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-05-10T01:23:07.000Z (over 1 year ago)
- Last Synced: 2024-05-28T13:31:21.652Z (6 months ago)
- Topics: authentication, ethereum, siwe, solana, tezos, web3
- Language: Dart
- Homepage: https://moongate.one
- Size: 614 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Flutter SDK: Ethereum Sign In
This guide will help you integrate the Ethereum sign in functionality into your Flutter app using the MoonGateConfig and MoonGateAuth from the Flutter SDK.
## Prerequisites
1. Make sure you have Flutter and Dart installed and set up.
2. Install the MoonGate Flutter SDK package in your project, you can do so by running
```dart
flutter pub add moongate_flutter_sdk
```## Getting Started
First, you need to set up the API key in your app. You can do this by calling the `MoonGateConfig.setApiKey` function with your API key as an argument.
```dart
import 'package:moongate_flutter_sdk/library.dart';void main() {
MoonGateConfig.setApiKey("YOUR API KEY HERE");
runApp(MyApp());
}
```Replace YOUR API KEY HERE with your actual API key.
## Implementing Ethereum Sign In
To implement Ethereum sign in, you can use the signWithEthereum and moonGateAuth functions provided by the MoonGate Flutter SDK.Create a new function called connectWallet which will handle the sign in process:
```dart
import 'package:moongate_flutter_sdk/library.dart';...
Future connectWallet(BuildContext context) async {
await signWithEthereum(context);
String mnemonic = await moonGateAuth.getMnemonic();
String privatekey = await moonGateAuth.getPrivateKey();
}
```Make sure to pass the BuildContext context as an argument to the connectWallet function. This is required for the WalletConnect modal to show up.
Here's a simple example of how to use the connectWallet function in your app:
```dart
import 'package:moongate_flutter_sdk/library.dart';void main() {
MoonGateConfig.setApiKey("YOUR API KEY HERE");
runApp(MyApp());
}class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(title: Text('Ethereum Sign In Example')),
body: Center(child: SignInButton()),
),
);
}
}class SignInButton extends StatelessWidget {
@override
Widget build(BuildContext context) {
return ElevatedButton(
onPressed: () async {
await connectWallet(context);
},
child: Text('Connect Wallet'),
);
}
}Future connectWallet(BuildContext context) async {
await signWithEthereum(context);
String mnemonic = await moonGateAuth.getMnemonic();
String privatekey = await moonGateAuth.getPrivateKey();
}
```
After the user has successfully signed in with their Ethereum wallet, the mnemonic and privatekey variables will contain the user's mnemonic phrase and private key, respectively. You can use these values to authenticate and perform various actions on behalf of the user within your app.