livepeer / merkle-mine

Token distribution based on providing Merkle proofs of inclusion in genesis state to generate allocation
29 stars 9 forks source link

merkle-mine

Requirements

Node.js >= 8.5.0

Building

git clone https://github.com/livepeer/merkle-mine.git
cd merkle-mine
npm install

Running Client Scripts

In the following sections, it is assumed that the user has access to a file with a list of accounts created from steps 1 and 2 in the MerkleMine token generation algorithm defined in the specification. This file might have been obtained from a hosted source such as IPFS or independently created by following steps 1 and 2 in the MerkleMine token generation algorithm in the specification.

Flags

Note: if Node.js memory limits are an issue the --max-old-space-size=4096 flag can be used to increase the Node.js memory limit from its default to ensure that the current Merkle tree construction implementation can complete (4096 is an arbitrarily set value).

Generating a token allocation

# By default this command will use the Ethereum main network
# Use the --rinkeby flag to use the Rinkeby Ethereum test network
# Use the --dev flag to use a custom development network with an Ethereum client (ganache-cli, Geth, Parity) running with JSON-RPC endpoints at http://localhost:8545
# The --acctFile flag is optional - if a path is not provided, the script will fetch from an IPFS gateway
# The --merkleMine flag is optional when using the Ethereum main network
node client/index.js --generate --acctFile [accounts file] --datadir [data directory] --merkleMine [MerkleMine address] --recipient [recipient address] --caller [caller address]

This script will perform a number of validation checks in accordance with the specification, construct the Merkle proof for the given recipient and then submit a transaction from the given caller to the MerkleMine contract to generate a token allocation for the given recipient using the constructed Merkle proof.

Constructing a Merkle proof for a recipient

# By default this command will use the Ethereum main network
# Use the --rinkeby flag to use the Rinkeby Ethereum test network
# Use the --dev flag to use a custom development network with an Ethereum client (ganache-cli, Geth, Parity) running with JSON-RPC endpoints at http://localhost:8545
# The --acctFile flag is optional - if a path is not provided, the script will fetch from an IPFS gateway
# The --merkleMine flag is optional when using the Ethereum main network
node client/index.js --acctFile [accounts file] --merkleMine [MerkleMine address] --recipient [recipient address]

The script will perform a number of validation checks in accordance with the specification and then output the Merkle proof for the given recipient. The outputted Merkle proof can be used with a tool like MyEtherWallet or MyCrypto to directly submit a token generation transaction to the MerkleMine contract. This might be useful if you want to sign your transaction offline or use a hardware wallet to sign the transaction instead of using a local keystore file. The MerkleMine contract ABI required to submit a transaction to the contract via MyEtherWallet or MyCrypto can be found here.

After Running Client Scripts

After you have generated your token, use the Livepeer Protocol Explorer to participate in the Livepeer network and delegate towards a transcoder.

For more information about participating in the Livepeer network using acquired tokens check out the wiki.

Developing with the MerkleMine Contract

Testing

npm run test

Deploying

# Generate `genesisRoot` and `totalGenesisRecipients`
npm run client/makeRoot.js --acctFile [accounts file]

# Configure `genesisRoot` and `totalGenesisRecipients` in `migrations/migrations.config.js`

# <network-name> can take on the following values
# - `dev`: Use a custom development network with an Ethereum client (ganache-cli, Geth, Parity) running with JSON-RPC endpoints at http://localhost:8545
# - `rinkeby`: Use the Rinkeby Ethereum test network (supported by Infura)
# - `mainnet`: Use the Ethereum main network (supported by Infura)

# Set the environment variable DATA_DIR=<data-directory>
# <data-directory> is the directory in which your local keystore files live
# If using `rinkeby`, set the environment variable RINKEBY_ACCOUNT=<deployment-account>
# If using `mainnet`, set the environment variable MAINNET_ACCOUNT=<deployment-account>
# <deployment-account> is the account you would like to submit the deployment transactions with
# If using `dev`, the local Ethereum client will manage the deployment account
npm run migrate -- --network=<network-name>