Temporary WIP repo for an automated smart ticket purchase (will move to decred when cleaned up)
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.



Build Status

dcrticketbuyer is a smart ticket purchasing bot for the automatic purchase of tickets from a Decred wallet. It uses both the daemon and wallet RPC to collect data on the blockchain and mempool and use that to make decisions about buying tickets.

This project is currently under active development and is in an alpha state.


Go 1.5 or newer.


Linux/BSD/MacOSX/POSIX - Build from Source

  • Install Go according to the installation instructions here: http://golang.org/doc/install

  • Ensure Go was installed properly and is a supported version:

$ go version

NOTE: The GOROOT and GOPATH above must not be the same path. It is recommended that GOPATH is set to a directory in your home directory such as ~/goprojects to avoid write permission issues.

  • Run the following command to obtain dcrticketbuyer, all dependencies, and install it:
$ go get -u -v github.com/cjepson/dcrticketbuyer/...
  • dcrticketbuyer (and utilities) will now be installed in either $GOROOT/bin or $GOPATH/bin depending on your configuration. If you did not already add the bin directory to your system path during Go installation, we recommend you do so now.


Linux/BSD/MacOSX/POSIX - Build from Source

  • Run the following command to update btcd, all dependencies, and install it:
$ go get -u -v github.com/cjepson/dcrticketbuyer/...

Getting Started

dcrticketbuyer has several configuration options avilable to tweak how it runs. The user should read over these options carefully and create a configuration file that specifies exactly the type of behavior they would prefer for ticket purchase. For reference, these options are given below.

  -C, --configfile=         Path to configuration file
  -V, --version             Display version information and exit
      --testnet             Use the test network (default mainnet)
      --simnet              Use the simulation test network (default mainnet)
  -d, --debuglevel=         Logging level {trace, debug, info, warn, error,
                            critical} (info)
      --logdir=             Directory to log output
      --dcrduser=           Daemon RPC user name
      --dcrdpass=           Daemon RPC password
      --dcrdserv=           Hostname/IP and port of dcrd RPC server to connect to
                            (default localhost:9109, testnet: localhost:19109,
                            simnet: localhost:18556)
      --dcrdcert=           File containing the dcrd certificate file
      --dcrwuser=           Wallet RPC user name
      --dcrwpass=           Wallet RPC password
      --dcrwserv=           Hostname/IP and port of dcrwallet RPC server to connect
                            to (default localhost:9110, testnet: localhost:19110,
                            simnet: localhost:18557)
      --dcrwcert=           File containing the dcrwallet certificate file
      --noclienttls         Disable TLS for the RPC client -- NOTE: This is only
                            allowed if the RPC client is connecting to localhost
      --accountname=        Name of the account to buy tickets from (default:
                            default) (default)
      --ticketaddress=      Address to give ticket voting rights to
      --pooladdress=        Address to give pool fees rights to
      --poolfees=           The pool fee base rate for a given pool as a percentage
                            (0.01 to 100.00%)
      --maxpriceabsolute=   The absolute maximum price to pay for a ticket
                            (default: 100.0 Coin) (100)
      --maxpricescale=      Attempt to prevent the stake difficulty from going
                            above this multiplier (>1.0) by manipulation (default:
                            2.0, 0.0 to disable) (2)
      --minpricescale=      Attempt to prevent the stake difficulty from going
                            below this multiplier (<1.0) by manipulation (default:
                            0.7, 0.0 to disable) (0.7)
      --pricetarget=        A target to try to seek setting the stake price to
                            rather than meeting the average price (default: 0.0,
                            0.0 to disable)
      --maxfee=             Maximum ticket fee per KB (default: 1.0 Coin/KB) (1)
      --minfee=             Minimum ticket fee per KB (default: 0.01 Coin/KB) (0.01)
      --feesource=          The fee source to use for ticket fee per KB (median or
                            mean, default: mean) (mean)
      --txfee=              Default regular tx fee per KB, for consolidations
                            (default: 0.01 Coin/KB) (0.01)
      --maxperblock=        Maximum tickets per block, with negative numbers 
                            indicating buy one ticket every 1-in-n blocks (default: 
      --balancetomaintain=  Balance to try to maintain in the wallet
      --highpricepenalty=   The exponential penalty to apply to the number of
                            tickets to purchase above the mean ticket pool price
                            (default: 1.3) (1.3)
      --blockstoavg=        Number of blocks to average for fees calculation
                            (default: 11) (11)
      --feetargetscaling=   The amount above the mean fee in the previous blocks to
                            purchase tickets with, proportional e.g. 1.05 = 105%
                            (default: 1.05) (1.05)
      --dontwaitfortickets  Don't wait until your last round of tickets have
                            entered the blockchain to attempt to purchase more
      --maxinmempool=       The maximum number of tickets allowed in mempool before
                            purchasing more tickets (default: 0)
      --expirydelta=        Number of blocks in the future before the ticket expires
                            (default: 16) (16)


It is recommended to use a configuration file to fine tune the software. A sample configuration file is give below, with explanations about what the software will do.

# Enable testnet.

# Purchase at most 5 tickets per block.

# Stop buying tickets if the mempool has more than 
# 40 tickets in in.

# Never spend more than 100.0 DCR on a ticket.

# Do not purchase tickets if it will move the difficulty 
# above this multiplier for the 'ideal' ticket price. 
# e.g. if the ideal ticket price is 15.0 DCR, the program 
# will prevent purchasing tickets if it drives the next 
# stake difficulty above 30.0 DCR.
# The 'ideal' ticket price is calculated with every new 
# block as (VWAP + ticketPoolAvgValue)/2.

# Force the wallet to purchase tickets if the price 
# is estimated to fall below this proportional amount 
# of the 'ideal' ticket price. This prevents the stake 
# difficulty from falling too low.
# e.g. if the ideal ticket price is 15.0 DCR, the program 
# will force the purchasing tickets if it detects that 
# the next stake difficulty will be below 10.5 DCR.

# The wallet normally targets the purchase of tickets 
# to meet the average price of the market. A wallet 
# with a large amount of DCR may wish to push the 
# price of tickets higher. e.g. if the current 
# average price of a ticket is 15 DCR, the user may 
# think that tickets are too cheap and wants to 
# move the average to 18 DCR. The user would then 
# set this value to 18 DCR.
# A value of 0.0 disables this feature, and it is 
# recommended to be left disabled unless you think 
# you have enough DCR to be able to strongly move 
# the average price.

# The maximum allowable fee in a competitive market 
# for tickets is 1.00 DCR/KB.

# The minimum allowable fee in a competitive market 
# for tickets is 0.01 DCR/KB.

# Use the mean of block or difficulty window periods 
# to determine the fees to use in your tickets.
# Alternatively the median may be used with 'median'.

# The proportion to use above the mean/median for 
# your tickets. e.g. If the network mean for the 
# last 11 blocks is 0.10, use 105%*0.10 = 0.105 
# DCR/KB as your ticket fee.

# Try to leave this much coins remaining in the 
# wallet.

# Give ticket voting rights to this address.

# Send 1.23% pool fees to this address.

# Set the transaction fees to 0.00001 DCR/KB.

# All purchased tickets will expire in 16 blocks 
# if they fail to exit the mempool and enter the 
# blockchain.

The program may then be run with

$ dcrtickeybuyer -C ticketbuyer.conf


  • irc.freenode.net
  • channel #decred-dev
  • webchat

Issue Tracker

The integrated github issue tracker is used for this project.


dcrticketbuyer is licensed under the copyfree ISC License.