Pull to refresh
  • by relevance
  • by date
  • by rating

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

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
Views 1.9K
Comments 0

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

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
Views 646
Comments 0

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

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
Views 624
Comments 0

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

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
Views 1.1K
Comments 0

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

Cryptography *Rust *DevOps *Distributed systems *WebAssembly *
Translation
Tutorial
image

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

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

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

Cryptography *C++ *DevOps *Distributed systems *WebAssembly *
Translation
Tutorial
image

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

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

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

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


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

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

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
Views 281
Comments 0

Converting text into algebra

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
Views 796
Comments 0

Context category

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
Views 650
Comments 0