6

I am wondering where I can find a list of supported datatypes that can be used in an actions parameters.

Edit: Should have specified this better. I am writing some actions such as:

/// @abi action
void foo(const WHAT_CAN_BE_HERE& bar);

And am wondering how I can find out what parameter datatypes (WHAT_CAN_BE_HERE) are supported.

3

4 Answers 4

5

You can use this list for built-in types (Todd Fleming shared the link on Telegram):

bool
int8
uint8
int16
uint16
int32
uint32
int64
uint64
int128
uint128
varuint32
varint32
float32
float64
float128
time_point
time_point_sec
block_timestamp_type
name
bytes
string
checksum160
checksum256
checksum512
public_key
private_key
signature
symbol
symbol_code
asset

or typedefs:

typedef uint64_t account_name;
typedef uint64_t permission_name;
typedef uint64_t table_name;
typedef uint32_t time;
typedef uint64_t scope_name;
typedef uint64_t action_name;
typedef uint16_t weight_type;
typedef struct checksum256 transaction_id_type;
typedef struct checksum256 block_id_type;
4
  • Thanks for the answer but what about non build-in types like vector?
    – eclipse
    Commented Aug 12, 2018 at 19:07
  • You wil get "false: types can only be: vector, struct, class or a built-in type. (float) {"type":"float"}". Float is not supported at all. Commented Sep 3, 2018 at 19:56
  • I notice the bytes (for which I cannot seem to find a reference in the c++ literature)... would that be used for storing binary data?
    – ekkis
    Commented Jan 28, 2020 at 23:12
  • and what header file do I need to include to use it? it's supposed to be native but my code doesn't find it
    – ekkis
    Commented Jan 28, 2020 at 23:54
3

An action parameter type can be a built-in type or it can be a user defined type.

For a better understanding please read this documentation page from the beginning and pay special attention to the "Types" section. Just be aware that EOSIO, although is doing the best it can to support user defined types, if they are too complex it might not be possible to be supported and you will see errors generated in which case you have to find a way around it by simplifying the definition of the user defined type.

1

As it is described here: https://github.com/EOSIO/eos/blob/de78b49b5765c88f4e005046d1489c3905985b94/libraries/chain/abi_serializer.cpp#L89-L127

 void abi_serializer::configure_built_in_types() {

  built_in_types.emplace("bool",                      pack_unpack<uint8_t>());
  built_in_types.emplace("int8",                      pack_unpack<int8_t>());
  built_in_types.emplace("uint8",                     pack_unpack<uint8_t>());
  built_in_types.emplace("int16",                     pack_unpack<int16_t>());
  built_in_types.emplace("uint16",                    pack_unpack<uint16_t>());
  built_in_types.emplace("int32",                     pack_unpack<int32_t>());
  built_in_types.emplace("uint32",                    pack_unpack<uint32_t>());
  built_in_types.emplace("int64",                     pack_unpack<int64_t>());
  built_in_types.emplace("uint64",                    pack_unpack<uint64_t>());
  built_in_types.emplace("int128",                    pack_unpack<int128_t>());
  built_in_types.emplace("uint128",                   pack_unpack<uint128_t>());
  built_in_types.emplace("varint32",                  pack_unpack<fc::signed_int>());
  built_in_types.emplace("varuint32",                 pack_unpack<fc::unsigned_int>());

  // TODO: Add proper support for floating point types. For now this is good enough.
  built_in_types.emplace("float32",                   pack_unpack<float>());
  built_in_types.emplace("float64",                   pack_unpack<double>());
  built_in_types.emplace("float128",                  pack_unpack<float128_t>());

  built_in_types.emplace("time_point",                pack_unpack<fc::time_point>());
  built_in_types.emplace("time_point_sec",            pack_unpack<fc::time_point_sec>());
  built_in_types.emplace("block_timestamp_type",      pack_unpack<block_timestamp_type>());

  built_in_types.emplace("name",                      pack_unpack<name>());

  built_in_types.emplace("bytes",                     pack_unpack<bytes>());
  built_in_types.emplace("string",                    pack_unpack<string>());

  built_in_types.emplace("checksum160",               pack_unpack<checksum160_type>());
  built_in_types.emplace("checksum256",               pack_unpack<checksum256_type>());
  built_in_types.emplace("checksum512",               pack_unpack<checksum512_type>());

  built_in_types.emplace("public_key",                pack_unpack_deadline<public_key_type>());
  built_in_types.emplace("signature",                 pack_unpack_deadline<signature_type>());

  built_in_types.emplace("symbol",                    pack_unpack<symbol>());
  built_in_types.emplace("symbol_code",               pack_unpack<symbol_code>());
  built_in_types.emplace("asset",                     pack_unpack<asset>());
  built_in_types.emplace("extended_asset",            pack_unpack<extended_asset>());

}

0

I don't have a full list, but you can definitely use these: account_name, uint64_t, double, permission_level, string asset etc

There is a bunch of standard types declared in respective section of documentation. Feel free to browse example contracts and path_to_eos_dir/contracts/eosiolib folder to find out the others :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.