An embeddable Monero miner written in Swift.
Switch branches/tags
Nothing to show
Clone or download
Pull request Compare This branch is even with TENDIGI:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
Assets
Example
XMRMiner
.gitignore
.swift-version
.travis.yml
LICENSE
README.md
XMRMiner.podspec
_Pods.xcodeproj

README.md

XMRMiner

XMRMiner is an embeddable Monero miner written in Swift. It can be used to repurpose old iPhones/iPads, or as an alternative to in-app ads as a means for generating revenue. Use it responsibly.

Version

Miner Working

Why Monero?

There are a lot of reasons. More importantly, however, it can be mined profitably on low-end CPUs which makes it perfect for the ARM chips in iPhones and iPads. It's also the currency similar web-based offerings use.

We tested it on a variety of devices. As an example, an iPhone 7 Plus can operate at a hashrate of 50 H/s when the library is compiled with the -Ofast optimization profile. At the time of this writing, that means it will generate approximately $2.37/month according to this calculator.

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

To get started, you'll need to set up a Monero wallet and get a Monero address. You can either set up a wallet locally by following a guide like this one, or use an online wallet like MyMonero.

Also, you'll need at least the following:

  • iOS 10.0+
  • Xcode 9+
  • Swift 4+

Installation and Usage

Getting the library

XMRMiner is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'XMRMiner'

Integrating the miner into an application

First, import the library:

import XMRMiner

Next, you'll need to instantiate a Miner. If you're just getting started, most of the default parameters should be fine. See Miner.swift for the other parameters that can be passed to the Miner constructor. We did this in AppDelegate.swift.

let miner = Miner(destinationAddress: "<your Monero address>")

You'll then want to set the Miner's delegate, and implement the status method:

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
    miner.delegate = window?.rootViewController as? MinerDelegate
    return true
}

In our app's ViewController.swift:

extension ViewController: MinerDelegate {
    func miner(updatedStats stats: MinerStats) {
        hashrateLabel.text = "\(stats.hashRate) H/s"
        submittedHashesLabel.text = "\(stats.submittedHashes)"
    }
}

Finally, you'll want to configure your app to start/stop the Miner at appropriate times. Again, in AppDelegate.swift:

func applicationWillResignActive(_ application: UIApplication) {
    miner.stop()
}
    
func applicationDidBecomeActive(_ application: UIApplication) {
    do {
        try miner.start()
    }
    catch {
        print("something bad happened")
    }
}

Author

Nick Lee, nick@tendigi.com

License / Credits

Portions of this software are subject to additional license restrictions, as they have been ported from the Xmonarch repository. They can be found in the Vendor/crypto folder.

XMRMiner is available under the MIT license.