View

View Api

Execute view function of a module

post

Example

{
"function": "0x1::timestamp::now_microseconds",
"type_arguments": [],
"arguments": []
}
Body
functionstringRequired

Entry function id is string representation of a entry function defined on-chain.

Format: {address}::{module name}::{function name}

Both module name and function name are case-sensitive.

type_argumentsstring[]Required

Vector of Move type tag. The Move type tag string representation as below: Values:

  • bool
  • u8
  • u16
  • u32
  • u64
  • u128
  • u256
  • address
  • signer
  • vector: vector<{non-reference MoveTypeId}>
  • struct: {address}::{module_name}::{struct_name}::<{generic types}>

Vector type value examples:

  • vector<u8>
  • vector<vector<u64>>
  • vector<0x1::coin::CoinStore<0x1::supra_coin::SupraCoin>>

Struct type value examples:

  • `0x1::coin::CoinStore<0x1::supra_coin::SupraCoin>
  • 0x1::account::Account

Note:

  1. Empty chars should be ignored when comparing 2 struct tag ids.
  2. When used in an URL path, should be encoded by url-encoding (AKA percent-encoding).
Responses
200
Result of view function
application/json
Responseall of | nullable
post
POST /rpc/v1/view HTTP/1.1
Host: rpc-mainnet.supra.com
Content-Type: application/json
Accept: */*
Content-Length: 60

{
  "function": "text",
  "type_arguments": [
    "text"
  ],
  "arguments": []
}
200

Result of view function

{
  "result": [
    {
      "U8": 1
    }
  ]
}