Icon LinkStoring Info in a Database

The Fuel indexer uses PostgreSQL Icon Link as the primary database.

💡 We're open to supporting other storage solutions in the future.

Icon LinkData Types

Below is a mapping of GraphQL schema types to their Sway and database equivalents. Note that an empty cell denotes that there is no direct equivalent for the type in the corresponding domain.

GraphQL ScalarSway TypePostgres Type
Addressb256varchar(64)
AssetIdu8[32]varchar(64)
Blobstr[]varchar(10485760)
BlockIdvarchar(64)
Booleanboolboolean
Bytes4str[4]varchar(8)
Bytes8str[8]varchar(16)
Bytes32str[32]varchar(64)
Bytes64str[64]varchar(128)
Charfieldstr[]varchar(255)
ContractIdb256varchar(64)
HexStringstr[]varchar(10485760)
IDvarchar(64) primary key
Int1u8integer
Int4u32integer
Int8u64bigint
Int16numeric(39,0)
Jsonstr[]json
MessageIdstr[32]varchar(64)
Noncestr[32]varchar(64)
Saltstr[32]varchar(64)
Signaturestr[64]varchar(128)
Tai64Timestampvarchar(128)
Timestampu64timestamp
UIDvarchar(64)
UInt1u8integer
UInt4u32integer
UInt8u64numeric(20, 0)
UInt16numeric(39, 0)
Virtualjson

Icon LinkExample

Let's define an Event struct in a Sway contract:

struct Event {
    id: u64,
    address: Address,
    block_height: u64,
}

The corresponding GraphQL schema to mirror this Event struct would resemble:

type Event @entity {
    id: ID!
    account: Address!
    block_height: UInt8!
}

And finally, this GraphQL schema will generate the following Postgres schema:

                                           Table "schema.event"
    Column   |     Type    | Collation | Nullable | Default | Storage  | Compression | Stats target | Description
--------------+-------------+-----------+----------+---------+----------+-------------+--------------+-------------
 id           |    bigint   |           | not null |         | plain    |             |              |
 block_height |    bigint   |           | not null |         | plain    |             |              |
 address      | varchar(64) |           | not null |         | plain    |             |              |
 object       |    bytea    |           | not null |         | extended |             |              |
Indexes:
    "event_pkey" PRIMARY KEY, btree (id)
Access method: heap

Was this page helpful?

Icon ListDetailsOn this page