Giter Club home page Giter Club logo

siwe_flutter's Introduction

siwe_flutter

SIWE Flutter is a Flutter plugin that enables Sign-In with Ethereum, allowing users to use their Ethereum accounts to access web services.

Overview

Today’s login experiences often rely on accounts controlled by centralized identity providers, such as Google, Facebook, and Apple. SIWE aims to provide an alternative by leveraging Ethereum accounts for authentication, offering users greater control over their digital identities.

The Ethereum ecosystem already has tens of millions of monthly active wallet users, making it an excellent foundation for secure authentication across various services.

Benefits

For Web2

  • Empowers users with control over their identifiers.
  • Introduces dedicated user bases to Web3.
  • Provides a strict specification for seamless integration.

For Web3

  • Standardizes the sign-in workflow for improved interoperability.
  • Enhances UX by offering a reliable method for wallet vendors to identify sign-in requests.

Getting Started

1. Installation

Add the following dependency to your pubspec.yaml file:

dependencies:
  siwe_flutter: ^1.0.0

2. Generating Message

import 'package:flutter/material.dart';
import 'package:siwe_flutter/siwe.dart';

// ... (your app code)

// Step 1: Replace these values with your actual data
String walletAddress = '0xYourWalletAddress';
String nonce = '123456'; // Replace with a valid nonce

// ### Generating a Version 1 Message ###
// Step 2: Generate message for version 1
var messageV1 = SiweFlutter(
  domain: 'example.com',
  statement: 'Sign in with your Ethereum account',
  version: '1',
  uri: 'example-uri',
  chainId: '1',
).createMessage(walletAddress: walletAddress, nonce: nonce);

// Print or use the generated message for version 1
print('Message for Version 1: ${messageV1.message}');

// ### Generating a Version 2 Message ###
// Step 3: Generate message for version 2
var messageV2 = SiweFlutter(
  domain: 'example.com',
  statement: 'Sign in with your Ethereum account',
  version: '1',
  uri: 'example-uri',
  chainId: '1',
).createMessageV2(
  walletAddress: walletAddress,
  nonce: nonce,
  expirationTime: '1639459200', // Replace with a valid expiration time
  notBefore: '1639459200', // Replace with a valid notBefore value
  requestId: '123', // Replace with a valid requestId
  resources: ['resource1', 'resource2'], // Replace with valid resources
);

// Print or use the generated message for version 2
print('Message for Version 2: ${messageV2.message}');

Step 3: Send the Message to User's Wallet for Signing

For this step, you would typically send the generated message (messageV2.message) to the user's wallet for them to sign. The actual implementation may vary depending on the wallet and signing method (personal sign or eth sign) you are using. Consult the documentation of the wallet you're integrating with for specific details.

siwe_flutter's People

Contributors

oyen-bright avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.