“INVALID-TITLE”的版本间的差异
跳到导航
跳到搜索
| 第2行: | 第2行: | ||
== <div style="background:#19a8e1; color:#FFF; padding-top: 10px; height:45px; padding-left:15px "> EXAMPLE </div> == | == <div style="background:#19a8e1; color:#FFF; padding-top: 10px; height:45px; padding-left:15px "> EXAMPLE </div> == | ||
=== <div style="background:#CC99FF; color:#FFF; padding-top: 10px; height:45px; padding-left:15px "> Loan contract </div> === | === <div style="background:#CC99FF; color:#FFF; padding-top: 10px; height:45px; padding-left:15px "> Loan contract </div> === | ||
| − | Loan contract, refers to a contract where a lender delivers a certain amount of funds to a borrower, and the latter returns the same amount of funds within a certain period of time and pays interests to the lender. There are 6 terms in the contract that consists of two aspects: 1) the borrower shall submit a loan application stating the amount he/she wants to borrow, and 2) the lender may deposit funds into the contract account until the target of loan is reached. Before borrowing, the contract requires that the borrower must confirm the loan information and check the historical loan records, and then calculate the corresponding interests. Meanwhile, the contract asserts that the borrower pays off the loan amount before the loan date comes. | + | Loan contract, refers to a contract where a lender delivers a certain amount of funds to a borrower, and the latter returns the same amount of funds within a certain period of time and pays interests to the lender. There are 6 terms in the contract that consists of two aspects: |
| + | 1) the borrower shall submit a loan application stating the amount he/she wants to borrow, and | ||
| + | 2) the lender may deposit funds into the contract account until the target of loan is reached. Before borrowing, the contract requires that the borrower must confirm the loan information and check the historical loan records, and then calculate the corresponding interests. Meanwhile, the contract asserts that the borrower pays off the loan amount before the loan date comes. | ||
=== <div style="background:#CC99FF; color:#FFF; padding-top: 10px; height:45px; padding-left:15px "> Auction contract </div> === | === <div style="background:#CC99FF; color:#FFF; padding-top: 10px; height:45px; padding-left:15px "> Auction contract </div> === | ||
Auction contract involves two parties: auctioneer who is an enterprise legal person engaged in auction activities, and bidders who are some citizens, legal persons or organizations to participate in bidding for auction targets. The highest bidding process is described as the following steps. The auctioneer starts the auction system after setting a reserve price and an auction end time, and waits for the auction to end; The bidders can bid anytime during the system. If the bid is greater than the current highest price, the system records it as new highest price, puts the bid into the fund pool, and returns the bid paid by the previous highest bidder; otherwise, the bidder fails and the bid is returned; After the auction time is over, the auctioneer can collect the highest bid from the fund pool. | Auction contract involves two parties: auctioneer who is an enterprise legal person engaged in auction activities, and bidders who are some citizens, legal persons or organizations to participate in bidding for auction targets. The highest bidding process is described as the following steps. The auctioneer starts the auction system after setting a reserve price and an auction end time, and waits for the auction to end; The bidders can bid anytime during the system. If the bid is greater than the current highest price, the system records it as new highest price, puts the bid into the fund pool, and returns the bid paid by the previous highest bidder; otherwise, the bidder fails and the bid is returned; After the auction time is over, the auctioneer can collect the highest bid from the fund pool. | ||
=== <div style="background:#CC99FF; color:#FFF; padding-top: 10px; height:45px; padding-left:15px "> House-leasing contract </div> === | === <div style="background:#CC99FF; color:#FFF; padding-top: 10px; height:45px; padding-left:15px "> House-leasing contract </div> === | ||
| − | House-leasing contract, takes assets as the transaction subject between lessor and lessee. There are 7 terms in the contract, including two aspects: 1) the lessor can register the house after depositing the rental deposit, and 2) the lessee can keep the right to use the house during the leasing period after depositing the rent. After confirming the leased house, the contract requires that the lessee shall pay the rent, and the lessor must transfer the right to the lessee within one week. Meanwhile, the contract stipulates the pre-condition for the lessor to charge the rent paid by the lessee, and the postcondition for both parties to get their deposits back after the house inspection. | + | House-leasing contract, takes assets as the transaction subject between lessor and lessee. There are 7 terms in the contract, including two aspects: |
| + | 1) the lessor can register the house after depositing the rental deposit, and | ||
| + | 2) the lessee can keep the right to use the house during the leasing period after depositing the rent. After confirming the leased house, the contract requires that the lessee shall pay the rent, and the lessor must transfer the right to the lessee within one week. Meanwhile, the contract stipulates the pre-condition for the lessor to charge the rent paid by the lessee, and the postcondition for both parties to get their deposits back after the house inspection. | ||
<syntaxhighlight lang="spec" line="1"> | <syntaxhighlight lang="spec" line="1"> | ||
HouseLease.scs | HouseLease.scs | ||
| 第447行: | 第451行: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
=== <div style="background:#CC99FF; color:#FFF; padding-top: 10px; height:45px; padding-left:15px "> Purchase contract </div> === | === <div style="background:#CC99FF; color:#FFF; padding-top: 10px; height:45px; padding-left:15px "> Purchase contract </div> === | ||
| − | Purchase contract, transfers the ownership of goods from a seller to a buyer through logistics company. There are 10 terms in the contract, including three parts: 1) once the goods are confirmed, the seller will sign a contract and take twice the contracting price as the delivery price, 2) the goods are sent to the buyer through logistics when the buyer purchases the goods, and 3) only when the logistics successfully delivers the goods to the buyer can the seller get back the payment. According to relevant laws, the contract requires the buyer can apply for compensation if goods do not arrive within 10 days after payment, or the seller can automatically confirm the arrival if the buyer does not confirm or apply for refund within 7 days after arrival. | + | Purchase contract, transfers the ownership of goods from a seller to a buyer through logistics company. There are 10 terms in the contract, including three parts: |
| + | 1) once the goods are confirmed, the seller will sign a contract and take twice the contracting price as the delivery price, | ||
| + | 2) the goods are sent to the buyer through logistics when the buyer purchases the goods, and 3) only when the logistics successfully delivers the goods to the buyer can the seller get back the payment. According to relevant laws, the contract requires the buyer can apply for compensation if goods do not arrive within 10 days after payment, or the seller can automatically confirm the arrival if the buyer does not confirm or apply for refund within 7 days after arrival. | ||
2021年2月26日 (五) 18:33的版本
EXAMPLE
Loan contract
Loan contract, refers to a contract where a lender delivers a certain amount of funds to a borrower, and the latter returns the same amount of funds within a certain period of time and pays interests to the lender. There are 6 terms in the contract that consists of two aspects: 1) the borrower shall submit a loan application stating the amount he/she wants to borrow, and 2) the lender may deposit funds into the contract account until the target of loan is reached. Before borrowing, the contract requires that the borrower must confirm the loan information and check the historical loan records, and then calculate the corresponding interests. Meanwhile, the contract asserts that the borrower pays off the loan amount before the loan date comes.
Auction contract
Auction contract involves two parties: auctioneer who is an enterprise legal person engaged in auction activities, and bidders who are some citizens, legal persons or organizations to participate in bidding for auction targets. The highest bidding process is described as the following steps. The auctioneer starts the auction system after setting a reserve price and an auction end time, and waits for the auction to end; The bidders can bid anytime during the system. If the bid is greater than the current highest price, the system records it as new highest price, puts the bid into the fund pool, and returns the bid paid by the previous highest bidder; otherwise, the bidder fails and the bid is returned; After the auction time is over, the auctioneer can collect the highest bid from the fund pool.
House-leasing contract
House-leasing contract, takes assets as the transaction subject between lessor and lessee. There are 7 terms in the contract, including two aspects: 1) the lessor can register the house after depositing the rental deposit, and 2) the lessee can keep the right to use the house during the leasing period after depositing the rent. After confirming the leased house, the contract requires that the lessee shall pay the rent, and the lessor must transfer the right to the lessee within one week. Meanwhile, the contract stipulates the pre-condition for the lessor to charge the rent paid by the lessee, and the postcondition for both parties to get their deposits back after the house inspection.
HouseLease.scs
contract Houselease{
party Renter{
registerHouse()
collectRent()
collectBail()
transferHouse()
checkHouse()
}
party Tenant{
confirmLease(endLeasingDuration:Date,
payDuration:Date)
payRent()
returnHouse()
collectBail()
}
house : House
infos : contractInfo
term term1 : Renter can registerHouse
while deposit $infos::renterBail.
term term2 : Tenant can confirmLease
when after Renter did registerHouse
while deposit $infos::tenantBail
where infos::startLeasingTime = now and
infos::endLeasingTime = endLeasingDuration + now
and infos::payDate = payDuration + now
and infos::payDuration = payDuration.
term term3 : Renter must transferHouse
when within 7 day after Tenant did confirmLease
while deposit $ house::useRight.
term term4 : Tenant must payRent
when before Tenant did confirmLease
while deposit $infos::rental
withdraw $house::useRight
where infos::payDate = infos::payDate + infos::payDuration
and infos::totalRental = infos::totalRental + infos::rental.
term term5 : Renter can collectRent
while withdraw $infos::totalRental
where infos::totalRental = 0.
term term6 : Tenant must returnHouse
when within 7 day after Renter did checkHouse
while deposit $house::useRight
transfer $house::useRight to Renter.
term term7_1 : Renter can collectBail
when within 15 day after Renter did checkHouse
while withdraw $infos::renterBail.
term term7_2 : Tenant can collectBail
when within 15 day after Renter did checkHouse
while withdraw $infos::tenantBail.
type contractInfo {
renterBail : Money
tenantBail : Money
rental : Money
totalRental : Money
penalty : Money
startLeasingTime : Date
endLeasingTime : Date
payDate : Date
payDuration : Date
}
type House {
ownershipNumber : integer
location : String
area : integer
usage : String
price : Money
useRight : String
usufruct : String
dispositionRight : String
possessionRight : String
}
}
<br>
Houselease.sol
pragma solidity ^0.4.0;
import "./RenterT.sol";
import "./TenantT.sol";
contract Houselease {
RenterT Renter;
TenantT Tenant;
House house;
contractInfo infos;
uint start;
struct contractInfo{
uint renterBail;
uint tenantBail;
uint rental;
uint totalRental;
uint penalty;
uint startLeasingTime;
uint endLeasingTime;
uint payDate;
uint payDuration;
}
struct House{
uint ownershipNumber;
bytes32 location;
uint area;
bytes32 usage;
uint price;
uint useRight;
uint usufruct;
uint dispositionRight;
uint possessionRight;
}
function Houselease(){
start = now;
Renter = new RenterT();
Tenant = new TenantT();
}
modifier onlyRenter{
require(Renter.contains(msg.sender));
_;
}
modifier onlyTenant{
require(Tenant.contains(msg.sender));
_;
}
modifier term2Modifier{
require(now > Renter.registerHouseTime());
require(infos.tenantBail > 0);
_;
}
modifier term3Modifier{
require((now > Tenant.confirmLeaseTime()) &&(now < Tenant.confirmLeaseTime()+604800));
require(house.useRight > 0);
_;
}
modifier term4Modifier{
require(now < Tenant.confirmLeaseTime());
require(infos.rental > 0);
_;
}
modifier term6Modifier{
require((now > Renter.checkHouseTime()) &&(now < Renter.checkHouseTime()+604800));
require(house.useRight > 0);
_;
}
modifier term7_1Modifier{
require((now > Renter.checkHouseTime()) &&(now < Renter.checkHouseTime()+1296000));
_;
}
modifier term7_2Modifier{
require((now > Renter.checkHouseTime()) &&(now < Renter.checkHouseTime()+1296000));
_;
}
function registerHouse() onlyRenter() public payable {
//USER CODE HERE
//CHECK
}
function confirmLease(uint endLeasingDuration, uint payDuration) onlyTenant() term2Modifier() public payable {
//USER CODE HERE
infos.startLeasingTime = now;
infos.endLeasingTime = endLeasingDuration + now;
infos.payDate = payDuration + now;
infos.payDuration = payDuration;
//CHECK
assert(infos.startLeasingTime == now && (infos.endLeasingTime == endLeasingDuration + now && (infos.payDate == payDuration + now && infos.payDuration == payDuration)));
}
function transferHouse() onlyRenter() term3Modifier() public payable {
//USER CODE HERE
//CHECK
}
function payRent() onlyTenant() term4Modifier() public payable {
//USER CODE HERE
infos.payDate = infos.payDate + infos.payDuration;
infos.totalRental = infos.totalRental + infos.rental;
msg.sender.transfer(house.useRight);
//CHECK
assert(infos.payDate == infos.payDate + infos.payDuration && infos.totalRental == infos.totalRental + infos.rental);
}
function collectRent() onlyRenter() term7_1Modifier() public payable {
//USER CODE HERE
infos.totalRental = 0;
msg.sender.transfer(infos.totalRental);
//CHECK
assert(infos.totalRental == 0);
}
function returnHouse() onlyTenant() term6Modifier() public payable {
//USER CODE HERE
address(Renter).transfer(house.useRight);
//CHECK
}
}
<br>
RenterT.sol
pragma solidity ^0.4.22;
contract RenterT{
//attributes of actionregisterHouse
bool _isregisterHouseDone;
uint _registerHouseTime;
//attributes of actioncollectRent
bool _iscollectRentDone;
uint _collectRentTime;
//attributes of actioncollectBail
bool _iscollectBailDone;
uint _collectBailTime;
//attributes of actiontransferHouse
bool _istransferHouseDone;
uint _transferHouseTime;
//attributes of actioncheckHouse
bool _ischeckHouseDone;
uint _checkHouseTime;
uint _max;
bool _isRenterDone;
uint _i;
address[] _RenterAddress;
function RenterT(){
_max = now*1000;
}
function regist(address a) public {
_RenterAddress[_i] = a;
_i++;
}
function getAddress(uint _i) public returns (address a){
return _RenterAddress[_i];
}
function registerHouseDone(address a){
_registerHouseTime = now;
_isRenterDone = true;
}
function registerHouseTime() returns (uint result){
if(_isregisterHouseDone){
return _registerHouseTime;
}
return _max;
}
function collectRentDone(address a){
_collectRentTime = now;
_isRenterDone = true;
}
function collectRentTime() returns (uint result){
if(_iscollectRentDone){
return _collectRentTime;
}
return _max;
}
function collectBailDone(address a){
_collectBailTime = now;
_isRenterDone = true;
}
function collectBailTime() returns (uint result){
if(_iscollectBailDone){
return _collectBailTime;
}
return _max;
}
function transferHouseDone(address a){
_transferHouseTime = now;
_isRenterDone = true;
}
function transferHouseTime() returns (uint result){
if(_istransferHouseDone){
return _transferHouseTime;
}
return _max;
}
function checkHouseDone(address a){
_checkHouseTime = now;
_isRenterDone = true;
}
function checkHouseTime() returns (uint result){
if(_ischeckHouseDone){
return _checkHouseTime;
}
return _max;
}
function contains(address a) returns (bool result) {
for (uint _j = 0; _j < _RenterAddress.length; _j++ ) { //for loop example
if (a == _RenterAddress[_j]){
return true;
}
}
return false;
}
}
<br>
TenantT.sol
pragma solidity ^0.4.22;
contract TenantT{
//attributes of actionconfirmLease
bool _isconfirmLeaseDone;
uint _confirmLeaseTime;
//attributes of actionpayRent
bool _ispayRentDone;
uint _payRentTime;
//attributes of actionreturnHouse
bool _isreturnHouseDone;
uint _returnHouseTime;
//attributes of actioncollectBail
bool _iscollectBailDone;
uint _collectBailTime;
uint _max;
bool _isTenantDone;
uint _i;
address[] _TenantAddress;
function TenantT(){
_max = now*1000;
}
function regist(address a) public {
_TenantAddress[_i] = a;
_i++;
}
function getAddress(uint _i) public returns (address a){
return _TenantAddress[_i];
}
function confirmLeaseDone(address a){
_confirmLeaseTime = now;
_isTenantDone = true;
}
function confirmLeaseTime() returns (uint result){
if(_isconfirmLeaseDone){
return _confirmLeaseTime;
}
return _max;
}
function payRentDone(address a){
_payRentTime = now;
_isTenantDone = true;
}
function payRentTime() returns (uint result){
if(_ispayRentDone){
return _payRentTime;
}
return _max;
}
function returnHouseDone(address a){
_returnHouseTime = now;
_isTenantDone = true;
}
function returnHouseTime() returns (uint result){
if(_isreturnHouseDone){
return _returnHouseTime;
}
return _max;
}
function collectBailDone(address a){
_collectBailTime = now;
_isTenantDone = true;
}
function collectBailTime() returns (uint result){
if(_iscollectBailDone){
return _collectBailTime;
}
return _max;
}
function contains(address a) returns (bool result) {
for (uint _j = 0; _j < _TenantAddress.length; _j++ ) { //for loop example
if (a == _TenantAddress[_j]){
return true;
}
}
return false;
}
} Purchase contract
Purchase contract, transfers the ownership of goods from a seller to a buyer through logistics company. There are 10 terms in the contract, including three parts: 1) once the goods are confirmed, the seller will sign a contract and take twice the contracting price as the delivery price, 2) the goods are sent to the buyer through logistics when the buyer purchases the goods, and 3) only when the logistics successfully delivers the goods to the buyer can the seller get back the payment. According to relevant laws, the contract requires the buyer can apply for compensation if goods do not arrive within 10 days after payment, or the seller can automatically confirm the arrival if the buyer does not confirm or apply for refund within 7 days after arrival.