Smart contract example: Stateless contract for loan matching
A stateless contract can be used to implement basic lending platform functionality.
- UTXO A
- Address B
- Loan request
- Loan pledge
- Signature from A
- Signature from B
The contract first checks if the loan request matches the loan pledge, the signatures are valid, and UTXO A has sufficient funds to cover the loan. If all conditions are met, then it (1) pays from address A to address B (2) transfers a 1% fee to the operator, and (3) issues the debt token from B to A.
The transactions that are issued are distinct from normal transactions, as the final transaction is “issued” by the smart contract itself. Verifying one of these transactions requires checking the result of the contract program. The final transaction includes the contract inputs, the contract output, and references the smart contract program, which is a content addressable data object that can be looked up on the ledger. Since there is no intermediate state, only the final contract-issued transactions need to get logged in the UTXO set. The verification just checks the inputs, runs the program, and checks the validity of the outputs.