Using the Titan Suite With The Open Application Network

Follow

What is the Titan suite? No, not a symphony by Wagner, it's a dev tool for creating dApps and smart contracts for use in the Open Application Network blockchain network.

Things you can do:

Build decentralized applications (dApps) on the Open Application Network blockchain with an IDE (Integrated Development Environment) and (CLI) Command Line Interface. 

  • Compile Solidity smart contracts
  • Deploy contracts
  • Syntax highlighting and linting
  • Run unit tests in Mocha
  • Call functions with GraphQL
  • Interact with any node
  • Unlock accounts

Usage

  • yarn add global @titan-suite/cli or npm i -g @titan-suite/cli
  • In your project root, create a titanrc.js file and specify the following:
    • host: the URL of your Open Application Network-web3 provider
    • port: the port exposing an Open Application Network-web3 instance, usually 8545
    • defaultAccount [optional]: the default address to call functions with
    • password [optional]: the password of this account 
;   module.>exports = {

       "host": "http://127.0.0.1",

       "port": 8545,

       "defaultAccount": "",

       "password": ""

 >}

   

Commands

Help

  • titan --help

Titan init

Generate an empty Titan project

  • in the current directory: titan init
  • in a new directory: titan init <name>

Titan unpack

Start a new project with a pre-built dApp

  • titan unpack
    • choose a pack from the options
  • titan unpack <name>

Titan compile

Compile a Solidity smart contract

  • titan compile path/to/contracts/Example.sol
  • Compile a specific contract withing a file
    • titan compile -n SpecificContract path/to/contracts/ManyContracts.sol
  • Output more details about the contract
    • titan compile -d path/to/contracts/Example.sol

Titan deploy

Deploy a smart contract to an Open Application Network node

  • titan deploy path/to/contracts/Example.sol
  • Deploy a specific contract within a contract file:
    • titan deploy -n Test path/to/contracts/Example.sol
  • Pass parameters:
    • titan deploy -p 5 path/to/contracts/Example.sol The details of the deployed contract will be stored as ./build/bots/<contractName>.json

Titan lint

Lint a smart contract

  • titan lint path/to/contracts/Example.sol
  • lint multiple files within a directory
    • titan lint path/to/contracts/**/*.sol

Titan test

Run unit tests

  • titan test path/to/contracts/testExample.js

Titan unlock

Unlock an account

You may be prompted to enter an AION address and/or password

  • titan unlock
  • with the account specified
    • titan unlock -a <0x..>
  • with both the account and password specified
    • titan unlock -a <0x...> -p <pwd>

Titan console

Interact with an AION node with an injected aion-web3 instance

  • titan console

Test

  • Create a titanrc.js as specified above
  • yarn test

 

A Sample __Hello World__ greeter smart contract

Your first citizen: the Greeter

The Greeter is an intelligent digital entity that lives on the blockchain and is able to have conversations with anyone who interacts with it, based on its input.

Here is its code:

contract Mortal {
    /* Define variable owner of the type address */
    address owner;

    /* This function is executed at initialization and sets the owner of the contract */
    function Mortal() { owner = msg.sender; }

    /* Function to recover the funds on the contract */
    function kill() { if (msg.sender == owner) selfdestruct(owner); }
}

contract Greeter is Mortal {
    /* Define variable greeting of the type string */
    string greeting;

    /* This runs when the contract is executed */
    function Greeter(string _greeting) public {
        greeting = _greeting;
    }

    /* Main function */
    function greet() constant returns (string) {
        return greeting;
    }
}

 

 

0 out of 0 found this helpful

Comments

0 comments

Please sign in to leave a comment.