dartminer 0.0.11

  • README.md
  • Installing
  • Versions
  • 0

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

Alternatively, your editor might support pub 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
Popularity:
Describes how popular the package is relative to other packages. [more]
0
Health:
Code health derived from static analysis. [more]
0
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
0
Overall:
Weighted score of the above. [more]
0
Learn more about scoring.

The package version is not analyzed, because it does not support Dart 2. Until this is resolved, the package will receive a health and maintenance score of 0.

Issues and suggestions

Fix platform conflicts.

Error(s) prevent platform classification:

Fix dependencies in pubspec.yaml.

Fix dependencies in pubspec.yaml.

Running pub upgrade failed with the following output:

ERR: The current Dart SDK version is 2.0.0.
 
 Because dartminer depends on unittest >=0.2.8+2 which requires SDK version <2.0.0, version solving failed.

Package is too old.

The package was released more than two years ago.

Maintain CHANGELOG.md.

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

Add SDK constraint in pubspec.yaml.

For information about setting SDK constraint, please see https://www.dartlang.org/tools/pub/pubspec#sdk-constraints.

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-v0.1 release.

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

Format lib/src/bitcoin.dart.

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

Format lib/src/block.dart.

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

Format lib/src/coinbase.dart.

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

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.

Fix additional 6 files with analysis or formatting issues.

Additional issues in the following files:

  • lib/src/doublesha256.dart (Run dartfmt to format lib/src/doublesha256.dart.)
  • lib/src/miner.dart (Run dartfmt to format lib/src/miner.dart.)
  • lib/src/sha256.dart (Run dartfmt to format lib/src/sha256.dart.)
  • lib/src/template.dart (Run dartfmt to format lib/src/template.dart.)
  • lib/src/util.dart (Run dartfmt to format lib/src/util.dart.)
  • lib/src/work.dart (Run dartfmt to format lib/src/work.dart.)