EOS Action API -C

定义用于查询操作属性的API.

函数

uint32_t read_action_data (void *msg, uint32_t len)

将当前操作数据复制到指定的位置.

uint32_t action_data_size ()

获取当前操作的数据字段的长度。

void require_recipient (account_name name)

将指定的帐户添加到要通知的帐户集。

void require_auth (account_name name)

验证指定的帐户是否存在于所提供的一组授权中。

bool has_auth (account_name name)

void require_auth2 (account_name name, permission_name permission)

验证指定的帐户是否存在于所提供的一组授权中。

void send_inline (char *serialized_action, size_t size)

void send_context_free_inline (char *serialized_action, size_t size)

void require_write_lock (account_name name)

验证该名称存在于持有的写锁集合中。

void require_read_lock (account_name name)

验证该名称存在于保持的读锁集合中。

time publication_time ()

获取发布时间。

account_name current_sender ()

获取操作的执行者。

account_name current_receiver ()

获取该动作的当前接收者。

详细描述

EOS.IO的action具有以下抽象结构:

struct action {
  scope_name scope; // the contract defining the primary code to execute for code/type
  action_name name; // the action to be taken
  permission_level[] authorization; // the accounts and permission levels provided
  bytes data; // opaque data processed by code
};
该API使您的合同能够检查当前操作的字段并相应采取行动。

例子:

// Assume this action is used for the following examples:
// {
//  "code": "eos",
//  "type": "transfer",
//  "authorization": [{ "account": "inita", "permission": "active" }],
//  "data": {
//    "from": "inita",
//    "to": "initb",
//    "amount": 1000
//  }
// }
char buffer[128];
uint32_t total = read_action(buffer, 5); // buffer contains the content of the action up to 5 bytes
print(total); // Output: 5
uint32_t msgsize = action_size();
print(msgsize); // Output: size of the above action's data field
require_recipient(N(initc)); // initc account will be notified for this action
require_auth(N(inita)); // Do nothing since inita exists in the auth list
require_auth(N(initb)); // Throws an exception
print(now()); // Output: timestamp of last accepted block

函数文档

action_data_size()

uint32_t action_data_size()

获取当前动作的数据字段的长度此方法对动态大小的action很有用
  • 返回 
    当前操作的数据字段的长度

current_receiver()

account_name current_receiver()

获取action的接收者。
  • 返回

    当前action接收者的帐户

current_sender()

account_name current_sender()

获取当前action的发送者账户
  • 返回 当前action发送者的帐户

has_auth()

bool has_auth(account_name name)

publication_time()

time publication_time()

返回publication_time 1970年以秒为单位的时间.
  • 返回 
    返回publication_time 1970年以秒为单位的时间.

read_action_data()

uint32_t read_action_data(void * msg, uint32_t len)

将当前操作数据的len个字节复制到指定的位置
  • 参数 
    - msg - 一个指针,最多可以复制当前操作数据的len个字节 
    - len - len将要复制的当前操作数据
  • 返回 
    复制到msg的字节数

require_auth()

void require_auth(account_name name)

验证该操作中提供的身份验证集中是否存在该名称。 如果找不到,则throws
  • 参数 
    name - 待验证账户的名称

require_auth2()

void require_auth2(account_name name,permission_name permission)

验证该操作中提供的身份验证集中是否存在该名称。 如果找不到,则throws
  • 参数
    • name - 待验证账户的名称
    • permission - 权限级别进行验证

require_read_lock()

void require_read_lock(account_name name)

验证该动作中保存的读锁的名称是否存在。 如果找不到,则throws
  • 参数

    • name - 待验证账户的名称 

      require_recipient()

      void require_recipient(account_name name)

    将指定的帐户添加到要通知的帐户集

  • 参数 
    - name - 待验证账户的名称

require_write_lock()

void require_write_lock(account_name name)

验证该操作中保存的写锁集合中是否存在该名称。 如果找不到,则throws
  • 参数
    • name - 待验证账户的名称

send_context_free_inline()

void send_context_free_inline(char * serialized_action, size_t size)

在此操作的父事务处理的上下文中发送内联上下文免费操作
  • 参数 
    - serialized_action - 序列化操作 
    - size - 序列化操作的大小,以字节为单位

send_inline()

void send_inline(char * serialized_action, size_t size)

在此操作的父事务处理的上下文中发送内联操作
  • 参数 
    - serialized_action - 序列化操作 
    - size - 序列化操作的大小,以字节为单位
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值