
ืืื ืืืืง ืืจืืฉืื ืืกืืจืช ืืืจืืืื ืขื ืืฆืืจืช ืืืืื ืืืืื ืืคืืืชืื ืขื ืืื ืืืืืงืฆ'ืืื ืฉื ืืื ืืืืืืื ืืืืฆืขืืช ืืื ืคืืชืื ืืืืืื ืืืืืื. .
ืืืืืจ ืื, ื ืชืืื ืืช ืืืืืจืืช ืฉืื ื ืขื ืืืฉืง ื-API ืฉื ืืืืื ืืืืื ืฉื Ontology. ืืืฉืง ื-API ืฉื ืืืืื ืืืืื ืฉื Ontology ืืืืืง ืืฉืืขื ืืืืืืื:
- ืืืืงืฆ'ืืื ื-API ืฉื ืืืืงืฆ'ืืื,
- API ืืืื ืจืืฆื,
- API ืืืืกืื,
- API ืืงืืจื,
- ืฉืืจืื API,
- ืืืฉืง API ืฉื ืื ืืข ืืืฆืืข ื
- API ืืฉืืืืช ืกืืืืืช ืืืื ืืืืช.
ืืืฉืง ื-API ืฉื Blockchain & Block ืืื ืืืง ืืจืืื ืืืขืจืืช ืืืืืื ืืืืืื ืฉื Ontology. ืืืฉืง ื-API ืฉื Blockchain ืชืืื ืืคืขืืืืช ืฉืืืืชื ืืกืืกืืืช ืฉื ืืืืงืฆ'ืืื, ืืืื ืืืืืจ ืืืื ืืืืืง ืื ืืืื, ืืขืื ืฉืืืฉืง ื-API ืฉื Block ืชืืื ืืคืขืืืืช ืฉืืืืชื ืืกืืกืืืช ืฉื ืืืืงืื, ืืืื ืฉืืืืชื ืขื ืืกืคืจ ืืขืกืงืืืช ืขืืืจ ืืืืง ื ืชืื.
ืืืื ื ืชืืื!
ืืื ืืืชืืื, ืฆืืจ ืืืื ืืืฉ ื , ืืืืืจ ืืื ืคืขื ืืคื ืืืืจืืืช ืฉืืืื.
1. ืืืฆื ืืืฉืชืืฉ ืืืืฉืง ื-API ืฉื ืืืืงืฆ'ืืื
ืืคื ืืืช ืืคืื ืงืฆืืืช ืฉื ืืืืื ืืืืื ืืืืช ืืืคื ืืืช ืฉื ืคืืืชืื. ื ืืชื ืืืืจืืง ืืช ืืคืื ืงืฆืืืช ืืืชืืืืืช ืืคื ืืฆืืจื. ืืืืืื, ืืืฆืืจื ืืืื ืืืจืืงื ืืช GetHeight, ืคืื ืงืฆืื ืืืืืืจ ืืืื ืืืืืง ืื ืืืื, ืืืช GetHeader, ืคืื ืงืฆืื ืืืืืืจ ืืืชืจืช ืืืืืง.
from ontology.interop.System.Blockchain import GetHeight, GetHeaderืงืื ืืืื
ืคืื ืงืฆืืืช GetHeight ืืฉืืฉืช ืืืฉืืช ืืกืคืจ ืจืฆืฃ ืืืืืงืื ืืขืืื ื ืืืืชืจ ืืืืืงืฆ'ืืื, ืืคื ืฉืืืฆื ืืืืืื ืืืื. ืืืืืื ืืืืจืื ื ืืื, ื ืฉืืื ืืช ืืคืื ืงืฆืื Main ืืฉื ื ืืืืช, ืื ื ืืชื ืืืืกืืฃ ืืืชื ืืืืืช ืืฆืืจื.
from ontology.interop.System.Runtime import Notify
from ontology.interop.System.Blockchain import GetHeight
def Main(operation):
if operation == 'demo':
return demo()
return False
def demo():
height=GetHeight()
Notify(height) # print height
return height #return height after running the functionืงืื ืืืชืจืช
GetHeader ืืฉืืฉ ืืืฉืืช ืืืชืจืช ืืืืง; ืืคืจืืืจ ืืื ืืกืคืจ ืืจืฆืฃ ืฉื ืืืืืง ืืืืืงืฆ'ืืื. ืืืืื:
from ontology.interop.System.Runtime import Notify
from ontology.interop.System.Blockchain import GetHeader
def demo():
block_height=10
header=GetHeader(block_height)
Notify(header)
return headerืงืื ืขืกืงื ืขื ืืื Hash
GetTransactionByHash ืืฉืืฉ ืืืืืืจ ืขืกืงื ืืืืฆืขืืช ืืืืื ืขืกืงื. ืืืืื ืืขืกืงื ื ืฉืื ืื ืงืื ืขืกืงื ืขื ืืื Hash ืืคืจืืืจืื ืืคืืจืื bytearray. ืืืคืชื ืืคืื ืงืฆืื ืื ืืื ืืืจืช ืืืืื ืขืกืงืช ืืงืกืืฆืืืื ืืืืืื ืขืกืงืช bytearray. ืืื ืฉืื ืืฉืื. ืืืจืช, ืชืงืืื ืฉืืืื ืืืฆืืื ืช ืฉืืื ืืืืง ืขื ืืืืื ืืืืืง ืืื. ืืืื ื ืืงื ืืืืื ืขืกืงืช ืืงืกืืฆืืืื ืืืืืื ืื ืืืจ ืืืชื ืืคืืจืื bytearray. ืืืืืื ื ืจืืืช ืื:
9f270aa3a4c13c46891ff0e1a2bdb3ea0525669d414994aadf2606734d0c89c1ืจืืฉืืช, ืืคืื ืืช ืงืื ืืืืืื ืฉื ืืขืกืงื:
c1890c4d730626dfaa9449419d662505eab3bda2e1f01f89463cc1a4a30a279ืืคืชืืื ืืืืืื ืืืฆืข ืฉืื ืื ืืืืฆืขืืช ืืื ืืืจืช ืืกืคืจืื ืืงืกืืฆืืืื (little endian) ืืืกืืคืง ืขื ืืื SmartX.
ืืืืจ ืืื, ืืืืจื ืืช ืืขืจื ืืืชืงืื ืืคืืจืื bytearray:
{0xc1,0x89,0x0c,0x4d,0x73,0x06,0x26,0xdf,0xaa,0x94,0x49,0x41,0x9d,0x66,0x25,0x05,0xea,0xb3,0xbd,0xa2,0xe1,0xf0,0x1f,0x89,0x46,0x3c,0xc1,0xa4,0xa3,0x0a,0x27,0x9f}ื ืืชื ืืขืฉืืช ืืืช ืืืืฆืขืืช ืืื ืืืืจื ืฉื ืืขืจื ืืชืื ืฉื String ืืืกืืคืง ืขื ืืื SmartX. ืืืกืืฃ, ืืืืจื ืืช ืืขืจื ืืืืืืื ืฉื ืืฆืจ ืืืืจืืืช ืื:
xc1x89x0cx4dx73x06x26xdfxaax94x49x41x9dx66x25x05xeaxb3xbdxa2xe1xf0x1fx89x46x3cxc1xa4xa3x0ax27x9fืืืื ืืืืื ืืคืื ืงืฆืื GetTransactionByHash, ืืฉืจ ืืืงืืช ืขืกืงื ืืคื ืงืื ื-hash ืฉืื:
from ontology.interop.System.Blockchain import GetTransactionByHash
def demo():
# tx_hash="9f270aa3a4c13c46891ff0e1a2bdb3ea0525669d414994aadf2606734d0c89c1"
tx_hash=bytearray(b"xc1x89x0cx4dx73x06x26xdfxaax94x49x41x9dx66x25x05xeaxb3xbdxa2xe1xf0x1fx89x46x3cxc1xa4xa3x0ax27x9f")
tx=GetTransactionByHash(tx_hash)
return txืืืื ืงืื ืขืกืงื
GetTransactionHeight ืืฉืืฉ ืืืืืืจ ืืืื ืืขืกืงื ืืืืฆืขืืช ืงืื ืืืืืื ืฉื ืืขืกืงื. ืืืื ื ืฉืชืืฉ ืืงืื ืืืืืื ืืืืืืื ืืขืื:
from ontology.interop.System.Blockchain import GetTransactionHeight
def demo():
# tx_hash="9f270aa3a4c13c46891ff0e1a2bdb3ea0525669d414994aadf2606734d0c89c1"
tx_hash=bytearray(b"xc1x89x0cx4dx73x06x26xdfxaax94x49x41x9dx66x25x05xeaxb3xbdxa2xe1xf0x1fx89x46x3cxc1xa4xa3x0ax27x9f")
height=GetTransactionHeight(tx_hash)
return heightืงืื ืืืื
ืืคืชืืื ืืืืืื ืืืฉืชืืฉ ืืคืื ืงืฆืื GetContract ืืื ืืืืืจ ืืืื ืืืืฆืขืืช ื-hash ืฉืื. ืชืืืื ืืืจืช ื-hash ืฉื ืืืืื ืืื ืืชืืืื ืืืจืช ื-hash ืฉื ืืขืกืงื ืฉืชืืืจ ืืขืื.
from ontology.interop.System.Blockchain import GetContract
def demo():
# contract_hash="d81a75a5ff9b95effa91239ff0bb3232219698fa"
contract_hash=bytearray(b"xfax98x96x21x32x32xbbxf0x9fx23x91xfaxefx95x9bxffxa5x75x1axd8")
contract=GetContract(contract_hash)
return contractGetBlock
GetBlock ืืฉืืฉ ืืืฉืืช ืืืืง. ืืฉื ื ืฉืชื ืืจืืื ืืืฉืื ืืืืง ืกืคืฆืืคื.
1. ืงืื ืืืื ืืืืง ืืืจ ืืืืง:
from ontology.interop.System.Blockchain import GetBlock
def demo():
block=GetBlock(1408)
return block2. ืงืืื ืืืืื ืืืืง ืืืจ ืืืืง:
from ontology.interop.System.Blockchain import GetBlock
def demo():
block_hash=bytearray(b'x16xe0xc5x40x82x79x77x30x44xeax66xc8xc4x5dx17xf7x17x73x92x33x6dx54xe3x48x46x0bxc3x2fxe2x15x03xe4')
block=GetBlock(block_hash)2. ืืืฆื ืืืฉืชืืฉ ืืืืฉืง ื-API ืฉื Block
ืืฉื ื ืฉืืืฉ ืคืื ืงืฆืืืช ืืืื ืืช ื-API ืฉื Block: ืงืื ืขืกืงืืืช, ืงืื ืืกืคืจ ืคืขืืืืชื - ืงืื ืขืกืงื ืืคื ืืื ืืงืกื ื ืชื ืืืชื ืืื ืืื.
ืงืื ืืกืคืจ ืคืขืืืืช
ืืคืื ืงืฆืื GetTransactionCount ืืฉืืฉืช ืืงืืืช ืืกืคืจ ืืขืกืงืืืช ืขืืืจ ืืืืง ื ืชืื.
from ontology.interop.System.Blockchain import GetBlock
from ontology.interop.System.Block import GetTransactionCount
def demo():
block=GetBlock(1408)
count=GetTransactionCount(block)
return countืงืื ืขืกืงืืืช
ืืคืชืืื ืืืืืื ืืืฉืชืืฉ ืืคืื ืงืฆืื GetTransactions ืืื ืืงืื ืืช ืื ืืขืกืงืืืช ืืืืืง ื ืชืื.
from ontology.interop.System.Blockchain import GetBlock
from ontology.interop.System.Block import GetTransactions
def demo():
block=GetBlock(1408)
txs=GetTransactions(block)
return txsืงืื ืขืกืงื ืืคื ืืื ืืงืก
ืืคืื ืงืฆืื GetTransactionByIndex ืืฉืืฉืช ืืืืกืืฃ ืขืกืงื ืกืคืฆืืคืืช ืืืืืง ื ืชืื.
from ontology.interop.System.Blockchain import GetBlock
from ontology.interop.System.Block import GetTransactionByIndex
def demo():
block=GetBlock(1408)
tx=GetTransactionByIndex(block,0) # index starts from 0.
return txืืช ืืืืจืื ืืืื ื ืืชื ืืืฆืื ืืืชืจ ืฉืื ื .
ืืืจืืช ืืืจ
ืืืฉืง ื-API ืฉื Blockchain & Block ืืื ืืืง ืืืชื ื ืคืจื ืืืืืื ืืืืื, ืฉืื ื ืืชื ืืืฉืชืืฉ ืื ืืื ืืืฆืข ืฉืืืืชืืช ืขื ื ืชืื ื ืืืืงืฆ'ืืื ืืืืืงืื ืืชืื ืืืืื ืืืืื. ืืืืืจืื ืขืชืืืืื ื ืืื ืืืฆื ืืืฉืชืืฉ ื-API ืื ืืชืจืื ืื ืืงืืจ ืืช ืืืื ืืจืืงืฆืืืช ืฉืืื ืขื ืืืืงืฆ'ืืื ืฉื ืืื ืืืืืืื.
ืืืืืจ ืชืืจืื ืขื ืืื ืขืืจืื Hashrate&Shares ืืืืืื ืขืืืจ OntologyRussia.
ืืื ืืชื ืืคืชื? ืืฆืืจืฃ ืืงืืืืช ืืืื ืืืืืื ืฉืื ื ื- . ืืื ืื, ืชืกืชืื ืขื ืืืชืจ ืืืื ืืจื ื ืฉืื ื, ืฉื ืชืืื ืืืฆืื ืืืื ืืืคืชืืื, ืชืืขืื ืืขืื.
ืืื ืืืืืืื
- /
- ืืืืจื /
- /
ืืงืืจ: www.habr.com
