Sign in now

Quick Start for Smart Contracts

Last updated: May 13, 2019

Before you begin

This page provides a step-by-step tutorial to deploy a sample app with Xooa’s blockchain platform-as-a-service (PaaS/BaaS). Xooa provides a permanent cloud end-point for the smart contract, enabling cloud-to-cloud integration, while retaining blockchain’s peer-to-peer capabilities.

Getting serious?

If you are using Xooa for the first time and just want to go through the process of creating a blockchain, then you need only log in to Xooa. That’s it. Nothing more to do. Read no further.

To deploy your smart contract, you can proceed with either of the below options:

  • Have a GitHub repository with your smart contract and you need to tell Xooa where the smart contract is in the repository.
  • Have the smart contract available in your local directory.

The easiest way to do that is to fork Xooa’s repository, which contains the necessary files:

https://github.com/Xooa/samples

If you already have an existing blockchain project, you can use that too.

Deploy the smart contract app

  1. In the Xooa console, go to Smart Contracts>Deploy New.

     

    Language support

    Languages supported for smart contract: NodeJS, GoLang, Java for hyperledger fabric and Solidity for Ethereum. Find samples for uploading smart contract here

  2. Locate your smart contract:

    1. Select public, private, local upload, or xooa github as appropriate (if you want to try the sample, select Xooa)
    2. If you need to, search for your repository
    3. Click Select, and then click Next.

    deploy

  3. From Smart Contract, select the smart contract you want to deploy, the network you want to deploy on, the language of your smart contract and then click Deploy. This deploys the contract to Xooa and creates an identity that can access the ledger.

     

    Relax

    Yeah, you are almost done. Xooa is doing the blockchain heavy lifting. You will be redirected to the app’s dashboard when the process completes. Be sure to copy that API token.

Create an identity

  1. Go to the Identities tab, and then click Add New

  2. Enter an identity name and from API Access Permission, select Read+Write.

  3. Click Create. You’ll get a message that the identity has been enrolled and the API token generated.

  4. Before you dismiss the message, click Copy, The token is now in the clipboard.

  5. Store the token somewhere safe. You will need it to authorize every API request.

     

    Xooa does not store the key. If you lose the key, you will have to generate a new one, invalidating any existing API clients.

Write to the blockchain ledger

You have created your smart contract app and now you want to invoke a smart contract function. Here, we’ll demonstrate the set function on the Get-Set smart contract. This function allows us to write data to the ledger. We can invoke functions directly from the API documentation, but you will need API token you copied earlier.

  1. In your Get-Set app, go to the API tab, and then click Explore API’s. The API Explorer, including the API documentation, opens.

  2. In the top left there is an input field for the API token, paste the token you copied earlier here.

  3. From the navigation, go to Smart Contract > Invoke Smart Contract Function.

  4. In the fcn field, enter set. The function set on the Get-Set smart contract will write to the ledger.

  5. In the body field, enter the data you want to store in the ledger in the format:

    [ "<key>", "<value>" ]

  6. Click TRY.

     

    Congrats!

    If your HTTP response code was 200, you have saved data in a blockchain ledger by using Xooa. Check instructions in the message or the API documentation for other return codes.

Read from the blockchain ledger

  1. To view transactions, go to Ledger > Transactions.
  2. Click the transaction ID to get additional details about the transaction

     

    Easy client integration

    Xooa client SDKs are also available in Go, PHP, Node.js, C#, Python, Java, Ruby languages here.