Seascape Network
EN
EN
  • Welcome to Seascape
  • Guides
    • How to use the Scape Store Swapping Feature
    • How to Play Profit Circus
    • Guide to NFT Brawl
    • Guide to Staking Saloon
    • Guide to Scape Forum
    • Guide to Zombie Farm
    • Bridge Your MSCP between MOVR and BSC
    • Guide to join the pCWS Pools and NFT Trading
  • SMARTCONTRACTS
    • Addresses
      • Lighthouse
      • Changelog
    • Installation
    • Seascape NFT (SCAPES)
    • Crowns (CWS) token
  • Game for Developers
    • API Urls
    • Seascape Nft
    • Game 2: NFT BRAWL
      • Leaderboard
    • Game 5: Zombie Farm
      • Glossary
      • Reward categories
      • Option categories
      • API call order
  • Scape Store (Marketplace)
    • Config
    • Nft Swap
    • RPC backend
    • Smartcontract Changelog
  • API changelog
  • Seadex
    • Intro
    • Local deployment
    • Addresses
    • Managing Token
      • Add supported token to Factory
  • Lighthouse (IDO)
    • API
    • Smartcontrontracts
      • Tiers
    • Installation
  • Seascape SDK
    • Intro
    • Installation
    • Features
      • Shared Smartcontract Parameters
        • Configuration Format
        • Seascape CDN Config
        • CdnWrite
          • Truffle Framework
          • Hardhat Framework
          • Non-framework update
        • CDN Read
      • Server Proof
        • Smartcontract Data
        • Proof of Server
Powered by GitBook
On this page
  • SmartcontractDataTypes
  • SmartcontractData

Was this helpful?

  1. Seascape SDK
  2. Features
  3. Server Proof

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.

SmartcontractDataTypes

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.

SmartcontractData

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.

PreviousServer ProofNextProof of Server

Last updated 2 years ago

Was this helpful?