Pull to refresh

How to Write a Smart Contract with Python on Ontology? Part 1: the Blockchain & Block API

Reading time 5 min
Views 2.8K
Python *Distributed systems *Cryptocurrencies
Sandbox
image

This is an official tutorial published earlier on Ontology Medium blog
Excited to publish it for Habr readers. Feel free to ask any related questions and suggest a better format for tutorial materials

Foreword


In this article, we will begin to introduce the smart contract API of Ontology. The Ontology’s smart contract API is divided into 7 modules:


In this article, we will introduce the Blockchain & Block API, which is the most basic part of the Ontology smart contract system. The Blockchain API supports basic blockchain query operations, such as obtaining the current block height, whereas the Block API supports basic block query operations, such as querying the number of transactions for a given block.

Let’s get started!

First, create a new contract in SmartX and then follow the instructions below.

1. How to Use Blockchain API


References to smart contract functions are identical to Python’s references. Developers can introduce the appropriate functions as needed. For example, the following statement introduces GetHeight, the function to get the current block height, and GetHeader, the function to get the block header.
Read more →
Total votes 20: ↑18 and ↓2 +16
Comments 0

How to Write a Smart Contract with Python on Ontology? Part 2: Storage API

Reading time 3 min
Views 1.2K
Python *Programming *DevOps *Distributed systems *Cryptocurrencies
Tutorial
image
This is an official tutorial published earlier on Ontology Medium blog
Excited to publish it for Habr readers. Feel free to ask any related questions and suggest a better format for tutorial materials

Foreword


Earlier, in Part 1, we introduced the Blockchain & Block API of Ontology’s smart contract. Today we will discuss how to use the second module: Storage API. The Storage API has five related APIs that enable addition, deletion, and changes to persistent storage in blockchain smart contracts. Here’s a brief description of the five APIs:
Read more →
Rating 0
Comments 0

How to Write a Smart Contract with Python on Ontology? Part 3: Runtime API

Reading time 3 min
Views 1.1K
Cryptography *Python *Programming *DevOps *Cryptocurrencies
Tutorial
image

Introduction


Earlier, I have introduced the Ontology Smart Contract in
Part 1: Blockchain & Block API and
Part 2: Storage API
Now when you have an idea about how to call the relevant API for persistent storage when developing Python smart contract on Ontology, let’s go on to Runtime API (Contract Execution API). The Runtime API has 8 related APIs that provide common interfaces for contract execution and help developers get, convert, and validate data. Here’s a brief description of these 8 APIs:
Read more →
Rating 0
Comments 0

How to Write a Smart Contract with Python on Ontology? Part 4: Native API

Reading time 4 min
Views 1.6K
Cryptography *Python *DevOps *Distributed systems *Cryptocurrencies
Tutorial
image

Earlier, I have introduced the Ontology Smart Contract in
Part 1: Blockchain & Block API and
Part 2: Storage API
Part 3: Runtime API
Today, let’s talk about how to invoke an Ontology native smart contract through the Native API. One of the most typical functions of invoking native contract is asset transfer.
Read more →
Total votes 5: ↑5 and ↓0 +5
Comments 0

Как написать смарт контракт на WebAssembly в сети Ontology? Часть 1: Rust

Reading time 4 min
Views 1.9K
Cryptography *Rust *DevOps *Distributed systems *WebAssembly *
Tutorial
Translation
image

Технология Ontology Wasm снижает стоимость переноса смарт контрактов dApp со сложной бизнес- логикой на блокчейн, тем самым значительно обогащая dApp экосистему.

В настоящее время Ontology Wasm одновременно поддерживает разработку как на языке Rust, так и на языке C++. Язык Rust лучше поддерживает Wasm, а сгенерированный байт-код проще, что может еще больше снизить стоимость контрактных вызовов. Итак, как использовать Rust для разработки контракта в сети Ontology?
Читать дальше →
Total votes 11: ↑10 and ↓1 +9
Comments 0

Как написать смарт контракт на WebAssembly в сети Ontology? Часть 2: С++

Reading time 8 min
Views 1.9K
Cryptography *C++ *DevOps *Distributed systems *WebAssembly *
Tutorial
Translation
image

В этой статье мы разберем на двух примерах, как написать смарт контракт на языке C++, используя WASM на основе блокчейн сети Ontology. Сегодня, после нескольких месяцев стабильной работы в тестовом режиме, Ontology запустила WASM в основной сети, что позволяет безболезненно и с меньшими издержками переносить контракты dApp со сложной бизнес-логикой на блокчейн, тем самым значительно обогащая dApp экосистему.

Ontology Wasm также поддерживает создание смарт контрактов на языке Rust, об этом можно почитать тут.

Ниже рассмотрим два примера смарт-контракта: сначала напишем “Hello world!” и потом создадим виртуальные денежный конверт, который можно будет отправить другу в качестве подарка.

Разработка WASM-контракта с помощью С++


Читать дальше →
Total votes 6: ↑6 and ↓0 +6
Comments 0

How to Write a Smart Contract with Python on Ontology? Part 5: Native API

Reading time 3 min
Views 420
Python *DevOps *
Tutorial
image

In the previous Python tutorial posts, I have introduced the Ontology Smart Contract in
Part 1: Blockchain & Block API and
Part 2: Storage API
Part 3: Runtime API
Part 4: Native API and described how to use smart contracts for ONT / ONG transfer.

Today we will talk about how to use Upgrade API to upgrade smart contract. There are 2 APIs: Destroy and Migrate.
Read more →
Rating 0
Comments 0

Converting text into algebra

Reading time 10 min
Views 1.3K
Search engines *Semantics *Algorithms *Natural Language Processing *
Translation

Algebra and language (writing) are two different learning tools. When they are combined, we can expect new methods of machine understanding to emerge. To determine the meaning (to understand) is to calculate how the part relates to the whole. Modern search algorithms already perform the task of meaning recognition, and Google’s tensor processors perform matrix multiplications (convolutions) necessary in an algebraic approach. At the same time, semantic analysis mainly uses statistical methods. Using statistics in algebra, for instance, when looking for signs of numbers divisibility, would simply be strange. Algebraic apparatus is also useful for interpreting the calculations results when recognizing the meaning of a text.

Читать далее
Total votes 1: ↑1 and ↓0 +1
Comments 0

Algebra of text. Examples

Reading time 5 min
Views 1.5K
Search engines *Semantics *Algorithms *Natural Language Processing *
Translation

The previous work from ref [1] describes the method of transforming a sign sequence into algebra through an example of a linguistic text. Two other examples of algebraic structuring of texts of a different nature are given to illustrate the method.

Читать далее
Total votes 1: ↑1 and ↓0 +1
Comments 0

Context category

Reading time 12 min
Views 1.2K
Search engines *Semantics *Algorithms *Natural Language Processing *
Translation

The mathematical model of signed sequences with repetitions (texts) is a multiset. The multiset was defined by D. Knuth in 1969 and later studied in detail by A. B. Petrovsky [1]. The universal property of a multiset is the existence of identical elements. The limiting case of a multiset with unit multiplicities of elements is a set. A set with unit multiplicities corresponding to a multiset is called its generating set or domain. A set with zero multiplicity is an empty set.

Read more
Total votes 1: ↑1 and ↓0 +1
Comments 0

Concordance of sense

Reading time 17 min
Views 795
Search engines *Semantics *Algorithms *Natural Language Processing *
Translation

In [1,2,3] texts (sign sequences with repetitions) were transformed (coordinated) into algebraic systems using matrix units as word images. Coordinatization is a necessary condition of algebraization of any subject area. Function (arrow) (7) in [1]) is a matrix coordinatization of text. One can perform algebraic operations with words and fragments of matrix texts as with integers, but taking into account the noncommutativity of multiplication of words as matrices. Structurization of texts is reduced to the calculation of ideals and categories of texts in matrix form.

Read more
Total votes 1: ↑1 and ↓0 +1
Comments 0

Collective meaning recognition

Reading time 37 min
Views 1.3K
Search engines *Semantics *Algorithms *Natural Language Processing *
Translation

The published material is in the Appendix of my book [1]

Modern civilization finds itself at a crossroads in which to choose the meaning of life. Because of the development of technology, the majority of the world's population may be "superfluous" - not in demand in the production of values. There is another option, where each person is a supreme value, an absolute individual and can be indispensably useful in the technology of the collective mind.

In the eighties of the last century, the task of creating a scientific field of "collective intelligence" was set. Collective intelligence is defined as the ability of the collective to find solutions to problems more effectively than each participant individually. The right collective mind must be...

Read more
Total votes 2: ↑2 and ↓0 +2
Comments 0