EOS.IO C语言API手册

EOS.IO C语言API手册

EOS.IO的C语言API分为以下几个部分:

Action

Action系列定义了与动作(action)查询和发送相关的API:

  • public uint32_t read_action_data (void * msg,uint32_t len)
  • public uint32_t action_data_size()
  • public void require_recipient(account_namename)
  • public void require_auth(account_namename)
  • public bool has_auth(account_namename)
  • public void require_auth2(account_namename,permission_namepermission)
  • public bool is_account(account_namename)
  • public void send_inline(char * serialized_action,size_t size)
  • public void send_context_free_inline(char * serialized_action,size_t size)
  • public void require_write_lock(account_namename)
  • public void require_read_lock(account_namename)
  • public uint64_t publication_time()
  • public account_name current_receiver()

Chain

Chain系列定义了查询区块链内部状态的API:

  • public uint32_tget_active_producers(account_name* producers,uint32_t datalen)

Console

Console系列定义了日志输出方面的API:

  • public void prints(const char * cstr)
  • public void prints_l(const char * cstr,uint32_t len)
  • public void printi(int64_t value)
  • public void printui(uint64_t value)
  • public void printi128(const int128_t * value)
  • public void printui128(const uint128_t * value)
  • public void printsf(float value)
  • public void printdf(double value)
  • public void printqf(const long double * value)
  • public void printn(uint64_t name)
  • public void printhex(const void * data,uint32_t datalen)

Crypto

Crypto系列定义了计算和校验哈希的API:

  • public void assert_sha256(char data,uint32_t length,const checksum256 hash)
  • public void assert_sha1(char data,uint32_t length,const checksum160 hash)
  • public void assert_sha512(char data,uint32_t length,const checksum512 hash)
  • public void assert_ripemd160(char data,uint32_t length,const checksum160 hash)
  • public void sha256(char data,uint32_t length,checksum256 hash)
  • public void sha1(char data,uint32_t length,checksum160 hash)
  • public void sha512(char data,uint32_t length,checksum512 hash)
  • public void ripemd160(char data,uint32_t length,checksum160 hash)
  • public int recover_key(const checksum256 digest,const char sig,size_t siglen,char * pub,size_t publen)
  • public void assert_recover_key(const checksum256 digest,const char sig,size_t siglen,const char * pub,size_t publen)

Database

Database系列定义了与数据库交互的API:

  • public int32_t db_store_i64(account_namescope,table_nametable,account_namepayer,uint64_t id,const void * data,uint32_t len)
  • public void db_update_i64(int32_t iterator,account_namepayer,const void * data,uint32_t len)
  • public void db_remove_i64(int32_t iterator)
  • public int32_t db_get_i64(int32_t iterator,const void * data,uint32_t len)
  • public int32_t db_next_i64(int32_t iterator,uint64_t * primary)
  • public int32_t db_previous_i64(int32_t iterator,uint64_t * primary)
  • public int32_t db_find_i64(account_namecode,account_namescope,table_nametable,uint64_t id)
  • public int32_t db_lowerbound_i64(account_namecode,account_namescope,table_nametable,uint64_t id)
  • public int32_t db_upperbound_i64(account_namecode,account_namescope,table_nametable,uint64_t id)
  • public int32_t db_end_i64(account_namecode,account_namescope,table_nametable)
  • public int32_t db_idx64_store(account_namescope,table_nametable,account_namepayer,uint64_t id,const uint64_t * secondary)
  • public void db_idx64_update(int32_t iterator,account_namepayer,const uint64_t * secondary)
  • public void db_idx64_remove(int32_t iterator)
  • public int32_t db_idx64_next(int32_t iterator,uint64_t * primary)
  • public int32_t db_idx64_previous(int32_t iterator,uint64_t * primary)
  • public int32_t db_idx64_find_primary(account_namecode,account_namescope,table_nametable,uint64_t * secondary,uint64_t primary)
  • public int32_t db_idx64_find_secondary(account_namecode,account_namescope,table_nametable,const uint64_t secondary,uint64_t primary)
  • public int32_t db_idx64_lowerbound(account_namecode,account_namescope,table_nametable,uint64_t secondary,uint64_t primary)
  • public int32_t db_idx64_upperbound(account_namecode,account_namescope,table_nametable,uint64_t secondary,uint64_t primary)
  • public int32_t db_idx64_end(account_namecode,account_namescope,table_nametable)
  • public int32_t db_idx128_store(account_namescope,table_nametable,account_namepayer,uint64_t id,const uint128_t * secondary)
  • public void db_idx128_update(int32_t iterator,account_namepayer,const uint128_t * secondary)
  • public void db_idx128_remove(int32_t iterator)
  • public int32_t db_idx128_next(int32_t iterator,uint64_t * primary)
  • public int32_t db_idx128_previous(int32_t iterator,uint64_t * primary)
  • public int32_t db_idx128_find_primary(account_namecode,account_namescope,table_nametable,uint128_t * secondary,uint64_t primary)
  • public int32_t db_idx128_find_secondary(account_namecode,account_namescope,table_nametable,const uint128_t secondary,uint64_t primary)
  • public int32_t db_idx128_lowerbound(account_namecode,account_namescope,table_nametable,uint128_t secondary,uint64_t primary)
  • public int32_t db_idx128_upperbound(account_namecode,account_namescope,table_nametable,uint128_t secondary,uint64_t primary)
  • public int32_t db_idx128_end(account_namecode,account_namescope,table_nametable)
  • public int32_t db_idx256_store(account_namescope,table_nametable,account_namepayer,uint64_t id,const void * data,uint32_t data_len)
  • public void db_idx256_update(int32_t iterator,account_namepayer,const void * data,uint32_t data_len)
  • public void db_idx256_remove(int32_t iterator)
  • public int32_t db_idx256_next(int32_t iterator,uint64_t * primary)
  • public int32_t db_idx256_previous(int32_t iterator,uint64_t * primary)
  • public int32_t db_idx256_find_primary(account_namecode,account_namescope,table_nametable,void * data,uint32_t data_len,uint64_t primary)
  • public int32_t db_idx256_find_secondary(account_namecode,account_namescope,table_nametable,const void data,uint32_t data_len,uint64_t primary)
  • public int32_t db_idx256_lowerbound(account_namecode,account_namescope,table_nametable,void data,uint32_t data_len,uint64_t primary)
  • public int32_t db_idx256_upperbound(account_namecode,account_namescope,table_nametable,void data,uint32_t data_len,uint64_t primary)
  • public int32_t db_idx256_end(account_namecode,account_namescope,table_nametable)
  • public int32_t db_idx_double_store(account_namescope,table_nametable,account_namepayer,uint64_t id,const double * secondary)
  • public void db_idx_double_update(int32_t iterator,account_namepayer,const double * secondary)
  • public void db_idx_double_remove(int32_t iterator)
  • public int32_t db_idx_double_next(int32_t iterator,uint64_t * primary)
  • public int32_t db_idx_double_previous(int32_t iterator,uint64_t * primary)
  • public int32_t db_idx_double_find_primary(account_namecode,account_namescope,table_nametable,double * secondary,uint64_t primary)
  • public int32_t db_idx_double_find_secondary(account_namecode,account_namescope,table_nametable,const double secondary,uint64_t primary)
  • public int32_t db_idx_double_lowerbound(account_namecode,account_namescope,table_nametable,double secondary,uint64_t primary)
  • public int32_t db_idx_double_upperbound(account_namecode,account_namescope,table_nametable,double secondary,uint64_t primary)
  • public int32_t db_idx_double_end(account_namecode,account_namescope,table_nametable)
  • public int32_t db_idx_long_double_store(account_namescope,table_nametable,account_namepayer,uint64_t id,const long double * secondary)
  • public void db_idx_long_double_update(int32_t iterator,account_namepayer,const long double * secondary)
  • public void db_idx_long_double_remove(int32_t iterator)
  • public int32_t db_idx_long_double_next(int32_t iterator,uint64_t * primary)
  • public int32_t db_idx_long_double_previous(int32_t iterator,uint64_t * primary)
  • public int32_t db_idx_long_double_find_primary(account_namecode,account_namescope,table_nametable,long double * secondary,uint64_t primary)
  • public int32_t db_idx_long_double_find_secondary(account_namecode,account_namescope,table_nametable,const long double secondary,uint64_t primary)
  • public int32_t db_idx_long_double_lowerbound(account_namecode,account_namescope,table_nametable,long double secondary,uint64_t primary)
  • public int32_t db_idx_long_double_upperbound(account_namecode,account_namescope,table_nametable,long double secondary,uint64_t primary)
  • public int32_t db_idx_long_double_end(account_namecode,account_namescope,table_nametable)

System

System系列定义了与系统内部进行交互的API:

  • public void eosio_assert(uint32_t test,const char * msg)
  • public void eosio_assert_message(uint32_t test,const char * msg,uint32_t msg_len)
  • public void eosio_assert_code(uint32_t test,uint64_t code)
  • public void eosio_exit(int32_t code)
  • public uint64_t current_time()
  • public uint32_t now()

Transaction

Transaction系列定义了发送交易的API:

  • public void send_deferred(const uint128_t & sender_id,account_namepayer,const char * serialized_transaction,size_t size,uint32_t replace_existing)
  • public int cancel_deferred(const uint128_t & sender_id)
  • public size_t read_transaction(char * buffer,size_t size)
  • public size_t transaction_size()
  • public int tapos_block_num()
  • public int tapos_block_prefix()
  • public time expiration()
  • public int get_action(uint32_t type,uint32_t index,char * buff,size_t size)
  • public int get_context_free_data(uint32_t index,char * buff,size_t size)

Privileged

Privileged系列定义了特权处理相关的API:

  • public voidset_resource_limits(account_nameaccount,int64_t ram_bytes,int64_t net_weight,int64_t cpu_weight)
  • public int64_tset_proposed_producers(char * producer_data,uint32_t producer_data_size)
  • public voidset_active_producers(char * producer_data,uint32_t producer_data_size)
  • public boolis_privileged(account_nameaccount)
  • public voidset_privileged(account_nameaccount,bool is_priv)
  • public voidset_blockchain_parameters_packed(char * data,uint32_t datalen)
  • public uint32_tget_blockchain_parameters_packed(char * data,uint32_t datalen)
  • public voidactivate_feature(int64_t f)

Memory

Memory系列定义了常用的内存操作API:

  • public void *malloc(size_t size)
  • public void *calloc(size_t count,size_t size)
  • public void realloc(void ptr,size_t size)
  • public voidfree(void * ptr)

如果你希望马上开始学习以太坊DApp开发,可以访问我们的在线互动教程:

推荐