All Products
Search
Document Center

Blockchain as a Service:Contract Data Structure

Last Updated:Oct 17, 2024

Basic data types

The contract platform of Ant Blockchain supports almost all data types in Solidity. However, some user-defined input parameter types are not supported, for example, the two-dimensional arrays. The contract platform also provides the identity type that contains a 32-byte string to identify each user. The address type in Solidity is not supported.

We recommend that you use the following data types:

Type

Sample

Supported by the contract platform

Supported as an 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

Note
  • These data types are used within the contract.

  • Input parameters: The parameters passed in when a method is called on the client.

For example, in the issuance methods of the credit management contract, the identity type and the int256 type are both input parameter types and supported by the contract platform.

function Issue(identity account, int256 value)

The mapping declaration type corresponding to the user credits and the account ID can be used within a contract. However, the mapping declaration type cannot be used as an input type for a function. For example:

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

Other types

Solidity also supports other data types, including:

  • mapping

  • struct

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

For more information, see Data types supported in Solidity (English).