Rewards

Introduction

The Rewards Custom Consensus (CC) module creates a master-node like rewards program, giving a user the ability to earn rewards by locking coins.

It features configurable parameters, such as a customizable APR, minimum deposit, a required holding period,etc.

There can be many rewards plans active at any given time.

Rewards CC Module Flow

  • Anyone can create a new plan using rewardscreatefunding
  • Anyone can add funding to the plan using rewardsaddfunding
  • Anyone can query the list of all active plans using rewardslist
  • To get the details of a particular plan, use rewardsinfo
  • After finding a suitable plan, any user can lock funds using rewardslock
  • After the minimum lock time is met, the user can use rewardsunlock to unlock their funds and receive their rewards

rewardsaddfunding

rewardsaddfunding name fundingtxid amount

The rewardsaddfunding method adds funds to a rewards plan.

The method returns a hex value which must then be broadcast using the sendrawtransaction method.

Arguments

Name Type Description
name (string) the desired name of your rewards plan
fundingtxid (string) the txid of the transaction that created and funded this contract
amount (number) the amount of funds to add to the contract

Response

Name Type Description
result: (string) whether the command succeeded
hex: (string) a raw transaction in hex-encoded format; you must broadcast this transaction to complete the command

📌 Examples

Step 1: Create a raw transaction and get the HEX value

./komodo-cli -ac_name=HELLOWORLD rewardsaddfunding FREE e020151cd81647b20aa45a0e6850216ae52d3e895443bbe1ae97dea3ae6767bd 100

Step 2: Broadcast raw transaction

./komodo-cli -ac_name=HELLOWORLD sendrawtransaction 0100000001bd6767aea3de97aee1bb4354893e2de56a2150680e5aa40ab24716d81c1520e00200000048473044022050ab254c7498e411ab5360551148405c4afff28d68729e2bd00ba2508ab105d402204067ab95020d606c35d3604d4385dcb97c899a06aa8bf8ce30471fb7868ac7a401ffffffff0300e40b5402000000302ea22c802065686d47a4049c2c845a71895a915eb84c04445896eec5dc0be40df0b31372da8103120c008203000401ccd05eefb1fe080000232103810d28146f60a42090991b044fe630d1664f3f8f46286c61e7420523318047b5ac00000000000000002c6a2ae5414652454500000000bd6767aea3de97aee1bb4354893e2de56a2150680e5aa40ab24716d81c1520e000000000

Step 3: Decode raw transaction (optional to check if the values are sane)

./komodo-cli -ac_name=ATEST decoderawtransaction 0100000001bd6767aea3de97aee1bb4354893e2de56a2150680e5aa40ab24716d81c1520e00200000048473044022050ab254c7498e411ab5360551148405c4afff28d68729e2bd00ba2508ab105d402204067ab95020d606c35d3604d4385dcb97c899a06aa8bf8ce30471fb7868ac7a401ffffffff0300e40b5402000000302ea22c802065686d47a4049c2c845a71895a915eb84c04445896eec5dc0be40df0b31372da8103120c008203000401ccd05eefb1fe080000232103810d28146f60a42090991b044fe630d1664f3f8f46286c61e7420523318047b5ac00000000000000002c6a2ae5414652454500000000bd6767aea3de97aee1bb4354893e2de56a2150680e5aa40ab24716d81c1520e000000000

rewardsaddress

rewardsaddress (pubkey)

The rewardsaddress method returns info about the rewards plan associated with the given pubkey. If no pubkey is provided, the pubkey used to launch the daemon is used.

Arguments

Name Type Description
pubkey (string, optional) the pubkey of the requested info; by default it is the pubkey used to launch the chain

Response

Name Type Description
result (string) whether the method executed successfully
RewardsCCaddress (string) taking the contract's EVAL code as a modifier, this is the public address that corresponds to the contract's privkey
Rewardsmarker (string) the unmodified public address generated from the contract's privkey
GatewaysPubkey (string) the pubkey for the gateways cc
RewardsCCassets (string) this property is used for development purposes only and can otherwise be ignored
CCaddress (string) taking the contract's EVAL code as a modifier, this is the CC address from the pubkey of the user
myCCaddress (string) taking the contract's EVAL code as a modifier, this is the CC address from the pubkey of the user
myaddress (string) the public address of the pubkey used to launch the chain

📌 Examples

Command:

./komodo-cli -ac_name=HELLOWORLD rewardsaddress 03810d28146f60a42090991b044fe630d1664f3f8f46286c61e7420523318047b5

rewardscreatefunding

rewardscreatefunding name amount APR mindays maxdays mindeposit

The rewardscreatefunding method creates a new rewards plan.

The method returns a hex value which must then be broadcast using the sendrawtransaction method.

The sendrawtransaction method will then return a txid. This txid is the fundingtxid that serves to identify the rewards plan.

If you create a plan with mindeposit: 10000, make sure to also add 10000 of your coin and the transaction fees using the rewardsaddfunding call after creating the plan. The rewards contract won't allow locking of funds greater than the amount already locked in a single transaction as it needs to assure that it will have the required funds to pay.

Arguments

Name Type Description
name (string) the desired name of your rewards plan
amount (number) the amount of seed funds to withdraw from your wallet
APR (number) the annual percentage of rewards, given in percentage units
mindays (number) the minimum number of days the funds will be locked
maxdays (number) the maximum number of days the funds will be locked
mindeposit (number) the minimum deposit amount for a user to participate

Response

Name Type Description
result: (string) whether the command succeeded
hex: (string) a raw transaction in hex-encoded format; you must broadcast this transaction to complete the command

📌 Examples

Step 1: Create raw transaction HEX using your own parameter

./komodo-cli -ac_name=HELLOWORLD rewardscreatefunding FREE 1000 5 1 10 10

Step 2: Broadcast/send the raw hex/transaction. This will output the txid which is the fundingtxid, also called the rewards plan id.

./komodo-cli -ac_name=ATEST sendrawtransaction 010000000104f2435046f3ad452e76e53ec01429ae4f49d3322e8cc96da96b9e35d6ada70e0000000049483045022100ebd06f60dea0e1fbfc82fdb1f17ca265c63bae51cd2db558946871513f64453902207d4d39b2418a5206bd7ef4efb9130f93f304577e0c84cc79be4e8abe0c8b22fe01ffffffff0400e8764817000000302ea22c802065686d47a4049c2c845a71895a915eb84c04445896eec5dc0be40df0b31372da8103120c008203000401cc1027000000000000232103da60379d924c2c30ac290d2a86c2ead128cb7bd571f69211cb95356e2dcc5eb9ace069fb0501090000232103810d28146f60a42090991b044fe630d1664f3f8f46286c61e7420523318047b5ac00000000000000002c6a2ae54646524545000000000065cd1d000000008051010000000000002f0d000000000000ca9a3b0000000000000000

Step 3: Decode the raw transaction (optional to check if the values are sane)

./komodo-cli -ac_name=ATEST decoderawtransaction 010000000104f2435046f3ad452e76e53ec01429ae4f49d3322e8cc96da96b9e35d6ada70e0000000049483045022100ebd06f60dea0e1fbfc82fdb1f17ca265c63bae51cd2db558946871513f64453902207d4d39b2418a5206bd7ef4efb9130f93f304577e0c84cc79be4e8abe0c8b22fe01ffffffff0400e8764817000000302ea22c802065686d47a4049c2c845a71895a915eb84c04445896eec5dc0be40df0b31372da8103120c008203000401cc1027000000000000232103da60379d924c2c30ac290d2a86c2ead128cb7bd571f69211cb95356e2dcc5eb9ace069fb0501090000232103810d28146f60a42090991b044fe630d1664f3f8f46286c61e7420523318047b5ac00000000000000002c6a2ae54646524545000000000065cd1d000000008051010000000000002f0d000000000000ca9a3b0000000000000000

rewardsinfo

rewardsinfo fundingtxid

The rewardsinfo method returns information about specific rewards plan.

Use rewardslist to see a list of all available fundingtxid's.

Arguments

Name Type Description
fundingtxid (string) the txid given on the creation of the rewards plan

Response

Name Type Description
name (string) the name of the rewards plan
sbits (number) a 64-bit int binary encoding of the first 8 characters of the name property
APR (number) the annual percentage of rewards, given in percentage units
minseconds (number) the minimum number of seconds the funds will be locked
maxseconds (number) the maximum number of seconds the funds will be locked
mindeposit (number) the minimum deposit amount
funding (number) the total available funds in the rewards plan

📌 Examples

Command:

./komodo-cli -ac_name=HELLOWORLD rewardsinfo e020151cd81647b20aa45a0e6850216ae52d3e895443bbe1ae97dea3ae6767bd

rewardslist

rewardslist

The rewardslist method lists the fundingtxid's of all the rewards contracts available on the asset chain.

Arguments

Name Type Description
(none)

Response

Name Type Description
fundingtxid (string) the txid of the transaction that created and funded the relevant contract

📌 Examples

Command:

./komodo-cli -ac_name=HELLOWORLD rewardslist

rewardslock

rewardslock name fundingtxid amount

The rewardslock method commits your desired amount of funds into the specified rewards plan. They remain locked until the minimum number of seconds/days passes.

The method returns a hex value that must be broadcast using sendrawtransaction.

The sendrawtransaction method will then return a txid, which is later used in the rewardsunlock method. In general, it is best to save this txid in a secure location.

If the final txid is lost, it is possible to find it again. See rewardsunlock for more information.

Arguments

Name Type Description
name (string) the name of the rewards plan
fundingtxid (string) the txid that identifies the desired rewards plan
amount (number) the amount of funds to commit to the plan (must be over the plan's minimum)

Response

Name Type Description
result: (string) whether the command succeeded
hex: (string) a raw transaction in hex-encoded format; you must broadcast this transaction to complete the diceaddfunds command

📌 Examples

Step 1: Create raw transaction

./komodo-cli -ac_name=HELLOWORLD rewardslock FREE e020151cd81647b20aa45a0e6850216ae52d3e895443bbe1ae97dea3ae6767bd 200

Step 2: Broadcast raw transaction

./komodo-cli -ac_name=ATEST sendrawtransaction 010000000180a53d85b02f6f61c5ddf94052c2d46a0161888c029114a9bf8dceeb4ea98c000100000049483045022100cf5581a6729eb0f37d03f0975dd6cfaca79ea08d380dae7df25b2335931bff5d02204feaf188f7f28d90c056a7b2bfa1f8d38fdf242c333470cf1e0cd3534ef1609701ffffffff0400c817a804000000302ea22c802065686d47a4049c2c845a71895a915eb84c04445896eec5dc0be40df0b31372da8103120c008203000401cc1027000000000000232103810d28146f60a42090991b044fe630d1664f3f8f46286c61e7420523318047b5acb048d709fa080000232103810d28146f60a42090991b044fe630d1664f3f8f46286c61e7420523318047b5ac00000000000000002c6a2ae54c4652454500000000bd6767aea3de97aee1bb4354893e2de56a2150680e5aa40ab24716d81c1520e000000000

Step 3: Decode raw transaction (optional to check if the values are sane)

./komodo-cli -ac_name=ATEST decoderawtransaction 010000000180a53d85b02f6f61c5ddf94052c2d46a0161888c029114a9bf8dceeb4ea98c000100000049483045022100cf5581a6729eb0f37d03f0975dd6cfaca79ea08d380dae7df25b2335931bff5d02204feaf188f7f28d90c056a7b2bfa1f8d38fdf242c333470cf1e0cd3534ef1609701ffffffff0400c817a804000000302ea22c802065686d47a4049c2c845a71895a915eb84c04445896eec5dc0be40df0b31372da8103120c008203000401cc1027000000000000232103810d28146f60a42090991b044fe630d1664f3f8f46286c61e7420523318047b5acb048d709fa080000232103810d28146f60a42090991b044fe630d1664f3f8f46286c61e7420523318047b5ac00000000000000002c6a2ae54c4652454500000000bd6767aea3de97aee1bb4354893e2de56a2150680e5aa40ab24716d81c1520e000000000

rewardsunlock

rewardsunlock name fundingtxid (txid)

The rewardsunlock method unlocks your funds from a specific rewards plan after the minimum lock time is met. If txid is not provided, rewardsunlock unlocks all funds in the fundingtxid plan.

The method returns a hex value which must then be broadcast using the sendrawtransaction method to complete the command.

If you attempt to unlock your funds before the minimum period is met, the daemon returns this error:

The method requires the txid that was returned as a result of the original rewardslock method.

If the original txid is lost, it is possible to find it again by either rebroadcasting the original hex (if it is available), or by scanning through available utxos using the getaddressutxos method.

{ "result": "error", "error": "reward 0 is <= the transaction fee" }

An error similar to the one below prints in the console:

APR 5.00000000 minseconds.86400 maxseconds.864000 mindeposit 10.00000000
duration 74628 < minseconds 86400
reward 0 is <= the transaction fee
amount 200.00000000 -> reward 0.00000000

Arguments

Name Type Description
name (string) the name of the rewards plan
fundingtxid (string) the txid that identifies the desired rewards plan
txid (string, optional) the txid that was returned as a result of the original rewardslock command; if txid is not provided, rewardsunlock unlocks all funds in the fundingtxid plan

Response

Name Type Description
result: (string) whether the command succeeded
hex: (string) a raw transaction in hex-encoded format; you must broadcast this transaction to complete the diceaddfunds command

📌 Examples

Step 1: Create raw transaction

./komodo-cli -ac_name=HELLOWORLD rewardsunlock FREE e020151cd81647b20aa45a0e6850216ae52d3e895443bbe1ae97dea3ae6767bd 494c4e8ab19ab73db9fde0454762e50ff3621d9708170083ea9d925918ec0263

Step 2: Broadcast raw transaction

./komodo-cli -ac_name=HELLOWORLD sendrawtransaction 01000000026302ec1859929dea83001708971d62f30fe5624745e0fdb93db79ab18a4e4c49000000007b4c79a276a072a26ba067a565802103da60379d924c2c30ac290d2a86c2ead128cb7bd571f69211cb95356e2dcc5eb98140dd5c7a6e8436748501608056b934a6b6cd54122f9451a1ca76f3d41568cb0e7a08e4d4f9045083425f42a4171e42b2d32f5e331f87d5b45298e006b909c706d2a100af038001e5a10001ffffffff45fc2d61dd7bf709409c3e5b9021ebd6191901a2a43fa7ed2704c03aa0d3a682000000007b4c79a276a072a26ba067a565802103da60379d924c2c30ac290d2a86c2ead128cb7bd571f69211cb95356e2dcc5eb9814011825693143f97dc51d34b47638f314146c20c92b5020673fb7411ab37018c2003870255e17d87d46b7af7d042335579de566ce492fd8c3c4e883253870ba329a100af038001e5a10001ffffffff0349f04c4817000000302ea22c802065686d47a4049c2c845a71895a915eb84c04445896eec5dc0be40df0b31372da8103120c008203000401cca79841a804000000232103810d28146f60a42090991b044fe630d1664f3f8f46286c61e7420523318047b5ac00000000000000002c6a2ae5554652454500000000bd6767aea3de97aee1bb4354893e2de56a2150680e5aa40ab24716d81c1520e000000000

Step 3: Decode raw transaction (optional to check if the values are sane)

./komodo-cli -ac_name=HELLOWORLD decoderawtransaction 01000000026302ec1859929dea83001708971d62f30fe5624745e0fdb93db79ab18a4e4c49000000007b4c79a276a072a26ba067a565802103da60379d924c2c30ac290d2a86c2ead128cb7bd571f69211cb95356e2dcc5eb98140dd5c7a6e8436748501608056b934a6b6cd54122f9451a1ca76f3d41568cb0e7a08e4d4f9045083425f42a4171e42b2d32f5e331f87d5b45298e006b909c706d2a100af038001e5a10001ffffffff45fc2d61dd7bf709409c3e5b9021ebd6191901a2a43fa7ed2704c03aa0d3a682000000007b4c79a276a072a26ba067a565802103da60379d924c2c30ac290d2a86c2ead128cb7bd571f69211cb95356e2dcc5eb9814011825693143f97dc51d34b47638f314146c20c92b5020673fb7411ab37018c2003870255e17d87d46b7af7d042335579de566ce492fd8c3c4e883253870ba329a100af038001e5a10001ffffffff0349f04c4817000000302ea22c802065686d47a4049c2c845a71895a915eb84c04445896eec5dc0be40df0b31372da8103120c008203000401cca79841a804000000232103810d28146f60a42090991b044fe630d1664f3f8f46286c61e7420523318047b5ac00000000000000002c6a2ae5554652454500000000bd6767aea3de97aee1bb4354893e2de56a2150680e5aa40ab24716d81c1520e000000000