Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
This guide provides an overview of how mining works, and a step-by-step of how to mine on the Filecoin network.
Table of contents
- What is mining?
- Start mining
- Explore mined blocks
- Create an ask
- Accept a deal and get paid
- Stop mining
What is mining?
In most blockchain protocols, "miners" are the participants on the network that do the work necessary to keep the blockchain valid and secure. For providing these services, miners are compensated in the native cryptocurrency. The term "miner" emerged to compare the work of securing blockchains with that of gold miners who expended resources to expand the supply of gold.
The Filecoin network will have multiple types of miners:
- Storage miners
- Retrieval miners
- Repair miners
In the current implementation, we focus mostly on storage miners. A storage miner sells storage capacity in exchange for filecoin.
init the Filecoin node and run the go-filecoin daemon, you can create a miner. By default, Filecoin nodes are not set up to mine. (See Getting Started for how to initialize a Filecoin node).
Create a miner that pledges 10 sectors (currently 256 MiB each) of storage and 100 FIL as collateral, with a message gas price of 0 FIL/unit and limit of 1000 gas units. When successful, it returns the miner address of the newly created miner.
Note: This step may take about a minute to process, but if it hangs for longer, double-check that
priceis less than
$YOUR_WALLET_BALANCE / LIMIT.
go-filecoin miner create 10 100 --gas-price=0 --gas-limit=1000 --peerid `go-filecoin id | jq -r '.ID'` # this may take a minute
Once the miner is created, we can run the following to start mining:
go-filecoin mining start
Congrats, you are now mining filecoin! For now, you are mining blocks that contain activity on the network. Let's take a detour to explore these blocks. (Or, to begin mining your unused storage, skip directly to Create an ask.)
Explore mined blocks
You can explore the Filecoin blockchain using the Filecoin Block Explorer, or via the command line. For example, let's get the
blockID of the very first block of the blockchain. This is known as the head.
- Show the chain head and copy the a block ID (there may be more than one):
go-filecoin chain head # returns JSON including the <blockID> of the chain head
- Then, view the contents of that block with
go-filecoin show block <blockID>
Many commands also support a
--enc=json option for machine-readable output.
Set your price for storage
In the Filecoin storage market, miners run a command that sets their price for storage by creating an ask order that provide some detail on their available storage space and how much they are charging for storage. Clients propose deals to miners for the files they want to store. Setting a price requires the following values:
- the price at which you are willing to sell that much storage (in FIL/byte/block)
- the number of blocks for which this asking price is valid
- the price to pay for each gas unit consumed mining this message (in FIL)
- the maximum number of gas units to be consumed by this message
Let's set our price!
- We set our price to 0.000000001 FIL/byte/block, valid for 2880 blocks, with a message gas price of 0 FIL/unit and limit of 1000 gas units:
go-filecoin miner set-price --gas-price=0 --gas-limit=1000 0.000000001 2880
- Once you have set your price, you can check
client list-asksto see your ask (look for your miner address):
go-filecoin client list-asks --enc=json | jq
Accept a deal and get paid
Clients propose storage deals to miners who have enough storage and at a price that is lower than their willingness to pay.
A few notes on the current implementation as of Dec 2018:
- Currently, miners accept all deals that are proposed to them by clients with sufficient funds. Payment validation is done automatically so you don't have to take any action to accept a deal.
- Deal payments and payment channels are implemented. Thus, miners are periodically credited funds in a payment channel throughout the lifetime of the deal.
If at any point you want to stop mining, you can always stop:
go-filecoin mining stop
You can also remove all data associated with your Filecoin node instance:
rm -rf ~/.filecoin