exSat Network
  • πŸ”—Important Links
  • 🌌Our Approach
    • What is exSat
      • exSat’s Docking Layer Approach
      • The Paradigm Shift of the Bitcoin Economic Ecosystem
      • Challenges Addressed by exSat
    • Architecture
      • Data Consensus Protocol
        • Network launch phases
        • Decentralized UTXO index
        • Synchronizers and Validators
        • Hybrid Consensus Mechanism
        • Decentralized execution
      • Decentralized Asset Custody (Coming soon)
      • Enhancing the Bitcoin Ecosystem with Smart Contract Capabilities
      • Expanding Possibilities with Rollups
    • $XSAT Tokenomics
      • Total Supply and Issuance
      • Rewards to Synchronizers and Validators
  • πŸ› οΈGuides of Data Consensus
    • Quick Start
    • UTXO Initialization
      • Data preparation
      • Analysis on the UTXO data tobe uploaded
      • Verify the data uploaded to exSat
    • Run a Sychronizer
      • Requirements for Synchronizers
      • Rewards for synchronizers
      • Run as Synchronizer
        • Run from source code
        • Run with Docker
    • Run a BTC Validator
      • Requirements and rewards for BTC Validators
      • Run as BTC validator
        • Run from source code
        • Run with docker
    • Run a XSAT Validator
      • Run as XSAT Validator
        • Run from source code
        • Run with docker
      • Run multiple XSAT Validators
    • Others
      • Operation references
        • Preparation Before You Start
          • Account Preparation
          • Run a BTC node
          • Environment requirements
          • Prerequisites
        • Synchronizer operations
          • Create New Synchronizer Account
          • Synchronizer Registration
          • Execute the synchronizer client
          • Revote For Consensus
          • Change Reward Address
          • Check and claim rewards for synchronizer
          • Update to new Docker version for Synchronizer
        • Validator operations
          • Create New BTC Validator Account
          • Create New XSAT Validator Account
          • Stake for Validator and claim rewards
          • Change Stake Address
          • Change Commission Address
          • Change Commission Ratio
          • Configure Display Information for Your Validator Account
          • Execute the validator client
          • Update to new Docker version for Validator
        • Common operations
          • Import from seed phrase
          • Import from Private Key
          • Set BTC RPC Node
          • Refill BTC for Gas Fees
          • Export private key
          • Remove Your Account
          • Upgrade to new version
          • View Logs
          • Environment variables
  • πŸ‘¨β€πŸ’»Developer Guides
    • Quick Start
    • Native Layer Developer Guides
      • exSat consensus contracts
        • Pool Register Contract
        • UTXO Management Contract
        • Reward Distribution Contract
        • Block Consensus Contract
        • Block Synchronization Contract
        • Validator Management Contract
        • Staking Contract
      • Run exSat native layer RPC Node
  • πŸ–₯️User Guides
    • Wallet Setup
    • Bridge Your Assets
    • Earn Rewards via BTC Staking
    • Explore Our Ecosystem
  • Popular Token Contract Addresses
  • πŸ“šReference
  • πŸ“¦Cutodian Guides
  • πŸ”Security Reports
    • Audit Report From Blocksec
  • πŸ”‘Terms and Conditions
    • Terms Of Service
    • Privacy Policy
  • 🎁PR & Press
  • ☎️Contact US
Powered by GitBook
On this page
  1. Developer Guides

Native Layer Developer Guides

PreviousQuick StartNextexSat consensus contracts

Last updated 2 months ago

Learn more about developing DApps on the Native Layer:

You can access the native layer using the or by .

Read data from contracts

exSat native layer stores data in tables, which are similar to database tables. Each table has a name and a set of fields. Tables are organized into scopes, which are defined by the smart contract that created the table.

To retrieve data from a table, you need to know its name, scope, and the name of the smart contract that created it. You can also specify a lower and upper bound to limit the amount of data returned.

To retrive data from a exSat native contract, all you need is :

  • A command-line interface to run curl commands.

  • Access to an exSat native layer RPC node. You could get the public here, or build your own RPC node.

  • The name of the contract, the table name, scope, and maybe the indexes.

use "get_table_rows" to get data from contract

The get_table_rows function retrieves rows from a table. It takes the following parameters in JSON format:

code

must

string

The name of the smart contract that controls the provided table

table

must

string

The name of the table to query

scope

must

string

The account to which this data belongs

index_position

optional

string

Position of the index used, accepted parameters primary, secondary, tertiary, fourth, fifth, sixth, seventh, eighth, ninth , tenth

key_type

optional

string

Type of key specified by index_position (for example - uint64_t or name)

encode_type

optional

string representing the encoded type of the key_type parameter, either dec or hex, defaults to dec.

lower_bound

optional

string

Filters results to return the first element that is not less than provided value in set

upper_bound

optional

string

Filters results to return the first element that is greater than provided value in set

limit

optional

integer <int32>Default: 10

Limit number of results returned.

reverse

optional

boolean Default: false

Reverse the order of returned results

show_payer

optional

boolean Default: false

Show RAM payer

Below is an example that retrieves rows from validators table, owned by the endrmng.xsat account and having endrmng.xsat as scope. which aims to get the registration information of the first validator.

curl --request POST \
--url https://rpc-sg.exsat.network/v1/chain/get_table_rows \
--header 'content-type: application/json'  \
--data '{ 
"json": true, 
"code": "endrmng.xsat", 
"scope": "endrmng.xsat", 
"table": "validators", 
"lower_bound": "0", 
"limit": 1, 
"reverse": false 
}'

In the example above:

  • The rows values are returned as JSON, set by the json parameter.

  • The table is owned by the account endrmng.xsat, set by the code parameter.

  • The table scope is endrmng.xsat, set by the scope parameter.

  • The table name is validators, set by the table parameter.

  • The query uses the primary index to search the rows and starts from the lower bound index value, set by the lower_bound parameter.

  • The function will fetch a maximum of 1 rows, set by the limit parameter.

  • The retrieved rows will be in ascending order, set by the reverse parameter.

The JSON returned by the get_table_rows has the following structure:

{
  "rows": [
    { },
    ...
    { }
  ],
  "more": true,
  "next_key": ""
}

The "rows" field is an array of table row objects in JSON representation. The "more" field indicates that there are additional rows beyond the ones returned. The "next_key" field contains the key to be used as the lower bound in the next request to retrieve the next set of rows.

For example, the result from the previous section command contains one row, and looks similar to the one below (for privacy, the sensitive informations of the validator is replaced by "-":

{
    "rows": [
        {
            "owner": "-----.sat",
            "reward_recipient": "erc2o.xsat",
            "memo": "0x--------------------",
            "commission_rate": 1000,
            "quantity": "0.00000000 BTC",
            "qualification": "0.00000000 BTC",
            "xsat_quantity": "0.00000000 XSAT",
            "donate_rate": 0,
            "total_donated": "0.00000000 XSAT",
            "stake_acc_per_share": "0",
            "consensus_acc_per_share": "0",
            "staking_reward_unclaimed": "0.00000000 XSAT",
            "staking_reward_claimed": "0.00000000 XSAT",
            "consensus_reward_unclaimed": "0.00000000 XSAT",
            "consensus_reward_claimed": "0.00000000 XSAT",
            "total_consensus_reward": "0.00000000 XSAT",
            "consensus_reward_balance": "0.00000000 XSAT",
            "total_staking_reward": "0.00000000 XSAT",
            "staking_reward_balance": "0.00000000 XSAT",
            "latest_staking_time": "1970-01-01T00:00:00",
            "latest_reward_block": 0,
            "latest_reward_time": "1970-01-01T00:00:00",
            "disabled_staking": 0
        }
    ],
    "more": true,
    "next_key": "3815492618318908816"
}

The get_table_rows Result

πŸ‘¨β€πŸ’»
​
Introduction to Spring
Developing Smart Contracts on the Native Layer
Interacting with Smart Contracts via SDK
Interacting with exSat via RESTful API
running your own RPC node
RPC node provided by exSat
RPC node