Contract Data Structure

Updated at:

The Ant Blockchain contract platform supports almost all Solidity data types, with the following differences from standard Solidity:

  • The address type is not supported. Use identity instead to identify users.

  • Two-dimensional arrays are not supported as input parameters.

  • Reference types (mapping, struct) and certain complex types (string[], enum) cannot be used as function input parameters — they can only be used inside a contract.

Basic data types

"Supported by the contract platform" means the type can be used within the contract body. "Supported as input parameter" means the type can be passed in by a client when calling a contract function.
TypeExampleSupported by the contract platformSupported as input parameter
boolbool a = trueYesYes
uintuint a = 1YesYes
uint8 ~ uint256uint8 a = 1YesYes
intint a = 1YesYes
int8 ~ int256int8 a = 1YesYes
bytesbytes a = "test"YesYes
bytes1 ~ bytes32bytes1 a = "a"YesYes
stringstring a = "test"YesYes
identityidentity id = 0x1234567890123456789012345678901234567890123456789012345678901234567890000YesYes
int[]int256[] a = [1,2,3,4,5]YesYes
uint[]uint256[] a = [1,2,3,4,5]YesYes
bytes1[] ~ bytes32[]bytes4[] asd = new bytes4;YesYes
string[]string[] a = ["adbc","dg"]YesNo
enumenum a {a,b,c}YesNo
structstruct a { string name;}YesNo
identity is a 32-byte string type specific to the Ant Blockchain contract platform. It identifies each user and replaces the standard Solidity address type, which is not supported on this platform.

For example, in the issuance methods of the credit management contract, both identity and int256 are valid input parameter types:

function Issue(identity account, int256 value)

Other types

Solidity also supports the following types, which can be used inside contracts but not as function input parameters:

  • mapping

  • struct

  • Units of time: seconds, minutes, hours, days, weeks, and years

For example, passing a mapping type as a function parameter causes an error:

function example(mapping(identity=>int256) map)  // An error occurred. The mapping declaration type is not supported as an input type.

For a full reference on Solidity data types, see Data types supported in Solidity (English).