# Native Layer Developer Guides

Learn more about developing DApps on the Native Layer:

* [Introduction to Spring](https://docs.eosnetwork.com/docs/latest/quick-start/introduction)
* [Developing Smart Contracts on the Native Layer](https://docs.eosnetwork.com/docs/latest/smart-contracts/contract-anatomy)
* [Interacting with Smart Contracts via SDK](https://docs.eosnetwork.com/docs/latest/web-applications/beginner-concepts)
* [Interacting with exSat via RESTful API](https://docs.eosnetwork.com/apis/spring/latest/)

You can access the native layer using the [RPC node provided by exSat ](https://docs.exsat.network/important-links#native-layer-of-exsat-mainnet)or by [running your own RPC node](https://docs.exsat.network/developer-guides/native-layer-developer-guides/run-exsat-native-layer-rpc-node).

### 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.&#x20;

To retrive data from a exSat native contract, all you need is :&#x20;

* A command-line interface to run curl commands.
* Access to an exSat native layer RPC node.\
  You could get the public [RPC node](https://docs.exsat.network/important-links#native-layer-of-exsat-mainnet) 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:

<table data-header-hidden><thead><tr><th width="164">Name</th><th width="95">Needed</th><th>Description</th></tr></thead><tbody><tr><td>code</td><td>must</td><td><p>string</p><p>The name of the smart contract that controls the provided table</p></td></tr><tr><td>table</td><td>must</td><td><p>string</p><p>The name of the table to query</p></td></tr><tr><td>scope</td><td>must</td><td><p>string</p><p>The account to which this data belongs</p></td></tr><tr><td>index_position</td><td>optional</td><td><p>string</p><p>Position of the index used, accepted parameters <code>primary</code>, <code>secondary</code>, <code>tertiary</code>, <code>fourth</code>, <code>fifth</code>, <code>sixth</code>, <code>seventh</code>, <code>eighth</code>, <code>ninth</code> , <code>tenth</code></p></td></tr><tr><td>key_type</td><td>optional</td><td><p>string</p><p>Type of key specified by index_position (for example - <code>uint64_t</code> or <code>name</code>)</p></td></tr><tr><td>encode_type</td><td>optional</td><td>string<br>representing the encoded type of the key_type parameter, either <code>dec</code> or <code>hex</code>, defaults to <code>dec</code>.</td></tr><tr><td>lower_bound</td><td>optional</td><td><p>string</p><p>Filters results to return the first element that is not less than provided value in set</p></td></tr><tr><td>upper_bound</td><td>optional</td><td><p>string</p><p>Filters results to return the first element that is greater than provided value in set</p></td></tr><tr><td>limit</td><td>optional</td><td><p>integer &#x3C;int32>Default: 10</p><p>Limit number of results returned.</p></td></tr><tr><td>reverse</td><td>optional</td><td><p>boolean Default: false</p><p>Reverse the order of returned results</p></td></tr><tr><td>show_payer</td><td>optional</td><td><p>boolean Default: false</p><p>Show RAM payer</p></td></tr></tbody></table>

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 get\_table\_rows Result**[**​**](https://docs.eosnetwork.com/docs/latest/web-applications/reading-state#the-get_table_rows-result)

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"
}
```
