A simple smart-contract which could be used for something like a crypto Patreon for digital nomads, until something better comes along

Debit Wallet

The wallet is designed to work together with Subscription Wallets, which are used by content creators.

The debit wallet notifies and syncs with subscription wallets. When a new debitObject is added, the content creator is notified, and their subscription wallet is updated. If a subscriber chooses to end their subscription, then the content creator is notified and their subscription wallet is updated.

Debit Wallets can:

Add a newDebitObject()

removeDebitObject()

And have the contentCreatorCanceledDebit() in case the subscriber for example does not pay the subscription

in case the subscriber for example does not pay the subscription sendEther() like a standard wallet

like a standard wallet suicideAndCancelDeposits() to empty the wallet and cancel any ongoing subscriptions, and then close the wallet contract with the selfdestruct OPCODE

SubscriptionDebitFactory

Debit Wallets and Subscription Wallets are created from a Factory contract, which also keeps track of existing debit and subscription wallets, and new debit objects check with the Factory if the addresses they are debiting to is a registered service.

Ethereum has a gas limit per block of around 3 million GAS. It cannot processes transactions which are bigger than that. The Factory therefore cannot store the bytecode of the Debit Wallet and Subscription Wallet. Instead, it stores a hash of the wallets, sha3(transactionBytecode), and the wallet code can be verified using the checkSubscriptionWalletHash() and checkDebitWalletHash() methods.

The Factory stores a list of the wallet contracts it has created,

mapping(address => uint) public subscriptionWalletID;

address[] public subscriptionWallets; mapping(address => uint) public debitWalletID;

address[] public debitWallets;

List of Debit Wallets created by the Factory

and the Debit Wallets and Subscription Wallets can verify other wallets to see if they are registered,

function isSubscriptionWallet(address subscriber)

public

returns (bool success)

{

if(subscriptionWalletID[subscriber] == 0) throw;

return true;

} function isDebitWallet(address subscriber)

public

returns (bool success)

{

if(debitWalletID[subscriber] == 0) throw;

return true;

}

To subscribe(), you need a Debit Wallet created by the same Factory as the Subscription Wallet you are subscribing to.

The subscription wallet keeps track of subscribers, notifies payments with events.

Subscription Wallet

Subscription wallets can

have debit wallets add their subscription to it, using newSubscription()

have debit wallets remove their subscription from it, using cancelSubscription()

cancelSubscriptionManually() in case a subscriber for example does not pay their subscriptions

in case a subscriber for example does not pay their subscriptions notify the content creator when a subscription payment has been received

sendEther() like any other wallet

like any other wallet and suicideAndCancelSubscibers() to empty the wallet and cancel any ongoing subscriptions, and then close the wallet contract with the selfdestruct OPCODE

Scheduling doDebit()

Ethereum does not yet support time-based scheduling. There is a planned upgrade happening late October 2016, when the Alarm Service releases version 0.8, but until then, doDebit() needs to be called manually.

doDebit() is a public function, and can be called by either the subscriber, the content creator, or any other entity.

Can I trust this service

No. Instead, you should audit the contract yourself.