Skip to main content

No project description provided

Project description

pyaos 开发文档

AOS链接口和AOS钱包接口的调用方法相同,在这里我会给出几个调用示例,其他方法的调用与此相通。

AOS 链接口调用示例

pyaos/chain.py 技术文档

  • chain.get_info

功能:获取与节点相关的最新信息

参数:

调用示例:

from pyaos.chain import chain

chain = chain("http://yournode.test")
print(chain.get_info())

参数example:

{'head_block_num': 33707199, 'chain_id': '907345e081e731497946845186a03a50030c6c9ee14bacfcb1922feae873f31b', 'head_block_time': '2020-10-19T12:33:56.000', 'head_block_producer': 'aoslosangele', 'head_block_id': '020254bfacb33c92188962a285ce7d9dc8e6f9a69ce8cfe46ae79a01435024be', 'last_irreversible_block_num': 33706870, 'virtual_block_cpu_limit': 3800000000, 'server_version': '95da4496', 'fork_db_head_block_id': '020254bfacb33c92188962a285ce7d9dc8e6f9a69ce8cfe46ae79a01435024be', 'block_net_limit': 1048576, 'virtual_block_net_limit': 1048576000, 'last_irreversible_block_id': '020253762f631efdb3071fca525a3a87dad244edf09efc79b7ec233f3ab400c7', 'fork_db_head_block_num': 33707199, 'block_cpu_limit': 3799900, 'server_version_string': 'push-dirty'}
  • chain.get_block

功能:获取一个块的信息

参数:

Key Value Required
block_num_or_id 块的id或者num值 Y

调用示例:

from pyaos.chain import chain

chain = chain("http://yournode.test")
print(chain.get_block(1))

参数example:

{'producer': '', 'transaction_mroot': '0000000000000000000000000000000000000000000000000000000000000000', 'block_num': 1, 'timestamp': '2018-12-13T02:02:13.000', 'producer_signature': 'SIG_K1_111111111111111111111111111111111111111111111111111111111111111116uk5ne', 'header_extensions': [], 'ref_block_prefix': 2778271483, 'id': '00000001dbcd954bfb0e99a5571cb4c7e9008ab3b28d829b8b59d0c49a1663ac', 'transactions': [], 'schedule_version': 0, 'new_producers': None, 'block_extensions': [], 'confirmed': 1, 'action_mroot': '907345e081e731497946845186a03a50030c6c9ee14bacfcb1922feae873f31b', 'previous': '0000000000000000000000000000000000000000000000000000000000000000'}

AOS 钱包接口调用示例

pyaos/wallet.py 技术文档

  • wallet.wallet_create

功能:用给定的名称创建一个新的钱包.

参数:

Key Value Required
wallet_name 钱包名称 Y

调用示例:

from pyaos.wallet import wallet

wallet = wallet("http://yournode.test")
print(wallet.wallet_create(wallet_name="YOUR_WALLET_NAME"))

参数example:

PW5KFWYKqvt63d4iNvedfDEPVZL227D3RQ1zpVFzuUwhMAJmRAYyX
  • wallet.wallet_open

功能:打开给定名称的现有钱包.

参数:

Key Value Required
wallet_name 钱包名称 Y

调用示例:

from pyaos.wallet import wallet

wallet = wallet("http://yournode.test")
print(wallet.wallet_create(wallet_name="YOUR_WALLET_NAME"))

参数example:

{}
  • wallet.wallet_lock

功能:锁定所有钱包。

参数:

Key Value Required
wallet_name 钱包名称 Y

调用示例:

from pyaos.wallet import wallet

wallet = wallet("http://yournode.test")
print(wallet.wallet_lock_all(wallet_name="YOUR_WALLET_NAME"))

参数example:

{}

AOS 加密函数

另外,AOS专门封装了一些加密和签名的函数,便于开发者使用,以保护数据的隐私性和匿名性。

  • ECDSA签名函数

功能:实现ECDSA签名

from aosencryfunc import ecdsa_sign

data = b'hello, AOS'
privkey = "0x2e66dbbfc7b8ae9ebd3bdce831509ce5136bc0a54055eaa4bff364e07291f5ab"
signature = ecdsa_sign(data, privkey)
print(signature)
# (signature:签名结果, data:签名对象, verifing_key:验签object)

结果Example:

(b'/\xdd\xceA"\x8d\x0b \x97\xa6\x9f\xb5\xd6\x9d\xdd\xfcoo7\xd9]N5\xa0\x80\x1e{\x95<\xfe\xfa:[\xe9rW\x9b\x925eV\x9b\x8b\x8a\xcb\x13SKsb\x9eDt\xc5\x18.\xb0\x89N\x9b\x064\x8c\xc7', b'hello, AOS', VerifyingKey.from_string(b'\x03 \xa2\x1a\xd4\x0etj\x1f\x99\xab=b\xca\x95g\xab+u%\xa1\xaf\xb6\xb8v\tf\x0f\xcbD\xd9!3', SECP256k1, sha1))
  • ECDSA验签

功能:验证ECDSA的签名

from aosencryfunc import ecdsa_sign, ecdsa_verifing

data = b'hello, AOS'
privkey = "0x2e66dbbfc7b8ae9ebd3bdce831509ce5136bc0a54055eaa4bff364e07291f5ab"
signature = ecdsa_sign(data, privkey)
verify = ecdsa_verifing(signature=signature[0], data=signature[1], verifing_key=signature[2])
print(verify)
verify_false = ecdsa_verifing(signature='test signature', data=signature[1], verifying_key=signature[2])
print(verify_false)

结果Example:

True
False
  • Hash加密

功能:Hash加密函数

from aosencryfunc import Hash

data = b'hello, AOS'
hash_msg = Hash(data)
print(hash_msg)

结果Example:

ba6077e30df147039255e6e981cfb2d2a53c0e40bd2f36dd009e9feded709884
  • Base64加密/解密

功能:Base64加密/解密函数

from aosencryfunc import base64_decode, base64_encode

data = b'hello, AOS'
encode_msg = base64_encode(data)
print(encode_msg)
decode_msg = base64_decode(encode_msg)
print(decode_msg)

结果Example:

aGVsbG8sIEFPUw==
b'hello, AOS'
  • bytes与list的转换函数

功能:转换bytes为list,将list转换为bytes

from aosencryfunc import list_to_binary, binary_to_list

num_list = [221, 223, 16]
binary = list_to_binary(num_list)
list_test = binary_to_list(binary)

print(binary)
print(list_test)

结果Example:

b'\xdd\xdf\x10'
[221, 223, 16]

还有许多加密函数还在开发ing,期待开发者的更新...

Project details


Release history Release notifications | RSS feed

This version

1.1

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyaos-1.1.tar.gz (6.1 kB view details)

Uploaded Source

File details

Details for the file pyaos-1.1.tar.gz.

File metadata

  • Download URL: pyaos-1.1.tar.gz
  • Upload date:
  • Size: 6.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.4

File hashes

Hashes for pyaos-1.1.tar.gz
Algorithm Hash digest
SHA256 0af377a3657fb1ccb2cce6eae9d4b8c5c87d6ce3cba5daff3fc0541bbb1a0c58
MD5 e9e9edb2e747d26c05ef7122a75a737f
BLAKE2b-256 7aeae3ea55c6c9e981c3d006aa7dff4f4b598093a234df36eecb5134d478ed56

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page