Contract Data Structure
The Ant Blockchain contract platform supports almost all Solidity data types, with the following differences from standard Solidity:
The
addresstype is not supported. Useidentityinstead 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.
| Type | Example | Supported by the contract platform | Supported as input parameter |
|---|---|---|---|
bool | bool a = true | Yes | Yes |
uint | uint a = 1 | Yes | Yes |
uint8 ~ uint256 | uint8 a = 1 | Yes | Yes |
int | int a = 1 | Yes | Yes |
int8 ~ int256 | int8 a = 1 | Yes | Yes |
bytes | bytes a = "test" | Yes | Yes |
bytes1 ~ bytes32 | bytes1 a = "a" | Yes | Yes |
string | string a = "test" | Yes | Yes |
identity | identity id = 0x1234567890123456789012345678901234567890123456789012345678901234567890000 | Yes | Yes |
int[] | int256[] a = [1,2,3,4,5] | Yes | Yes |
uint[] | uint256[] a = [1,2,3,4,5] | Yes | Yes |
bytes1[] ~ bytes32[] | bytes4[] asd = new bytes4; | Yes | Yes |
string[] | string[] a = ["adbc","dg"] | Yes | No |
enum | enum a {a,b,c} | Yes | No |
struct | struct a { string name;} | Yes | No |
identityis a 32-byte string type specific to the Ant Blockchain contract platform. It identifies each user and replaces the standard Solidityaddresstype, 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:
mappingstructUnits of time:
seconds,minutes,hours,days,weeks, andyears
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).