dartminer 0.0.11

  • README.md
  • Installing
  • Versions
  • 29

Dartminer - An example bitcoin mining package written in Dart.

This is an example application of how to build a Bitcoin mining application using the Dart language. I also recommend only using this application using the TestNet within Bitcoin so that you do not risk of hitting the live network with sample code.

On my machine, I was able to hit hash rate of about 500kH/s, which turns out to be about a 15x speed improvement on a JavaScript implementation... While this is impressive, here's hoping that the Dash VM improves in performance with future releases.

Usage

Below is the steps necessary to get this to work.

Mining with getwork.

import 'package:dartminer/dartminer.dart';
 
 // Our main entry point.
void main() {  
  
  // Create a bitcoin client with the proper configuration.  
  Bitcoin bitcoin = new Bitcoin({
    "scheme": "http",
    "host": "127.0.0.1",
    "port": 18332,
    "user": "bitcoinrpc",
    "pass": "123123123123"
  });
  
  // Get work from the bitcoind.
  bitcoin.getwork().then((Map<String, String> work) {
    
    // Work.
    print(work);
    
    // Create the miner.
    Miner miner = new Miner.fromJSON(work);
    
    // Mine for gold!
    Map<String, String> result = miner.mine();
    
    // If the result isn't null, then
    if (result != null) {
      print('Gold!');
      print(result);
      bitcoin.getwork(params: [result['data']]);
    }
  });
}

Mining with getblocktemplate

// Import the dartminer package.
import 'package:dartminer/dartminer.dart';

// Our main file
void main() {  
  
  // Create a bitcoin client with the proper configuration.  
  Bitcoin bitcoin = new Bitcoin({
    "scheme": "http",
    "host": "127.0.0.1",
    "port": 18332,
    "user": "bitcoinrpc",
    "pass": "123123123123123"
  });
    
  // Get work from the bitcoind.
  bitcoin.getblocktemplate().then((dynamic tpl) {
    
    // Create the new template.
    Template template = new Template.fromJSON(tpl, address: '1N438cAaGjY9cyZ5J5hgvixkch3hiu6XA1');
    
    // Mine for gold.
    Map<String, String> result = template.mine();
    
    // See if there is a result.
    if (result != null) {
      
      // We found gold!
      print('GOLD!');
      
      // Print the result.
      print(result);
      
      // Submit the block.
      bitcoin.submitblock(params: [result['data']]);
    }
  });
}

Donations Welcome: 1N438cAaGjY9cyZ5J5hgvixkch3hiu6XA1

Enjoy...

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  dartminer: "^0.0.11"

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter packages get

Alternatively, your editor might support pub get or flutter packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


      import 'package:dartminer/dartminer.dart';
  
Version Uploaded Documentation Archive
0.0.11 Mar 12, 2014 Go to the documentation of dartminer 0.0.11 Download dartminer 0.0.11 archive
0.0.9 Mar 11, 2014 Go to the documentation of dartminer 0.0.9 Download dartminer 0.0.9 archive
0.0.8 Mar 11, 2014 Go to the documentation of dartminer 0.0.8 Download dartminer 0.0.8 archive
0.0.7 Mar 5, 2014 Go to the documentation of dartminer 0.0.7 Download dartminer 0.0.7 archive
0.0.6 Mar 4, 2014 Go to the documentation of dartminer 0.0.6 Download dartminer 0.0.6 archive
0.0.5 Feb 14, 2014 Go to the documentation of dartminer 0.0.5 Download dartminer 0.0.5 archive
0.0.4 Feb 13, 2014 Go to the documentation of dartminer 0.0.4 Download dartminer 0.0.4 archive
0.0.3 Jan 31, 2014 Go to the documentation of dartminer 0.0.3 Download dartminer 0.0.3 archive
0.0.2 Jan 31, 2014 Go to the documentation of dartminer 0.0.2 Download dartminer 0.0.2 archive
0.0.1 Jan 31, 2014 Go to the documentation of dartminer 0.0.1 Download dartminer 0.0.1 archive

Analysis

We analyzed this package on May 22, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0-dev.54.0
  • pana: 0.11.1

Scores

Popularity:
Describes how popular the package is relative to other packages. [more]
0 / 100
Health:
Code health derived from static analysis. [more]
97 / 100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
0 / 100
Overall score:
Weighted score of the above. [more]
29
Learn more about scoring.

Platforms

Detected platforms: Flutter, other

Primary library: package:dartminer/dartminer.dart with components: io.

Suggestions

  • Maintain CHANGELOG.md.

    Changelog entries help clients to follow the progress in your code.

  • Fix analysis and formatting issues.

    Analysis or formatting checks reported 1 error 19 hints.

    Strong-mode analysis of lib/src/bitcoin.dart failed with the following error:

    line: 24 col: 7
    The argument type 'String' can't be assigned to the parameter type 'int'.

    Run dartfmt to format lib/src/block.dart.

    Similar analysis of the following files failed:

    • lib/src/coinbase.dart (hint)
    • lib/src/doublesha256.dart (hint)
    • lib/src/miner.dart (hint)
    • lib/src/sha256.dart (hint)
    • lib/src/template.dart (hint)
    • lib/src/util.dart (hint)
    • lib/src/work.dart (hint)
  • The description is too short.

    Add more detail about the package, what it does and what is its target use case. Try to write at least 60 characters.

  • Package is pre-v1 release.

    While there is nothing inherently wrong with versions of 0.*.*, it usually means that the author is still experimenting with the general direction API.

  • Maintain an example.

    None of the files in your example/ directory matches a known example patterns. Common file name patterns include: main.dart, example.dart or you could also use dartminer.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
crypto >=0.9.0 <0.9.1 0.9.0 2.0.3
unittest >=0.10.0 <0.10.1 0.10.0 0.12.4+1
utf >=0.9.0 <0.9.1 0.9.0+4
Transitive dependencies
path 1.5.1
stack_trace 0.9.3+2 1.9.2