Punica
Search…
Punica Python

Overview

Punica Python is a dApp development command line tool which has (almost) everything you need to start developing your dApp based on Ontology network.
There are a few technical requirements before we start. Please install the following:
Then, execute the following command to install your tool:
$ pip install punica

Quickstart

To use most Punica commands, you need to run them against an existing Punica project. So the first step is to create a Punica project.
$ punica
Usage: punica [OPTIONS] COMMAND [ARGS]...
Options:
-p, --project PATH Specify a punica project directory.
-v, --version Show the version and exit.
-h, --help Show this message and exit.
Commands:
compile Compile the specified contracts to avm and...
deploy Deploys the specified contracts to specified...
init Initialize new and empty Ontology DApp...
invoke Invoke the function list in default-config or...
node Ontology Blockchain private net in test mode.
scpm Smart contract package manager,support...
smartx Ontology smart contract IDE,SmartX...
test Unit test with specified smart contract
tool Data format conversion tool
unbox Download a Punica Box, a pre-built Ontology...
wallet Manager your ontid, account, asset.
You can create a bare Punica project with no smart contracts included, use punica init command.
Once this operation is completed, you'll now have a project structure with the following items:
  • contracts/: Directory for Ontology smart contracts.
  • src/: Directory for DApp source file.
  • test/: Directory for test files for testing your application and contracts.
  • wallet/: Directory for save Ontology wallet file.

Creating Project

To use most Punica commands, you need to run them against an existing Punica project. So the first step is to create a Punica project.

Create New Project

You can create a bare Punica project with no smart contracts included, use punica init command.
Once this operation is completed, you'll now have a project structure with the following items:
  • contracts/: Directory for Ontology smart contracts.
  • src/: Directory for DApp source file.
  • test/: Directory for test files for testing your application and contracts.
  • wallet/: Directory for save Ontology wallet file.
punica init --help
Usage: punica init [OPTIONS]
Initialize new and empty Ontology DApp project.
Options:
-h, --help Show this message and exit.
If you not run Punica CLI in you project root directory, you need to use -p or --project option to specify your DApp project's path.

Creating Box Project

You can create a bare project template, but for those just getting started, you can use Punica Boxes, which are example applications and project templates.
We'll use the ontology-tutorialtoken box, which creates a OEP4 token that can be transferred between accounts:
  • Create a new directory for your Punica project:
mkdir tutorialtoken
cd tutorialtoken
  • Download ("unbox") the MetaCoin box:
punica unbox tutorialtoken
punica unbox --help
Usage: punica unbox [OPTIONS] BOX_NAME
Download a Punica Box, a pre-built Ontology DApp project.
Options:
-h, --help Show this message and exit.
You can use the punica unbox <box-name> command to download any of the other Punica Boxes.
If you not run punica cli in you project root directory, you need to use -p or --project option to specify your DApp project's path.
Copy link
On this page
Overview
Quickstart
Creating Project
Create New Project
Creating Box Project