Oracle by Example brandingInstall, Instantiate, and Invoke a Sample Blockchain Network

section 0Before You Begin

This 15-minute tutorial shows you how to install the Car Dealer sample chaincode that is packaged with Oracle Blockchain Platform, instantiate it on a channel, confirm that it is running, invoke basic transactions to add blocks to your ledger, and confirm that the new blocks have been added correctly.

Background

A blockchain is a system for maintaining distributed ledgers of facts and the history of the ledger鈥檚 updates. A blockchain is a continuously growing list of records, called blocks, which are linked and secured using cryptography.

Chaincodes define the data schema in the ledger, initialize it, perform updates when triggered by applications, and respond to queries. Chaincodes can also post events that allow applications to be notified and perform downstream operations.

Channels partition and isolate peers and ledger data to provide private and confidential transactions on the blockchain network. Members define and structure channels to allow specific peers to conduct private and confidential transactions that other members on the same blockchain network can't see or access. Each channel includes peers, the shared ledger, chaincodes instantiated on the channel, and one or more ordering service nodes.

Peer nodes contain a copy of the ledger and write transactions to the ledger. These nodes can also endorse transactions.

REST proxy nodes map an application identity to a blockchain member, which allows users and applications to call the Oracle Blockchain Platform REST APIs.

The Car Dealer sample includes a chaincode to manage the production, transfer, and querying of vehicle parts; the vehicles assembled from these parts; and the transfer of the vehicles. To run the sample, you need to:

  • Install the chaincode on one or more peers.
  • Instantiate the chaincode on a channel and enable it on REST proxy nodes.
  • Invoke the chaincode using a REST API call or an application.

You can download the sample to explore it more thoroughly, or to use it as a basis for your own chaincodes or applications.

What Do You Need?

  • An Oracle Blockchain Platform founder instance. You can't delete chaincodes that have been deployed, so create a new Oracle Blockchain Platform Developer instance for the sample network if possible.
  • Administrator access.
  • The URL of the Oracle Blockchain Platform console.

section 1Install the Sample

Installing is the act of putting the chaincode on a peer.

  1. Sign in to the Oracle Blockchain Platform console using an administrative user ID.
  2. Select the Developer Tools tab.
  3. Click the Samples pane.
  4. In the Samples pane, locate the Car Dealer sample, and click Install.
  5. On the Install CarDealer Chaincode dialog, select peer0 from the Peers drop-down list, and click Install.
  6. Click 1 in the Installed on Peers field; it lists peer0 on which you have installed the chaincode.

section 2Instantiate the Sample

Instantiating a chaincode compiles, builds, and initializes the chaincode on the selected channel and peers where the chaincode was previously installed. The instantiate transaction invokes the Lifecycle System Chaincode (LSCC) to create and initialize a chaincode on a channel.

  1. In the Samples pane, locate the Car Dealer sample, and click Instantiate. On the Instantiate Chaincode dialog, select the following and click Instantiate and Enable in REST Proxy:
    • Channel: default
    • REST proxy: restproxy1.
  2. Click 1 on the Instantiated on channels field; it shows the default channel you've selected to use.
  3. On the Channels tab, click the default channel that you are running the sample chaincode on. In the Channel Information page, click the Instantiated Chaincodes pane to confirm that there is one chaincode deployment on the channel, the obcs-cardealer chaincode.
    Description of instantiate-channel.png follows
    Description of the illustration instantiate-channel.png
  4. Click the Ledger pane and confirm that the Ledger Summary has one new block added in addition to the genesis block, indicating one deployment occurred. In the Ledger table, locate the block with the Type of data (sys). Select the block and in the Transaction table, click the arrow icon to display more information about the block.

    Confirm that the Function Name field displays deploy. Confirm that the transaction lists the Chaincode as lscc as opposed to the Car Dealer chaincode.

    Description of instantiate-ledger.png follows
    Description of the illustration instantiate-ledger.png

section 3Invoke the Sample

Invoking is the process of calling chaincode functions. You'll use the applications included with the samples, although you could use direct REST API calls if you want to.

  1. On the Developer Tools tab, open the Samples pane, locate the Car Dealer sample, and click Invoke.
  2. On the Invoke Chaincode window, create a tire using the following information, and click then Execute:
    • Channel: default
    • Action: Produce vehicle part
    • Serial Number: tr357
    • Owner: bobsmith
    • Name: tire357
    • Assembler: sevencorp
    • Assembly Date: 08/09/18
    Description of invoke-create-part.png follows
    Description of the illustration invoke-create-part.png
  3. On the Channels tab, locate and click the default channel.
  4. Open the Ledger pane, and locate the block number indicating that a data invocation occurred.
  5. Select the block, and confirm that in the Transactions table you see Success in the Status column.
  6. Click the arrow icon beside the transaction ID to display more information about the transaction.

    Because you're invoking the Car Dealer chaincode, the obcs-cardealer chaincode is listed in the transaction. The function name is initVehiclePart because you've created a new part, and the transaction is endorsed by peer0 because that's the only peer you have chosen to endorse transactions on this channel.

  7. Description of invoke-create-ledger.png follows
    Description of the illustration invoke-create-ledger.png
  8. On the Developer Tools tab, open the Samples pane, locate the Car Dealer sample, and click Invoke.
  9. On the Invoke Chaincode window, enter the following values to query the tire you just created, and then click Execute:
    • Channel: default
    • Action: Query vehicle part
    • Serial Number: tr357
  10. On the Channels tab, locate and click the default channel.
  11. Open the Ledger pane, and locate the block number of the most recent transaction.
  12. Click the block and confirm that in the Transactions table you see Success in the Status column.  Click the arrow icon next to the transaction ID to display more information about the transaction.

    The correct chaincode, function name (readVehiclePart), and endorsing peer (peer0) should be listed.

  13. Description of invoke-query.png follows
    Description of the illustration invoke-query.png
  14. On the Developer Tools tab, open the Samples pane, locate the Car Dealer sample, and click Invoke.
  15. On the Invoke Chaincode window, enter the following values to transfer the ownership of the tire to a new user, and then click Execute:
    • Channel: default
    • Action: Transfer vehicle part
    • Serial Number: tr357
    • Owner: anniechu
  16. On the Channels tab, locate and click the default channel.
  17. Open the Ledger pane, and locate the block number of the most recent transaction.
  18. Click the block, click the arrow icon next to the transaction ID to display more information about the transaction, and confirm that in the Transactions table you see Success in the Status column.

    The correct chaincode, function name (transferVehiclePart), and endorsing peer (peer0) should be listed.

  19. Description of invoke-transfer.png follows
    Description of the illustration invoke-query.png

more informationWant to Learn More?



微信炸金花购买房卡 赌博运气规律 11选5新疆 燕赵风采排列7结果 十一选五顺口溜 多乐彩江西 那个平台上有江西快三 浙江体彩6十1走势图风采网 领航pk10计划准吗 广西十一选五技巧 甘肃11选5前3选号技巧 福彩广西快3综合走势图带连线 江苏七位数体彩2元网 七开奖结果星彩 在线博彩 福建36选7有人中过奖吗 12237期博彩老头