Sample Currency Contract

From Open Transactions
Revision as of 17:02, 11 June 2013 by Cryptoman (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

What I find interesting about Ricardian Contracts

  • They provide a consistent ID for the same contract, across all servers, without needing a centralized directory server. (Since the ID is formed by hashing the contract itself, forming its fingerprint.)
  • Since the Contract's ID is its fingerprint, this prevents tampering. (Were someone to change any contract, by even one bit--a 0 or a 1--it would also change the contract's hashed ID, which would fail to verify as a fingerprint.) The Nym ID, similarly, acts as a fingerprint for its public key.
  • Furthermore, the public key of the contract's signer is embedded within the contract itself. This means that anyone can read that public key out of the contract, and then use it to verify the signature on that contract.
  • From then on, users will also encrypt all their future communications to that key, and/or take advantage of whatever other trusted keys and rendezvous points may be described in the contract. Whenever the user sends messages to the entity listed on the contract, he has pretty good confidence that only the contract signer, with his private key and passphrase, can both receive AND open the OpenSSL envelope sent by the client.
  • Ricardian Contracts encapsulate everything you need to know about a currency (or a server.) Such as the connection information, the currency symbol, the entity's identifying information, its terms and conditions, jurisdiction, etc. These values can all be set by the issuer, agreed by the user, and enforced by the server.
  • Ricardian contracts can contain many different addresses of different types, such as the .onion address, the eepsite, the IP address, the Freenet address, a Namecoin address, an email addresses, WWW etc. Combining with these external locations makes it possible for contracts to expire themselves, and update their terms, effectively replacing the CA system.
  • Ricardian contracts also provide good evidence that, if a user was using the ID, therefore he must have had the contract loaded up into his wallet and assented to its terms. No one just magically guesses a 256 bit hash. How could a person simultaneously be aware of a currency contract enough to use it every day in his own wallet, for his own money, yet turn around later and try to claim that he was unaware of its existence? And on top of that, who could then expect to bring any legal action against the signer, except based upon those same terms? Only time will tell as this contracts are tested in court.
  • While Ricardian contracts are simply signed-XML files, they can be nested like russian dolls, and they have turned out to become the critical building block of the entire Open Transactions library. Most objects in the library are derived, somehow, from OTContract. The messages are contracts. The datafiles are contracts. The ledgers are contracts. The payment plans are contracts. The markets and trades are all contracts. Etc.
  • Many OT contracts, such as smart contracts are self-enforcing, meaning the contract is a financial instrument, yet it is also a computer script that executes over time. Once it has been activated, until it expires or is canceled by one of its authorized parties, the contract will process automatically according to its terms. The clauses are scripted by the users and then signed and activated onto any OT server.

I originally implemented contracts solely for the issuing, but they have really turned out to have become central to everything else in the library. Today even escrow is now available in OT purely in scripted form. (Without requiring any changes inside the OT C++ code itself, users are able to create their own escrow agreements in SCRIPT form, and run them inside OT.)

Here is a sample currency contract:

-----BEGIN SIGNED CONTRACT-----
Hash: SAMY

<?xml version="1.0"?>
<digitalAssetContract version="1.0">

<entity shortname="Gnome" 
longname="The Gnomes of Zurich" 
email="gnome@zurich.com"/>

<issue company="Anon-E-Gold, Inc" 
email="gnome@anonesilver.com"
contractUrl="https://e-silver.com/cash/contract/"
type="currency"/>

<currency name="silver grams" tla="GRAM" symbol="sg" type="decimal" factor="1" decimal_power="0" fraction="mg"/>

<!-- CONDITIONS -->

<condition name="backing">
  DIGITAL SILVER GRAMS are payable to bearer in physical silver grams,
  at any exchange provider supporting our contract in any denomination
  they support, or through one of our direct agents in 1000 oz bars. 
</condition>

<condition name="audit">
  Silver Grams are audited monthly by highly trusted people.
</condition>

<condition name="purchase">
  In order to obtain Silver Grams, you must
  purchase them from an exchange provider or receive them in trade.
  The issuer only accepts direct bail-in of physical silver from an
  authorized exchange provider.
</condition>

<condition name="redemption">
  In order to redeem Silver Grams, you must use an exchange provider.
  If none are available you must make sure you trust this issuer
  and make sure this contract is enforceable in your jurisdiction,
  and make sure you are trading in a BASKET currency so that you
  are not entirely reliant on a single issuer.
  Silver Grams are redeemable to exchange providers in 1 oz coins.
</condition>

<condition name="rate">
  Issuance and redemption will be performed at no charge.
</condition>

<condition name="buyback">
  The Issuer reserves the right to buy back all outstanding
  currency, thereby terminating the use of this instrument.
</condition>

<condition name="liability">
  Silver and its maker, God, are solely liable to perform according to
  the conditions specified in this contract.
</condition>

<condition name="mint">
  Float - the total quantity of Silver is created by God.
  The quantity of silver that enters the market yearly is strictly
  regulated by His wisdom. 

  Any server operator using this contract will not issue any more
  silver digital currency than he actually has in physical silver.
</condition>

<condition name="privacy">
  The purchase, redemption and trading of digital assets normally
  are done on the basis of strong privacy.
</condition>

<!-- KEYS -->

<key name="contract">
- -----BEGIN CERTIFICATE-----
MIICZjCCAc+gAwIBAgIJAJWeuXi8XjVjMA0GCSqGSIb3DQEBBQUAMFcxCzAJBgNV
BAYTAlVTMREwDwYDVQQIEwhWaXJnaW5pYTEQMA4GA1UEBxMHRmFpcmZheDERMA8G
A1UEChMIWm9yay5vcmcxEDAOBgNVBAMTB1Jvb3QgQ0EwHhcNMTAwNzIyMjAxMTIx
WhcNMTAwODIxMjAxMTIxWjBeMQswCQYDVQQGEwJVUzERMA8GA1UECBMIVmlyZ2lu
aWExEDAOBgNVBAcTB0ZhaXJmYXgxETAPBgNVBAoTCFpvcmsub3JnMRcwFQYDVQQD
Ew5zaGVsbC56b3JrLm9yZzCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAtiu6
jU/R2Zm3AAo1jA4z/IVHyAnIFzp4kUNkLjEQ6bKG31PRaTcZTLPBkXsnQIFPx1Ky
u9q8T9gjiKPAEurtPyoDdT99aWP1NREcg4/RJ2naWOEAXGh21PP22x31bvy6lOrv
KqOSBfNTL43PEj0dKMIl0MNywzsVZGDqKXTStG0CAwEAAaMzMDEwCQYDVR0TBAIw
ADAkBgNVHREEHTAbgg5zaGVsbC56b3JrLm9yZ4IJbG9jYWxob3N0MA0GCSqGSIb3
DQEBBQUAA4GBAEhRt14Ys7jhUg0mDKMMgZLLs8cbDNFqwoJynLVNgJUdlvwo/nzZ
Mk0wWVw8ucaDdpSBufUx4G3h6KkTTKOAbkvncRGdCiqywvOjKIbUczWMDdJ9uE5m
5zGVZZ8C7EqaIIrv0OpW8WSryOCXvCFhLfKuZteELGmCCX2tQE9TqIsr
- -----END CERTIFICATE-----
</key>

<key name="certification">
- -----BEGIN PGP PUBLIC KEY BLOCK-----
Version: PGP Desktop 10.0.1 - not licensed for commercial use: www.pgp.com

mQGiBDn6yYURBADM3qphMoDpvpp3Lk2KW0bpA+i1ne6Hwm24lW9w1dIJrw8CEc+S
vAEhoGOAJNTO209NFYxcM+sA8XHp5aJpFHSbI536sfzbSVe3/MwdJ8JZXtbzcbHv
ToBs1wScGTet2SGL6I9S3p7XUfprCYezBPRMCPOTxqR8pptotYOGXZoPZQCg/y0q
CZjPJclqDY8Hf0X+DWnOMAkEAI4GnOpSq838/oElDAuZcLOvpTqTZ922pG1EJQmj
Vh4P6br3ocrWnJSonkqFPLjihsVwGumO/hkyptrgqRV/vR9BmK1LKz901VaXbXPZ
Lcns+XAg5sXxZcz87Dl4AduTF59ahHkc2bR7HqrvzRkXoQ/Q4ViLOifFISXXPKx8
3OazA/9Ip4W+gr8e/oub7MQFJZcyOfcN1KDFIjnObVIabpIlKPcTeEHGvd/WUHOJ
PQQr1+WGZY1W9UjLo171ssL2/x2bXaqJ4Ukgf4aQpRb5lUqekCKgine6eUA1XjTw
J+a/J3xP54/iEuqdDZYGuX5j0/EJCqbY7gggPNkDNH82XdfQ+7QzUmFjaGVsIFdp
bGxtZXIgW2NlcnRpZmljYXRpb25dIDxyYWNoZWxAd2lsbG1lci5vcmc+iE4EEBEC
AA4FAjn6yYUECwMCAQIZAQAKCRC30ABpXpgYMFTFAJ0WqZwUXbD0H7YCGR7rI8jB
Rh8E2wCePBrQBC1+shZrXCY0proYCkYfWdA=
=UObU
- -----END PGP PUBLIC KEY BLOCK-----
</key>

<key name="serverCertification">
- -----BEGIN PGP PUBLIC KEY BLOCK-----
Version: PGP Desktop 10.0.1 - not licensed for commercial use: www.pgp.com

mQGiBDmhGRERBAC9F7VF7ZNcwhffdFS2Sg0AcsF9gdhEEggZmBT1ezM5BYEO4lvN
EJjezFilNxMLE3mP9E95mtRUEEtIx4ViyAGjVPwRBVQA2BNf+rbvCReBhhlJTFkN
GOSHd65k4mDCflJAn7EX2OpST9tEAhpBs82w4OxlHIxmnav8iyD0O07sHwCgzYJI
Xv3TEqERh0eDPEQ80MqGYEkD/Aj12tRhZYhYlVtEmJ4MrET9Ezuyhn8kQv89iBNK
u2mN//LK4cqfJos1SJ3qXT16AHQQvfI0AUsI1ZQ+piq9pZ+sUMwpRnoQHM5SKux5
UYcIM9aklW0zYAt+WjyrQBhN0eW0uzF40NVZHIH592dz/1RbNKf0hSDKBeCERTxk
/zRDA/9rgvwyclIq4VTgA9AgwHC+JrKwbtJsawb4eYZPSbDe/pl2bQT9haTuLBKs
Olz57Er5Vto6DWb1hs8gzb107u7CGYholr/tyjiPRhDvOcVQpZudkCE/1UXpawT/
P4tPUvrBIVNK5SmHVRz6nsJxMxYm6Pr14+t8mgS1jrr/TxFTW7Q+U3lzdGVtaWNz
IE9wZW5QR1AgU09YIFtvcGVyYXRvcl0gKGRzczEpIDxzZXJ2ZXJAc3lzdGVtaWNz
LmNvbT6IVgQTEQIAFgUCOaEZEQQLCgQDAxUDAgMWAgECF4AACgkQKfOLUygtdArw
3QCeJ8bEfVFS2etPkFus6esJfZ0+2OUAoK4AIIjFB+9CsoEkCn4dJBRTUKen
=L806
- -----END PGP PUBLIC KEY BLOCK-----
</key>

</digitalAssetContract>
-----BEGIN CONTRACT SIGNATURE-----
fm7l4FyMW7p0ayZcBwq2JHGnSzRIwS75tvkNxpEnrvcahwv68RKFmxDr7Hz8000u
d9oOznZpjga17gwSlTS1AsiX3GAix5CLCZLenAV6dUUsgEBOK2kCnB/6gc8c5FVP
QH0mF0ICfxDPSY2Y0/lXVww8URis0mmHz3F+NX9S9B4=
-----END CONTRACT SIGNATURE-----

To read about the cash tokens, click here.
To read about the OTMint object, click here.
To read about messaging and OTMessage, click here.