Smartcontract Data

Explains each data type that Blockchain uses, and how to convert your data into Smartcontract Data Type

The EVM (Ethereum Virtual Machine) uses the data types that are different than JS/TS provided data types.

Those data types are represented as SmartcontractDataTypes module.


There are following data types that are most often used by the smartcontracts. There are represented as the uppercase constants.

  • UINT8 - Unsigned 1 byte (8 bits) integer.

  • UINT256 - Unsigned 32 bytes (256 bits) integer. It's a very large data type, that's enough to store number for each Atom in a whole universe. Amazing isn't it?

  • ADDRESS - A 20 bytes (160 bits) long data type used to store the Account or Smartcontract addresses.

  • DECIMAL_18 - Smartcontracts doesn't support the floating numbers. Instead they are stored usually as a large Unsigned 32 bytes integer. But, the first 144 bits of the integer is used to represent the number before the dot, and the second 144 bits of the integer is used to represent the floating part of the number.

  • DECIMAL_6 - Some stable coins use 208 bits to represent the integer part, and 48 bits of 32 bytes they use to represent the floating part.

  • RAW - Raw hex string that starts with '0x'. It could be used if you want to pass the string or bytes sequence to the smartcontract.


The section above explained what kind of data types the Seascape SDK supports.

The SmartcontractData module is used to keep the smartcontract variant of the data from the JS/TS.

How to use SmartcontractData to convert the JS/TS data into the blockchain data type? The SmartcontractData module is a class, that you can to create the object.

The object accepts two parameters, the first parameter is the SmartcontractDataTypes, and the second one is the value in JS/TS that the module will convert during the instantiniation of the SmartcontractData.

import { SmartcontractDataTypes as TYPES, SmartcontractData } from "seascape";

// exmaple data
let ageNumber = 27; // Twenty seven years old.
let randomString = "0x0d0f0fcdcb";
let feeFloat = 1.5;  // 1.5 tokens

let age = new SmartcontractData(TYPES.UINT8, ageNumber);
let random = new SmartcontractData(TYPES.RAW, randomString);
let fee = new SmartcontractData(TYPES.DECIMAL_18, feeFloat as Number);

The SmartcontractData has the following helpful properties and methods:

  • hex (String type) - a smartcontract datatype as a hex string, its a converted JS/TS datatype.

  • hash() - the unique hash of the smartcontract data.

  • SmartcontractData.concat ( Array<SmartcontractData> ) - a static function that concatinates the data as a single hex string in SmartcontractDataTypes.RAW format.

Last updated