EOS 智能合约转ABI 支持类型

合约中,账户名,函数名,结构体名长度都要小于等于13。

常识:函数名不支持小数点,结构体名却可以支持下划线

合约账户account只支持下面字符:".12345abcdefghijklmnopqrstuvwxyz",有点意思


先说一下,支持的类型

unsigned __int128 uint128_t
unsigned long long uint64_t
unsigned long uint32_t
unsigned short  uint16_t
unsigned char uint8_t
long long int64_t
long int32_t
short int16_t
char int8_t
std::vector
std::string

不支持的类型,数组可以用vector代替,bool可以用char代替

__int128 int128_t
size_t
signed char 
double
float

bool
数组

下面是测试的hello.cpp

#include   
#include   
using namespace eosio;  
  
class hello : public eosio::contract {  
  public:  
      using contract::contract;  
  
      /// @abi action   
      void hi ( account_name user ) {  
         print( "Hello, ", name{user} );  
      }  
      //@abi table test i64
      struct test
      {

      	unsigned __int128	uint128_1;
      	uint128_t 			uint128_2;
      	
      	unsigned long long  uint64_1;
      	uint64_t            uint64_2;

		unsigned long       uint32_1;
		uint32_t        	uint32_2;

		unsigned short      uint16_1;
		uint16_t          	uint16_2;
		
		unsigned char       uint8_1;
		uint8_t 			uint8_2;

		long long 			int64_1;
		int64_t 			int64_2;
      	
      	long 				int32_1;
      	int32_t 			int32_2;
      	
      	short 				int16_1;
      	int16_t 			int16_2;
      	
      	char 				int8_1;
      	int8_t 				int8_2;

      	std::vector vec;
      	std::string str;

      	// __int128          int128;
      	// int128_t          int128_2;
      	// char s[10];
      	// signed char s_char;
      	//bool bl;
      	//double dl;
      	//float ft;
      	// size_t st;
      };
};  
  
EOSIO_ABI( hello, (hi) )  

测试的hello.abi

{
  "____comment": "This file was generated by eosio-abigen. DO NOT EDIT - 2018-04-12T05:34:32",
  "types": [],
  "structs": [{
      "name": "test_",
      "base": "",
      "fields": [{
          "name": "uint128_1",
          "type": "uint128"
        },{
          "name": "uint128_2",
          "type": "uint128"
        },{
          "name": "uint64_1",
          "type": "uint64"
        },{
          "name": "uint64_2",
          "type": "uint64"
        },{
          "name": "uint32_1",
          "type": "uint32"
        },{
          "name": "uint32_2",
          "type": "uint32"
        },{
          "name": "uint16_1",
          "type": "uint16"
        },{
          "name": "uint16_2",
          "type": "uint16"
        },{
          "name": "uint8_1",
          "type": "uint8"
        },{
          "name": "uint8_2",
          "type": "uint8"
        },{
          "name": "int64_1",
          "type": "int64"
        },{
          "name": "int64_2",
          "type": "int64"
        },{
          "name": "int32_1",
          "type": "int32"
        },{
          "name": "int32_2",
          "type": "int32"
        },{
          "name": "int16_1",
          "type": "int16"
        },{
          "name": "int16_2",
          "type": "int16"
        },{
          "name": "int8_1",
          "type": "int8"
        },{
          "name": "int8_2",
          "type": "int8"
        },{
          "name": "vec",
          "type": "int8[]"
        },{
          "name": "str",
          "type": "string"
        }
      ]
    },{
      "name": "hi",
      "base": "",
      "fields": [{
          "name": "user",
          "type": "account_name"
        }
      ]
    }
  ],
  "actions": [{
      "name": "hi",
      "type": "hi",
      "ricardian_contract": ""
    }
  ],
  "tables": [{
      "name": "test",
      "index_type": "i64",
      "key_names": [
        "uint128_1"
      ],
      "key_types": [
        "uint128"
      ],
      "type": "test_"
    }
  ],
  "clauses": []
}



你可能感兴趣的:(eos)