Skip to content

An Ethereum smart contract to pay out creation value at a constant rate, but the owner can burn the remaining ether at any time.

Notifications You must be signed in to change notification settings

nerdbeard/allowance

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Allowance

A smart contract (`MinimalAllowance`) to pay out to a payee address, at a given rate in wei per second, commencing at a given time. Payouts are triggered by calling `payPayee()`. The owner (ie, creator) of the Allowance can `burn()` it at any time, irrecoverably destroying any remaining ether after first implicitly calling `payPayee()`.

Dev notes

Future ideas and design scribbling. Needs to be cleaned up.

Notes

  • ERC20 allowances? A big problem with MinimalAllowance is that ether is volatile. Tokens allow using a stable/pegged monetary value.

Variations

Minimal Allowance

Pays out over time from contract’s creation value. Does not accept additional funds.

Data and views

  • address owner: can burn the contract
  • address payee: receives payments
  • uint rate: Wei per second the contract pays out

methods

  • MinimalAllowance(payee, rate, commences): should be created with ether value. There is no other way to fund the contract.
  • payPayee(): transfer all currently-owed ether to payee. If this payment reduces contract’s value to zero, selfdestruct the contract.
  • onlyOwner burn(): call payPayee() then selfdestruct, transfering ether to this contract’s address.

Extendable

The contract accepts payment anytime after creation, extending the length of the allowance, perhaps by third parties.

Cashout version

Owner can cashout the contract to the payee at any time. This isn’t in the basic version because a person might wish to create their own allowance contract and solicit people to send funds to it. A use case would be to offer to perform a service for a community. But then the community does not have the option to burn, so this whole idea needs some thought.

methods

  • onlyOwner cashout(): transfer all remaining ether to payee and terminate contract

burnAddress version

Owner can set a burn address at contract creation time. This will receive “burnt” ether, rather than actually destroying it.

Data

  • address burnAddress

methods

  • onlyOwner burn(): call payPayee() then selfdestruct, transfering ether to burnaddress

controlled payout version

Only owner can call payPayee()

Bookmark

The absolute most-simple version of this contract I can see now passes its very basic tests. I’m interested in extending it to more sophisticated versions, as well as providing a UI.

Emacs environment

The configuration for my devlopment environment.

 (progn
   (setenv "PYTHONWARNINGS" "ignore:::cffi.model:532")
   (global-whitespace-mode t)
   (define-key global-map (kbd "C-c c")
     (lambda () "Run unit tests"
	(interactive)
	(compile "cd /home/desktop/eth/allowance/ && populus compile && py.test --disable-warnings")))
   'READY)

About

An Ethereum smart contract to pay out creation value at a constant rate, but the owner can burn the remaining ether at any time.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages