@acc-toppings/api-rpc 中文文档教程

发布于 5年前 浏览 17 项目主页 更新于 3年前

api-rpc NPM Version

RESTful API 服务使用 nodeacc RPC API 包装器 @acctoken/accjs 从 nodeacc 获取数据。

Manual Usage

全局范围内安装 TypeScript 和 tsc(TypeScript 编译器)

yarn global add typescript

Compile and Watch

将源代码编译成 js 并观察 ./dist 中的变化:

rm -rf dist && tsc -w

Currently Available API Functions

使用以下命令在 下面的 API 函数都接受一个参数,一个查询,它基本上是一个包含几个键的对象,这些键由进行 RPC API 调用所需的值组成。

buy_ram

给定一个连接的 endpointprivate_key, actor, permission, quantity 详细信息,为帐户 actor 购买 ram。

  • endpoint - string
  • private_key - string
  • actor - string
  • permission - string
  • quantity - number

create_account

给定具有 private_key、actor、permission 凭据的已连接 endpoint,使用公共 new_account_owner_key 创建一个包含 new_account_name 的帐户和公共 new_account_active_key。 如果要质押cpu、质押网络和购买内存,请传递所需的参数。

  • endpoint - string
  • private_key - string
  • actor - string
  • permission - string
  • new_account_name - string
  • new_account_owner_key - string
  • new_account_active_key - string
  • delagate - boolean (If the delagate is true then buy ram, stake cpu, and stake net actions are executed)
  • ram_bytes_buy_quantity - number (default to 8192)
  • stake_net_quantity - string (default to '1.0000 SYS')
  • stake_cpu_quantity - string (default to '1.0000 SYS')

deploy_contract

给定一个连接的端点,其中包含private_key, account_name, permission, payload 详细信息,将合同部署到account_name

  • endpoint - string
  • private_key - string
  • account_name - string
  • permission - string
  • payload - { abi: '', wasm: '' }

get_abi

给定一个连接的端点,尝试直接从 RPC API 获取 account_name 的 abi 详细信息

  • endpoint - string
  • account_name - string

get_account_details

给定连接的 endpoint,尝试直接获取 account_name 的帐户详细信息使用 RPC API

  • endpoint - string
  • account_name - string

get_block

给定一个连接的 endpoint,尝试直接从 RPC API 获取 id_or_num 的块详细信息

  • endpoint - string
  • id_or_num - string (it can accept either block ID or block number)

get_info

给定一个连接的 endpoint,尝试在 endpoint 处获取有关区块链的基本信息

  • endpoint - string

get_producer_schedule

给定一个连接的 endpoint,尝试在 endpoint

  • endpoint - string

get_producers

给定一个连接的 处获取区块链中的生产者调度端点,尝试在端点获取区块链中的生产者详细信息

  • endpoint - string

get_table_rows

给定连接的端点,尝试获取多索引表table_name<的行/code> 的 contrac t_name,如果存在

  • endpoint - string
  • contract_name - string
  • table_name - string

push_action

给定一个连接的endpointprivate_key, actor, permission 凭据,推送 action_name 的操作>account_name 参数包含在 payload 中的智能合约

  • endpoint - string
  • account_name - string
  • private_key - string
  • actor - string
  • permission - string
  • action_name - string
  • payload - object

sell_ram

给定一个连接的 endpointprivate_key, actor, permission, quantity 细节,卖 ram来自帐户 actor

  • endpoint - string
  • private_key - string
  • actor - string
  • permission - string
  • quantity - number

stake_cpu

给定一个连接的 endpointprivate_key, actor, permission, quantity 详细信息,为帐户 actor 抵押 cpu。

  • endpoint - string
  • private_key - string
  • actor - string
  • permission - string
  • quantity - number

stake_net

给定一个连接的端点,其中包含private_key、actor、permission、quantity 详细信息,帐户actor 的权益网络。

  • endpoint - string
  • private_key - string
  • actor - string
  • permission - string
  • quantity - number

unstake_cpu

给定一个连接的端点,其中包含private_key、actor、permission、quantity 详细信息,为帐户actor 取消质押cpu。

  • endpoint - string
  • private_key - string
  • actor - string
  • permission - string
  • quantity - number

unstake_net

给定一个连接的端点,其中包含private_key、actor、permission、quantity 详细信息,为帐户actor 取消质押网络。

  • endpoint - string
  • private_key - string
  • actor - string
  • permission - string
  • quantity - number

update_auth

给定一个具有private_key, account_name 凭据的连接端点,在单个事务中推送一个或两个updateauth 操作以更新公钥) account_name new_active_keynew_owner_key 表示公钥,可以同时传递,也可以一次传递一个。

  • endpoint - string
  • account_name - string
  • private_key - string
  • new_active_key - string
  • new_owner_key - string

api-rpc NPM Version

RESTful API service making use of the nodeacc RPC API wrapper @acctoken/accjs to obtain data from nodeacc.

Manual Usage

Install TypeScript and tsc (TypeScript Compiler) globally with

yarn global add typescript

Compile and Watch

Compile the source into js and watch for changes into ./dist with the following command:

rm -rf dist && tsc -w

Currently Available API Functions

The following API functions all accept a single parameter, a query which is basically an object containing several keys composed of the necessary values to make the RPC API call.

buy_ram

Given a connected endpoint with private_key, actor, permission, quantity details, buys ram for the account actor.

  • endpoint - string
  • private_key - string
  • actor - string
  • permission - string
  • quantity - number

create_account

Given a connected endpoint with private_key, actor, permission credentials, make an account consisting of new_account_name with the public new_account_owner_key and public new_account_active_key. If you want to stake cpu, stake net and buy ram, pass the required parameters.

  • endpoint - string
  • private_key - string
  • actor - string
  • permission - string
  • new_account_name - string
  • new_account_owner_key - string
  • new_account_active_key - string
  • delagate - boolean (If the delagate is true then buy ram, stake cpu, and stake net actions are executed)
  • ram_bytes_buy_quantity - number (default to 8192)
  • stake_net_quantity - string (default to '1.0000 SYS')
  • stake_cpu_quantity - string (default to '1.0000 SYS')

deploy_contract

Given a connected endpoint with private_key, account_name, permission, payload details, deploys contract to the account_name

  • endpoint - string
  • private_key - string
  • account_name - string
  • permission - string
  • payload - { abi: '', wasm: '' }

get_abi

Given a connected endpoint, try to get the abi details of account_name directly from the RPC API

  • endpoint - string
  • account_name - string

get_account_details

Given a connected endpoint, try to get the account details of account_name directly with the RPC API

  • endpoint - string
  • account_name - string

get_block

Given a connected endpoint, try to get the block details of id_or_num directly from the RPC API

  • endpoint - string
  • id_or_num - string (it can accept either block ID or block number)

get_info

Given a connected endpoint, try to get basic information about the blockchain at endpoint

  • endpoint - string

get_producer_schedule

Given a connected endpoint, try to get producer schedule in the blockchain at endpoint

  • endpoint - string

get_producers

Given a connected endpoint, try to get producers details in the blockchain at endpoint

  • endpoint - string

get_table_rows

Given a connected endpoint, try to get the rows of multi-index table table_name of contract_name, if present

  • endpoint - string
  • contract_name - string
  • table_name - string

push_action

Given a connected endpoint with private_key, actor, permission credentials, push an action of action_name of the account_name smart contract with parameters contained in payload

  • endpoint - string
  • account_name - string
  • private_key - string
  • actor - string
  • permission - string
  • action_name - string
  • payload - object

sell_ram

Given a connected endpoint with private_key, actor, permission, quantity details, sell ram from the account actor.

  • endpoint - string
  • private_key - string
  • actor - string
  • permission - string
  • quantity - number

stake_cpu

Given a connected endpoint with private_key, actor, permission, quantity details, stake cpu for the account actor.

  • endpoint - string
  • private_key - string
  • actor - string
  • permission - string
  • quantity - number

stake_net

Given a connected endpoint with private_key, actor, permission, quantity details, stake net for the account actor.

  • endpoint - string
  • private_key - string
  • actor - string
  • permission - string
  • quantity - number

unstake_cpu

Given a connected endpoint with private_key, actor, permission, quantity details, unstake cpu for the account actor.

  • endpoint - string
  • private_key - string
  • actor - string
  • permission - string
  • quantity - number

unstake_net

Given a connected endpoint with private_key, actor, permission, quantity details, unstake net for the account actor.

  • endpoint - string
  • private_key - string
  • actor - string
  • permission - string
  • quantity - number

update_auth

Given a connected endpoint with private_key, account_name credentials, push one or two updateauth actions in a single transaction in order to update the public key(s) of account_name The new_active_key and new_owner_key denote public keys, and can either be passed at the same time or passed one at a time.

  • endpoint - string
  • account_name - string
  • private_key - string
  • new_active_key - string
  • new_owner_key - string
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文