PRS Lib
是对 PRS REST API 的封装,开发者可以直接调用与 PRS 服务进行通信。
PRS 目前提供了两个环境供开发者使用:
- 正式环境,域名 https://press.one
- 测试环境,域名 https://beta.press.one
- 开发环境,域名 https://beta.press.one
目前对 DApp 开放的接口有:
- DApp 创建和维护。
- 用户授权。
- 签名。
- 签名文件相关。(签名文件、获取文件)
- 合约相关。(创建合约、绑定合约、查询合约)
- 合约交易相关。(购买合约、合约交易记录)
- 区块信息查询。
- 钱包相关。(查询钱包、查询交易历史、充值、提现)
快速开始
注册账号
- 开发者前往 PRS 官网注册账号。(正式环境:https://press.one 测试环境:https://beta.press.one )
- 登录成功后进入开发者设置、我的 DApp,完善开发者信息以及创建 DApp。
- 在项目中安装此 Lib
- DApp 在合适的时候引导用户进行授权
- 授权成功后即可进行签名发布文件、创建合约等操作
更多信息,请参考开发者网站。
Python 版本支持
支持 >= Python 3.6
安装
通过 pip 安装:
pip install prs-lib
初始化
在代码中 import prs_lib,之后创建 client
import prs_lib
# 初始化 client
client = prs_lib.PRS({
'env': 'dev',
'private_key': 'private key ..',
'address': 'address ...',
'token': 'token ...',
'debug': True,
})
# 其中,`env` 是必填的,其它都是可选的
示例代码
以下代码根据块的 id 从链上对块内容进行获取
import prs_lib
client = prs_lib.PRS({
'env': 'dev',
'debug': True,
})
res = client.block.get_by_rids([
'ba03bd584d69b89615ce8db22b4c593342a5ec09b343a7859044a8e4d389c4c2',
'65163724a98d29506b1031dc68fa62fb5a7a11fe631fb723a723b2a19e9bb65c'
])
print(res.json())
API
prs-lib 暴露一个 PRS 类,开发者通过创建 PRS 实例,来对 REST API 进行交互。
$ pydoc prs_lib
看某个具体模块的帮助,比如,查看 block 的文档:
$ pydoc prs_lib.block
Metadata
Release files for prs-lib 0.0.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| prs-lib-0.0.4.tar.gz | 24.5 kB | Without provenance | Details for prs-lib-0.0.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| prs_lib-0.0.4-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details for prs_lib-0.0.4-py2.py3-none-any.whl |
Total release size: 41.2 kB
Release files / prs-lib-0.0.4.tar.gz
| Download URL | prs-lib-0.0.4.tar.gz |
|---|---|
| Size | 24.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4cdef1b2454cf3af9b57a12ced63dd141306d354eff1e077e6b15ad61014c254
|
|
BLAKE2b-256 checksum How to use checksums |
c592c18cc49e870657f3879131310d5891a51a180b6252cd828d6b92c2c60e1c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.2.0 requests-toolbelt/0.8.0 tqdm/4.32.1 CPython/3.7.1
|
Release files / prs_lib-0.0.4-py2.py3-none-any.whl
| Download URL | prs_lib-0.0.4-py2.py3-none-any.whl |
|---|---|
| Size | 16.7 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
6277e28595471e45c41294644002828a9bb33ab4de104f0d8020a84525fa9488
|
|
BLAKE2b-256 checksum How to use checksums |
333e105edf54afc87f266f89d3d166917c35548c5bc895239542f0562d811e3c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.2.0 requests-toolbelt/0.8.0 tqdm/4.32.1 CPython/3.7.1
|
Security for prs-lib 0.0.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.