Dapp Development Toolkit

    The PlasmaDLT platform allows you to develop smart contracts and compile them using a ion.cdt

    In this guide:

    Development Toolkit

    Required Background Knowledge.

    • C / C++
    • Linux / Mac OS
    • Command Line Experience
    • Basic Blockchain Knowledge

    Installing the ION Contract Development Toolkit

    • Step 1: Installing the PlasmaDLT n project
    • Step 2: Installing the ION Contract Development Toolkit
    • Step 3:  Creating A Contract

    Step 1: Installing the PlasmaDLT n project

    Follow Setting up Configurations on PlasmaDLT Node Set-up Guide

    # Please go to and Download image https://hub.docker.com/r/plasmachain/mainet
    docker pull plasmachain/mainet
    

    Step 2: Installing the ION Contract Development Toolkit

    Clone the PlasmaDLT and ion.cdt repositories. I’d recommend keeping them in the home directory

    # Please go to https://hub.docker.com/r/plasmachain/ion.cdt
    mkdir /data
    mkdir /data/plasma
    mkdir /data/plasma/ioncdt
    mkdir /data/plasma/bios
    mkdir /data/plasm/bios/wallet
    #install ion.cdt and ionodesol/plk/ look image local or testnet 
    docker pull plasmachain/ion.cdt
    

    Tips:

    • ionode — Block producer, which you will use to run a blockchain on your local node.
    • sol —  The tool for communicating with the command interface
    • ion-cpp — The build system for compiling smart contracts.

    Notes:

    • To start, we’re going to run a local node by issuing the command below. The -e option enables block production, even if the chain is stale. The -p followed by an parameter specifies id of the block producer that controls this node.

    Step 3:  Creating A Contract

    Create a new directory called "helloworld" in the contracts directory you previously created

    # find source code on https://github.com/plasmadlt/Simple-contracts-for-Plasma/tree/master/helloworld
      $ cd CONTRACTS_DIR
      $ mkdir helloworld
      $ cd helloworld
    

    Take the basic helloworld contract and create your contract based on it

      $ cp ~/contracts/helloworld/* .
      $ ls
       CMakeLists.txt helloworld.abi helloworld.cpp helloworld.hpp
    

    Changed all the names tochanged all the names to Yours

        $ mv helloworld.cpp helloworld1.cpp
        $ mv helloworld.hpp helloworld1.hpp
        $ mv helloworld.abi helloworld1.abi
    

    Tips:

    • helloworld.abi — abi is short for “application binary interface”, it’s basically a JSON file that knows where the hooks live once we compile our source into webassembly, more on this later.
    • helloworld.cpp — c++ file, this is where our C++ source lives.
    • helloworld.hpp — h++ file, normal header file stuff.
    • CMakeLists.txt — Delete this, we’re not going to use CMake right now

    Notes:

    • We want to put together a simple Makefile so we can compile this thing and ensure that the compiler works.

    Deploying The Contract: 

    After make this change you should be able to compile by just issuing make.

    $ :~/helloworld1$ make
    Building
    # ion-cpp helloworld1.cpp -o helloworld1.wasm — abigen
    ion-cpp helloworld1.cpp -o helloworld1.wasm
    ~/helloworld1$ ls
    Makefile helloworld1.abi helloworld1.cpp helloworld1.hpp helloworld1.wasm
    

    Now lets deploy…

    $ ~/helloworld1$ make deploy
      sol set contract yoursaccount ../helloworld1 -p yoursaccount@active
      Reading WASM from ../helloworld/helloworld1.wasm…
      Publishing contract…
      executed transaction: e9136a748a9960c0e095336e7ee6d11000794026905f5d65298df8771919013e 7000 bytes 3437 us
    

    Tips:

    • Check if you can access you node using link http://you_server:your_http_port/v1/chain/get_info

    Notes:

    • If you would like to run a Block Producer node you need register your node from administration network

    Other tools: Sol commands

    Send token

    # You can find a complete list of tokens on the official website.
    $ docker exec -i <network>-bios-node sol  transfer <your account> <receiver account> "1.000000000000000000 USDP" "test memo text"
    

    Get Balance

    $ docker exec -i <network>-bios-node sol  get currency balance usdp <account name>
    

    List your last action (use -h to get help, don`t work now, works with history node only)

    $ docker exec -i <network>-bios-node sol  get actions <account name>
    

    Get blockchain info

    $ docker exec -i <network>-bios-node sol  get info <account name>
    

    Get account info

    $ docker exec -i <network>-bios-node sol  get  <account name>
    $ docker exec -i <network>-bios-node sol  get  <account name> --json
    

    Registration producer

    $ docker exec -i <network>-bios-node sol  cleos system regproducer <accountname> PLASMA1234534... http://producer.site Mars
    

    Additional Resources

    See these additional resources for more information about authorization, API resources and order actions.

    Support

    For API feature requests, bug reports and other questions related to API guides, contact [email protected].