Giter VIP home page Giter VIP logo

flutter_ethers's Introduction

Flutter_Ethers For Flutter

Fluter_Ethers is a dart library that connects to interact with the Ethereum blockchain and inspired by ethers.js and ethers.

Installing

Add Flutter_Ethers to your pubspec.yaml file:

dependencies:
  flutter_ethers:

Import Flutter_Ethers in files that it will be used:

import 'package:flutter_ethers/flutter_ethers.dart';

Usage

Provider

const provider = ethers.providers.JsonRpcProvider();

// Look up the current block number
await provider.getBlockNumber();
// Output: 14135476

// Get the balance of an account (by address or ENS name, if supported by network)
final balance = await provider.getBalance("0x0000000000000000000000000000000000000000");
// Output: { BigInt: "10478645750785322678769" }

// Often you need to format the output to something more user-friendly,
// such as in ether (instead of wei)
print(ethers.utils.formatEther(balance));
// Output: '10478.645750785321'

// If a user enters a string in an input field, you may need
// to convert it from ether (as a string) to wei (as a BigNumber)
print(ethers.utils.parseEther("1.0"));
// Output: { BigInt: "1000000000000000000" }

Wallet

// Create a wallet instance from a mnemonic...
final mnemonic = "announce room limb pattern dry unit scale effort smooth jazz weasel alcohol";
final walletMnemonic = Wallet.fromMnemonic(mnemonic);

// ...or from a private key
final walletPrivateKey = Wallet(walletMnemonic.privateKey);

print(walletMnemonic.address == walletPrivateKey.address);
// Output: true

// The address as a Promise per the Signer API
print(walletMnemonic.getAddress());
// Output: '0x71CB05EE1b1F506fF321Da3dac38f25c0c9ce6E1'

// The address as a property
print(walletMnemonic.address);
// Output: '0x71CB05EE1b1F506fF321Da3dac38f25c0c9ce6E1'

// The internal cryptographic components
print(walletMnemonic.privateKey);
// Output: '0x1da6847600b0ee25e9ad9a52abbd786dd2502fa4005dd5af9310b7cc7a3b25db'
print(walletMnemonic.publicKey);
// Output: '0x04b9e72dfd423bcf95b3801ac93f4392be5ff22143f9980eb78b3a860c4843bfd04829ae61cdba4b3b1978ac5fc64f5cc2f4350e35a108a9c9a92a81200a60cd64'

// The wallet mnemonic
print(walletMnemonic.mnemonic);
// Output: {
//   locale: 'en',
//   path: "m/44'/60'/0'/0/0",
//   phrase: 'announce room limb pattern dry unit scale effort smooth jazz weasel alcohol'
// }

// Note: A wallet created with a private key does not
//       have a mnemonic (the derivation prevents it)
print(walletPrivateKey.mnemonic);
// Output: null

flutter_ethers's People

Contributors

hydratechnologies-ops avatar renovate[bot] avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Forkers

nerverwind

flutter_ethers's Issues

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

github-actions
.github/workflows/dart.yml
  • actions/checkout v3
  • dart-lang/setup-dart e2fce1213c49504e0029ade4bac39403dfc11fb3
pub
pubspec.yaml
  • flutter
  • web3dart ^2.4.1
  • ens_dart ^1.0.0
  • provider ^6.0.4
  • bip39 ^1.0.6
  • decimal ^3.0.1
  • bip32 ^2.0.0
  • convert ^3.1.1
  • pointycastle ^3.6.2
  • http ^0.13.6
  • lints ^4.0.0
  • test ^1.16.0
  • dart >=3.4.3 <4.0.0

  • Check this box to trigger a request for Renovate to run again on this repository

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.