Skip to content

Program Outline

Andreas E edited this page Jan 21, 2020 · 1 revision

Proposal for the smart contract to take the following form:

It consists of a single main function which executes whenever the mining facility inputs the electricity costs of the last billing cycle. The function takes as input the electricity costs of the last billing cycle. The function calculates the amount of Ether mined during that last cycle (i.e. the amount mined since the function last ran), and uses the input electricity costs to calculate how much Ether to send to the donation wallet (beneficiary), and sends that quantity of coin to the said wallet. The function then notes down the current date and time in a global variable so that the next time the mining facility inputs the electricity costs and runs the function, it knows when it last ran and consequently from which time period of mining to draw coin from to send to the donation wallet (beneficiary).

Outline

time_of_last_payment - global variable in which the date and time of the last time the mining rewards were split is stored

Split_Mining_Rewards(input: electricity_costs):

  1. calculate the amount of coin mined since time_of_last_payment
  2. use electricity_costs to calculate the amount of coin to transfer
  3. transfer the just calculate amount of coin to the receiving wallet
  4. set time_of_last_payment to the current date and time

the function which runs every time the mining facility declares its electricity costs

The function takes the electricity costs as input, uses that to calculate how much coin to send, and sends that amount of coin to the receiving wallet.

Clone this wiki locally