github.com/leonlxy/hyperledger@v1.0.0-alpha.0.20170427033203-34922035d248/docs/source/FAQ/chaincode_FAQ.rst (about)

     1  Chaincode (Smart Contracts and Digital Assets)
     2  ----------------------------------------------
     3  
     4  * Does the fabric implementation support smart contract logic?
     5  
     6  Yes. Chaincode is the fabric’s interpretation of the smart contract
     7  method/algorithm, with additional features.
     8  
     9  A chaincode is programmatic code deployed on the network, where it is
    10  executed and validated by chain validators together during the consensus
    11  process. Developers can use chaincodes to develop business contracts,
    12  asset definitions, and collectively-managed decentralized applications.
    13  
    14  * How do I create a business contract using the fabric?
    15  
    16  There are generally two ways to develop business contracts: the first way is to
    17  code individual contracts into standalone instances of chaincode; the
    18  second way, and probably the more efficient way, is to use chaincode to
    19  create decentralized applications that manage the life cycle of one or
    20  multiple types of business contracts, and let end users instantiate
    21  instances of contracts within these applications.
    22  
    23  * How do I create assets using the fabric?
    24  
    25  Users can use chaincode (for business rules) and membership service (for digital tokens) to
    26  design assets, as well as the logic that manages them.
    27  
    28  There are two popular approaches to defining assets in most blockchain
    29  solutions: the stateless UTXO model, where account balances are encoded
    30  into past transaction records; and the account model, where account
    31  balances are kept in state storage space on the ledger.
    32  
    33  Each approach carries its own benefits and drawbacks. This blockchain
    34  fabric does not advocate either one over the other. Instead, one of our
    35  first requirements was to ensure that both approaches can be easily
    36  implemented with tools available in the fabric.
    37  
    38  * Which languages are supported for writing chaincode?
    39  
    40  Chaincode can be written in any programming language and executed in containers
    41  inside the fabric context layer. We are also looking into developing a
    42  templating language (such as Apache Velocity) that can either get
    43  compiled into chaincode or have its interpreter embedded into a
    44  chaincode container.
    45  
    46  The fabric's first fully supported chaincode language is Golang, and
    47  support for JavaScript and Java is planned for 2016. Support for
    48  additional languages and the development of a fabric-specific templating
    49  language have been discussed, and more details will be released in the
    50  near future.
    51  
    52  * Does the fabric have native currency?
    53  
    54  No. However, if you really need a native currency for your chain network, you can develop your own
    55  native currency with chaincode. One common attribute of native currency
    56  is that some amount will get transacted (the chaincode defining that
    57  currency will get called) every time a transaction is processed on its
    58  chain.