<p>I think this question is based on a false premise. The lightning network is not a platform for <em>building</em> novel smart contracts. It is a payment network built <em>on top of</em> the smart contract functionality that Bitcoin's blockchain offers.</p>
<p>It may be possible to design a bespoke system that offers the functionality you seek, but it'll likely require its own off-chain communication to negotiate the transactions.</p>

CC BY-SA 4.0
2023-10-24T16:32:49.790Z
Thank you for the clarifications. I mistakenly assumed it would be possible to deploy contracts to the lightning network. Based on [this](https://www.investopedia.com/terms/h/hashed-timelock-contract.asp#citation-5) article, and your answer, I understand that any smart contracts that may be used by the Lightning Network, (such as the Discreet Log Contracts and Hashed Timelock Contracts), are deployed to the Bitcoin blockchain (instead of the Lightning Network). I have updated my question accordingly.
a.t.
CC BY-SA 4.0
2023-10-23T14:27:36.297Z
2023-10-23T14:27:36.297Z
Pieter Wuille
<h2>XY-problem</h2>
<p>To improve the transparency and payout automation of funds that are raised for a small SAAS project, I would like to enable (micro)-investors to invest with bitcoin whilst providing a transparent &amp; automated payout-mechanism/contract. The SAAS revenue that is received from users paying for the product, is then automatically partially distributed back to the investors. The users are not investors, and pay to a different wallet address.</p>
<p>Note this has little to do with trust, as the developer still needs to be trusted to not switch the SAAS revenue wallet address for new customers after receiving investments. It is mainly for transparency and automation purposes.</p>
<h2>Question</h2>
<p><em>Is it possible to set up a Bitcoin contract that enables lightning wallets to act according to the following behaviour?</em>:</p>
<ul>
<li>Person <code>A</code> creates a wallet with wallet nr <code>A_WALLET_NR</code></li>
<li>Person <code>A</code> creates a wallet with wallet nr <code>INVEST</code></li>
<li>Person <code>A</code> creates a wallet with wallet nr <code>REVENUE</code></li>
</ul>
<p>Person <code>B</code> with wallet nr <code>B_WALLET_NR</code> inputs 1000 Satoshi into <code>INVEST</code>.</p>
<pre><code>For all other persons `C` adding 50 Satoshi into Wallet `REVENUE`:
    Until (`B_WALLET_NR` has retrieved 2x1000 Satoshi from REVENUE):
       - wallet `B_WALLET_NR` gets half of REVENUE income automatically. 
       - wallet `A_WALLET_NR` get half of REVENUE income automatically.
    After (`B_WALLET_NR` has received 2x1000 Satoshi from REVENUE):
       - wallet `A_wallet_NR` gets all income.
</code></pre>
<p>Where:</p>
<ul>
<li>The revenues are split, with multiple investors (that have not yet been payed off 2x their investment) according to key: <code>1/(nr_of_investors+1)</code></li>
<li>A minimum investment amount into <code>INVEST</code> is set of 999 Satoshis (to prevent a single investor with multiple wallets from flooding the distribution key).</li>
</ul>
<h2>Related Contracts</h2>
<p><a href="https://bitcoinmagazine.com/technical/dlcs-on-lightning-and-bitcoin-smart-contracts" rel="nofollow noreferrer">This article</a> describes payout schematics based on (oracle/external) data in <a href="https://dci.mit.edu/smart-contracts" rel="nofollow noreferrer">discrete log contracts</a>. However, in this question there is no need to receive data from outside the chain, as all the data/wallets are already on the lightning network.</p>

<lightning-network><smartcontracts>
Bitcoin smart contract for wallet income distribution based on specific conditions?
a.t.
# Bitcoin smart contract for wallet income distribution based on specific conditions?

(Asked by: username_0 on 2023-09-27)

## XY-problem

To improve the transparency and payout automation of funds that are raised for a small SAAS project, I would like to enable (micro)-investors to invest with bitcoin whilst providing a transparent & automated payout-mechanism/contract. The SAAS revenue that is received from users paying for the product, is then automatically partially distributed back to the investors. The users are not investors, and pay to a different wallet address.

Note this has little to do with trust, as the developer still needs to be trusted to not switch the SAAS revenue wallet address for new customers after receiving investments. It is mainly for transparency and automation purposes.

## Question

*Is it possible to set up a Bitcoin contract that enables lightning wallets to act according to the following behaviour?*:

* Person `A` creates a wallet with wallet nr `A_WALLET_NR`
* Person `A` creates a wallet with wallet nr `INVEST`
* Person `A` creates a wallet with wallet nr `REVENUE`

Person `B` with wallet nr `B_WALLET_NR` inputs 1000 Satoshi into `INVEST`.

```
For all other persons `C` adding 50 Satoshi into Wallet `REVENUE`:
    Until (`B_WALLET_NR` has retrieved 2x1000 Satoshi from REVENUE):
       - wallet `B_WALLET_NR` gets half of REVENUE income automatically. 
       - wallet `A_WALLET_NR` get half of REVENUE income automatically.
    After (`B_WALLET_NR` has received 2x1000 Satoshi from REVENUE):
       - wallet `A_wallet_NR` gets all income.

```

Where:

* The revenues are split, with multiple investors (that have not yet been payed off 2x their investment) according to key: `1/(nr_of_investors+1)`
* A minimum investment amount into `INVEST` is set of 999 Satoshis (to prevent a single investor with multiple wallets from flooding the distribution key).

## Related Contracts

[This article](https://bitcoinmagazine.com/technical/dlcs-on-lightning-and-bitcoin-smart-contracts) describes payout schematics based on (oracle/external) data in [discrete log contracts](https://dci.mit.edu/smart-contracts). However, in this question there is no need to receive data from outside the chain, as all the data/wallets are already on the lightning network.

**Tags:** lightning-network, smartcontracts


---

## 1 answers

### Answer by username_1 on 2023-10-23. Score: 2

I think this question is based on a false premise. The lightning network is not a platform for *building* novel smart contracts. It is a payment network built *on top of* the smart contract functionality that Bitcoin's blockchain offers.

It may be possible to design a bespoke system that offers the functionality you seek, but it'll likely require its own off-chain communication to negotiate the transactions.

> **Comments:**
> **username_0**: Thank you for the clarifications. I mistakenly assumed it would be possible to deploy contracts to the lightning network. Based on [this](https://www.investopedia.com/terms/h/hashed-timelock-contract.asp#citation-5) article, and your answer, I understand that any smart contracts that may be used by the Lightning Network, (such as the Discreet Log Contracts and Hashed Timelock Contracts), are deployed to the Bitcoin blockchain (instead of the Lightning Network). I have updated my question accordingly.  

---

