Note: Based on some comments from this article I want to be clear: this article is not investment advice. It is possible to produce a profit this way if the Spot price is sufficiently low and Ethers value continues to rise, but this article is primarily a tutorial in AWS CloudFormation, Spot, and crypto-currency.
Get rich quick? Well, possibly, but probably not But mining Ether this way is still interesting and fun! This article gives a tutorial for using AWS CloudFormation and Spot by showing how it can be used to mine Ether. But, before we get into the technical stuff, lets talk a little more about Ether.
Ether is a new, popular crypto-currency similar to Bitcoin. Its popularity is coming from its association with the dominant open-source Blockchain implementation called Ethereum. There has been a lot of commercial interest in the Ethereum project because it adds a concept to Blockchain called Smart Contracts which extend the applications of Blockchain. Ethereum, Blockchain, and Crypto-Currency are all very deep topics in their own right. Its sufficient for our context to say that Blockchain implementations like Ethereum will have a global impact on many, many industries. Even big financial companies like Fidelity have been investing in Bitcoin and Ethereum. If youre interested to learn more check out this great (but almost 30min) video about Blockchain and Crypto-Currency from L2inc.
So, wheres the money come in? Well, as you are probably aware, Bitcoin has become pretty valuable since its introduction in 2009 achieving a market cap of ~$70B USD as of October 2017. Somewhat quietly, Ether has recently crept up to have a market cap about 40% of the size of Bitcoin. All of this means that Ether is now worth real money. Of course, if you just wanted to invest directly in these crypto-currencies you could do that through a currency exchange by trading in your national currency for a digital alternative. For Ether though, you can also acquire it another way
In great oversimplification, the Blockchain implementations of crypto-currencies like Ether require massive mathematical computations to be performed in order to keep them running. Having computers crunch these numbers can be expensive, so in exchange Ether is given to participants who turn in correct solutions. The process of exchanging compute power for crypto-currency is called Mining.
Of course, you could build your own massive computer system to mine Ether, but in the era of Public Cloud, why not just rent one from AWS? Good thinking! And I built a CloudFormation template to do exactly that.
CloudFormation is a service in AWS that allows you to create templates that define the systems you want to deploy as code. This makes it easy to save, replicate, and share the exact configuration of a system. The templates are created in JSON or YAML and are pretty flexible. This template can be used in any of the four US AWS Regions to deploy a Spot Fleet that will automatically mine Ether and deposit the proceeds in your Ethereum wallet.
In order to store cypto-currencies you need a digital wallet. There are lots of ways to create a wallet for Ethereum, but Ill show you one that I think will be accessible to almost everyone. Download the Jaxx Blockchain Wallet from your favorite App Store.
Open up the app and youll have the ability to create wallets for lots of different crypto-currencies. Youll then be given an address for your Ethereum wallet. This address can be public knowledge because its what allows people to send you Ethereum. Copy it down because youll need it later to receive your mining proceeds.
You can get a copy of my CloudFormation Template from this GitHub Repo. There is kind of a lot going on in it, but in a nutshell it creates something in AWS called a Spot Fleet. Using Spot, AWS allows you to bid on unused compute capacity and purchase it for up to 90% less than the standard price.
This CloudFormation Template evaluates all of the compatible AWS Instance Types (all of the instances that have GPUs) and selects the combination that gives you the lowest cost per GPU at that time without going above a price that you specify (Bid Price). If it cant find a combination that is less than your Bid Price then it wont launch any at all. You can even leave it running and when instances are available that meet your Bid Price they automatically start up and run until the price raises above your threshold again.
Graph showing g2.8xlarge instance available for $0.60/hr instead of the normal $2.60/hrprice.
This template exercises some cool features from CloudFormation to select the appropriate instance types, deal with multiple regions, and boot-strap the instances with your provided parameters. If there is interest in a separate article to break down how this template works then let me know in the Responses!
Log into your AWS Account, make sure you are in one of the four US Regions (
N. Virginia, Ohio, N. California or Oregon), and choose the CloudFormation service. Then youll want to create a new New Stack.
A Stack is CloudFormation language for a set of infrastructure specified by a pre-defined Template. Youll want to choose the Upload a template to Amazon S3 option and then choose the CloudFormation Template file you downloaded from my GitHub repo (
Next youll need to provide some Parameters. In CloudFormation, Parameters give you the ability to pass data into the Template to affect how it behaves. For this Template youll need to provide a Stack Name (anything will do), FleetSize, SpotPrice, and your Ethereum Wallet Address (we generated this earlier in Jaxx).
Use these values to specify the number of GPUs you want to deploy for mining and the maximum price per hour youre willing to pay for each one. For context, one GPU would produce Ether at a pretty slow rate. Also, in general, $0.20/GPU/hr is a fairly low price, but not so low that it will be hard to find instances.
The default value for the Wallet address is my Ethereum wallet. Im happy to receive your Ether contributions if you are so inclined, but otherwise you should paste in your Wallet address that you generated earlier in Jaxx.
The last step before hitting the Create button is to check the box acknowledging that this CloudFormation template will create an IAM Role. You can look in the template to see the details, but in a nutshell this is an AWS Security step to give the Spot Fleet you are creating the ability to launch the number of instances you specify in the Parameters section.
Now youll be able to browse to the EC2 Service and look under Spot Requests. Youll see the Spot Fleet that was created and the combination of Instance Types that were chosen based upon availability in your Region and on your FleetSize and SpotPrice parameters.
If no Instances were available that met your SpotPrice parameter youll see that as well. Dont worry if thats the case, just follow Step 6 to delete your CloudFormation Stack and try again with different Parameters.
Crypto-currency mining payout is a very unpredictable process if you mine independently, so the instances in my CloudFormation template participate in a Mining Pool. You can think of a Mining Pool as a co-op of miners. To simplify, being a part of this pool allows you to receive consistent payout for your mining work. The pool these instances join is called nanopool and their website allows you to easily track your mining progress.
Putting in work onnanopool
To see your progress, just head over to
https://eth.nanopool.org and paste your Wallet address in the search bar. This will let you see all of the Instances mining for you, their Hashrate (how fast they are mining) and your current Ether Balance. The pool will pay out Ether to your wallet when your balance reaches
Depending on how many GPUs you specified you may notice that your Spot Fleet wasnt able to expand to its full capacity due to EC2 Instance Type Limits.
AWS does its customers a big favor by implementing limits to the number of instances that can be deployed per Region and by Instance Type. This is to prevent new users from accidentally provisioning a huge number of expensive Instances and digging themselves into an accidental financial hole.
Increasing these limits is pretty easy if you decide they are constraining your mining armada. Just head over to the EC2 Service, click on the Limits link on the sidebar, and Request limit increases for the specific Instance Types you want to be able to provision more of.
Once youve made yourself rich enough youll want to turn off your Spot Fleet. Please, do yourself a favor and do not try to individually delete all of the EC2 Instances, the Role, and the Security Group that the CloudFormation Template created. There is a much easier way. Just delete the Stack using CloudFormation. It will automatically delete all of the resources that were created for you.
Please enjoy this interesting journey into Crypto-Currency, AWS, Spot, and CloudFormation. Again, a lot can be gained by studying the CloudFormation Template and learning how it works, so I definitely encourage you to do that if you have the interest!