GithubHelp home page GithubHelp logo

nickfujita / python-template Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ont-avocados/python-template

0.0 0.0 0.0 52 KB

A python smart contract library for ontology

License: Apache License 2.0

Python 100.00%

python-template's Introduction

Disclaimer

All downloads and use of this repository (python-template) are deemed to have been read carefully and fully agree to the following terms.

  • This repository is only for personal learning and communication purposes and is strictly prohibited for commercial and non-use purposes.
  • The authors have the right to revoke the right to use any commercial activity or bad use.
  • The risks of using the contents within this repository (python-template) will be entirely token by the users, and the repository authors will not hold any responsibility.
  • The repository authors are not responsible for any accidents, negligence, contract damage, defects, copyright or other intellectual property rights infringement and any damage caused by improper use of any contents within this repository (python-template). And the repository authors will not take any legal responsibility.
  • The repository (python-template) authors do not assume any responsibility for service interruption or other defects caused by force majeure or hacking attacks, communication line interruptions, etc. In addition, under the circumstances that the authors do not take any responsibility, the authors will try to reduce the loss or bad effects caused to the users.
  • For issues not covered by this statement, please refer to relevant national laws and regulations. When this statement conflicts with relevant national laws and regulations, the national laws and regulations shall prevail.
  • The copyright of this repository and its right of modification, renewal and final interpretation are owned by the authors of the repository (python-template).

Introduction

This project aims for providing demos in python version for developing smart contract based on ontology. The following templates have been tested smoothly. The template contracts all work well and they can be used as reference when you write ONT smart contract.

  • libs contain safe SafeMath, SafeCheck and Utils files
  • migrate_destroyWithinContract.py
  • static_call_Oep4.py
  • struct_example.py
  • storage_example.py
  • native_asset_invoke.py
  • OEP4Sample.py
  • OEP5Sample.py
  • OEP8Sample.py
  • event_test.py
  • Compare Executing Entry and Calling ScriptHash
  • Dynamic Call Contract
  • List and Map Sample

Instruction

Preparation

1. configure ontology cli

For test usage, you can start ontology node and test your contract under ontology cli.

1.1 Install ontology cli

The instructions for installation of cli is given here.

1.2 Usage of ontology cli

The instructions for usage of cli is given here (EN, CN).

2. configure neo-boa environment

Note here that the official installation instruction is a little bit misunderstanding. Here I will give the full and correct installation guide.

2.1. Download neo-boa (ONT version)
2.2. Make a Python 3 virtual environment and activate it (in windows system) via:
python3 -m venv venv
cd venv/bin
activate
2.3. Then, install the requirements:
pip install -r requirements.txt
2.4. Installation requires a Python 3.6 or later environment.
pip install neo-boa
2.5. You can read the docs about how to use neo-boa

Suggest you can ignore boa-test since some of the paths are configured wrongly.

Usage

Download the "python-template" zip folder and unzip it to any folder you create parallel with "boa" folder.

3.1 Compile contract

Open "compile_contract.py", make sure there is nothing wrong with compiling it. Then you can run this py file. Accordingly, the corresponding readable avm file will be in the corresponded folder.

Copy your avm file into your "$GOPATH/src/github.com/ontio/ontology/*" (the folder containing your ontology and wallet).

3.2 Start ontology node
ontology --testmode --gasprice=0
3.3 Deploy contract

Deploy smart contract in testmode. Here --code="your avm file"

./ontology contract deploy --name=xxx 
--code=xxx 
--author=xxx --desc=xxx --email=xxx --needstore --gaslimit=100000000

3.4 Invoke contract

Invoke methods within your contract, please refer to the usage of ontology cli (EN, CN).

python-template's People

Contributors

tonyclarking avatar avocas avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.