Skip to content
This repository has been archived by the owner on Dec 11, 2021. It is now read-only.

Commit

Permalink
Add ricardian contracts
Browse files Browse the repository at this point in the history
  • Loading branch information
alepacheco committed Jun 29, 2018
1 parent 77987bb commit a9be6ac
Show file tree
Hide file tree
Showing 8 changed files with 117 additions and 3 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.DS_Store
*.wast
*.abi
*.wasm
*.wasm
bin/
4 changes: 2 additions & 2 deletions resource_exchange.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ void resource_exchange::cycle() {
double cost_per_token = calcosttoken();
for (auto acnt = accounts.begin(); acnt != accounts.end(); ++acnt) {
billaccount(acnt->owner, cost_per_token);
matchbandith(*acnt);
matchbandwidth(*acnt);
payreward(acnt->owner, cost_per_token);
}
}
Expand Down Expand Up @@ -313,7 +313,7 @@ void resource_exchange::matchbandwidth(account_t user) {

void resource_exchange::payreward(account_name user, double cost_per_token) {
const double multiplier = cost_per_token * 0.9;
auto acnt = accounts.find(owner);
auto acnt = accounts.find(user);
auto reward = acnt->balance.amount * multiplier;

accounts.modify(acnt, 0,
Expand Down
16 changes: 16 additions & 0 deletions ricardian_contracts/resource_exchange.buystake_rc.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# CONTRACT FOR resource_exchange::buystake

## ACTION NAME: buystake
### Parameters

Implied parameters:

* `account_name` (name of the party invoking and signing the contract)
* `asset` (amount of net stake the party whish to purchase)
* `asset` (amount of cpu stake the party whish to purchase)

### Intent
INTENT. The intention of the author and the invoker of this contract is to queue the purchase and delegation of {parameter} resources.

### Term
TERM. This Contract expires at the conclusion of code execution.
15 changes: 15 additions & 0 deletions ricardian_contracts/resource_exchange.calcost_rc.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# CONTRACT FOR resource_exchange::calcost

## ACTION NAME: calcost

### Parameters

Implied parameters:

* `asset` (amount of resources the party wish to get the current price of)

### Intent
INTENT. The intention of the author and the invoker of this contract is to get a quote of the price given the current contract state.

### Term
TERM. This Contract expires at the conclusion of code execution.
9 changes: 9 additions & 0 deletions ricardian_contracts/resource_exchange.cycle_rc.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# CONTRACT FOR resource_exchange::cycle

## ACTION NAME: cycle

### Intent
INTENT. The intention of the author and the invoker of this contract is to execute queued actions, deduct from accounts the market price for their used resources and pay dividends on their balances.

### Term
TERM. This Contract expires at the conclusion of code execution.
17 changes: 17 additions & 0 deletions ricardian_contracts/resource_exchange.sellstake_rc.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# CONTRACT FOR resource_exchange::sellstake

## ACTION NAME: sellstake

### Parameters

Implied parameters:

* `account_name` (name of the party invoking and signing the contract)
* `asset` (amount of net stake the party whish to stop consuming)
* `asset` (amount of cpu stake the party whish to stop consuming)

### Intent
INTENT. The intention of the author and the invoker of this contract is to reduce the resources to be billed to the account on the following cycle.

### Term
TERM. This Contract expires at the conclusion of code execution.
16 changes: 16 additions & 0 deletions ricardian_contracts/resource_exchange.withdraw_rc.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# CONTRACT FOR resource_exchange::withdraw

## ACTION NAME: withdraw

### Parameters

Implied parameters:

* `account_name` (name of the party invoking and signing the contract)
* `asset` (amount of tokens the party whish to withdraw from the contract)

### Intent
INTENT. The intention of the author and the invoker of this contract is to get withdraw tokens from the users account balance.

### Term
TERM. This Contract expires at the conclusion of code execution.
40 changes: 40 additions & 0 deletions ricardian_contracts/resource_exchange_rc.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
### CLAUSE NAME: Warranty
WARRANTY. The invoker of the contract action shall uphold its Obligations under this Contract in a timely and workmanlike manner, using knowledge and recommendations for performing the services which meet generally acceptable standards set forth by EOS.IO Blockchain Block Producers.

### CLAUSE NAME: Default
DEFAULT. The occurrence of any of the following shall constitute a material default under this Contract:

### CLAUSE NAME: Remedies
REMEDIES. In addition to any and all other rights a party may have available according to law, if a party defaults by failing to substantially perform any provision, term or condition of this Contract, the other party may terminate the Contract by providing written notice to the defaulting party. This notice shall describe with sufficient detail the nature of the default. The party receiving such notice shall promptly be removed from being a Block Producer and this Contract shall be automatically terminated.

### CLAUSE NAME: Force Majeure
FORCE MAJEURE. If performance of this Contract or any obligation under this Contract is prevented, restricted, or interfered with by causes beyond either party's reasonable control ("Force Majeure"), and if the party unable to carry out its obligations gives the other party prompt written notice of such event, then the obligations of the party invoking this provision shall be suspended to the extent necessary by such event. The term Force Majeure shall include, without limitation, acts of God, fire, explosion, vandalism, storm or other similar occurrence, orders or acts of military or civil authority, or by national emergencies, insurrections, riots, or wars, or strikes, lock-outs, work stoppages, or supplier failures. The excused party shall use reasonable efforts under the circumstances to avoid or remove such causes of non-performance and shall proceed to perform with reasonable dispatch whenever such causes are removed or ceased. An act or omission shall be deemed within the reasonable control of a party if committed, omitted, or caused by such party, or its employees, officers, agents, or affiliates.

### CLAUSE NAME: Dispute Resolution
DISPUTE RESOLUTION. Any controversies or disputes arising out of or relating to this Contract will be resolved by binding arbitration under the default rules set forth by the EOS.IO Blockchain. The arbitrator's award will be final, and judgment may be entered upon it by any court having proper jurisdiction.

### CLAUSE NAME: Entire Agreement
ENTIRE AGREEMENT. This Contract contains the entire agreement of the parties, and there are no other promises or conditions in any other agreement whether oral or written concerning the subject matter of this Contract. This Contract supersedes any prior written or oral agreements between the parties.

### CLAUSE NAME: Severability
SEVERABILITY. If any provision of this Contract will be held to be invalid or unenforceable for any reason, the remaining provisions will continue to be valid and enforceable. If a court finds that any provision of this Contract is invalid or unenforceable, but that by limiting such provision it would become valid and enforceable, then such provision will be deemed to be written, construed, and enforced as so limited.

### CLAUSE NAME: Amendment
AMENDMENT. This Contract may be modified or amended in writing by mutual agreement between the parties, if the writing is signed by the party obligated under the amendment.

### CLAUSE NAME: Governing Law
GOVERNING LAW. This Contract shall be construed in accordance with the Maxims of Equity.

### CLAUSE NAME: Notice
NOTICE. Any notice or communication required or permitted under this Contract shall be sufficiently given if delivered to a verifiable email address or to such other email address as one party may have publicly furnished in writing, or published on a broadcast contract provided by this blockchain for purposes of providing notices of this type.
### CLAUSE NAME: Waiver of Contractual Right
WAIVER OF CONTRACTUAL RIGHT. The failure of either party to enforce any provision of this Contract shall not be construed as a waiver or limitation of that party's right to subsequently enforce and compel strict compliance with every provision of this Contract.

### CLAUSE NAME: Arbitrator's Fees to Prevailing Party
ARBITRATOR'S FEES TO PREVAILING PARTY. In any action arising hereunder or any separate action pertaining to the validity of this Agreement, both sides shall pay half the initial cost of arbitration, and the prevailing party shall be awarded reasonable arbitrator's fees and costs.

### CLAUSE NAME: Construction and Interpretation
CONSTRUCTION AND INTERPRETATION. The rule requiring construction or interpretation against the drafter is waived. The document shall be deemed as if it were drafted by both parties in a mutual effort.

### CLAUSE NAME: In Witness Whereof
IN WITNESS WHEREOF, the parties hereto have caused this Agreement to be executed by themselves or their duly authorized representatives as of the date of execution, and authorized as proven by the cryptographic signature on the transaction that invokes this contract.

0 comments on commit a9be6ac

Please sign in to comment.