
# Module XDPoS

## Method XDPoS_getBlockInfoByEpochNum

Parameters:

- epochNumber: integer, required, epoch number

Returns:

result: object EpochNumInfo:

- hash: hash of first block in this epoch
- round: round of epoch
- firstBlock: number of first block in this epoch
- lastBlock: number of last block in this epoch

Example:

```shell
epoch=89300

curl -s -X POST -H "Content-Type: application/json" ${RPC} -d '{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "XDPoS_getBlockInfoByEpochNum",
  "params": [
    '"${epoch}"'
  ]
}' | jq
```

Response:

```json
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "hash": "0x5a701a8ba642a9b53475bb19cb9a313829f7afb4287caa76bebaea02f0219f89",
    "round": 1,
    "firstBlock": 80370001,
    "lastBlock": 80370838
  }
}
```


## Method XDPoS_getEpochNumbersBetween

Parameters:

- begin: string, required, block number
- end: string, required, block number

Returns:

result: array of uint64

Example:

```shell
curl -s -X POST -H "Content-Type: application/json" ${RPC} -d '{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "XDPoS_getEpochNumbersBetween",
  "params": [
    "0x5439860",
    "0x5439c48"
  ]
}' | jq
```

Response:

```json
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": [
    88316769
  ]
}
```


## Method XDPoS_getLatestPoolStatus

The `XDPoS_getLatestPoolStatus` method retrieves current vote pool and timeout pool content and missing messages.

Parameters:

None

Returns:

result: object MessageStatus

- vote:    object
- timeout: object

Example:

```shell
curl -s -X POST -H "Content-Type: application/json" ${RPC} -d '{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "XDPoS_getLatestPoolStatus"
}' | jq
```

Response:

See [XDPoS_getLatestPoolStatus_response.json](./XDPoS_getLatestPoolStatus_response.json)

## Method XDPoS_getMasternodesByNumber

Parameters:

- number: string, required, BlockNumber

Returns:

result: object MasternodesStatus:

- Number:          uint64
- Round:           uint64
- MasternodesLen:  int
- Masternodes:     array of address
- PenaltyLen:      int
- Penalty:         array of address
- StandbynodesLen: int
- Standbynodes:    array of address
- Error:           string

Example:

```shell
curl -s -X POST -H "Content-Type: application/json" ${RPC} -d '{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "XDPoS_getMasternodesByNumber",
  "params": [
    "latest"
  ]
}' | jq
```

Response:

```json
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "Epoch": 89300,
    "Number": 0,
    "Round": 0,
    "MasternodesLen": 0,
    "Masternodes": [],
    "PenaltyLen": 0,
    "Penalty": [],
    "StandbynodesLen": 0,
    "Standbynodes": [],
    "Error": null
  }
}
```


## Method XDPoS_getMissedRoundsInEpochByBlockNum

Parameters:

- number: string, required, BlockNumber

Returns:

result: object PublicApiMissedRoundsMetadata:

- EpochRound:       uint64
- EpochBlockNumber: big.Int
- MissedRounds:     array of MissedRoundInfo

MissedRoundInfo:

- Round:            uint64
- Miner:            address
- CurrentBlockHash: hash
- CurrentBlockNum:  big.Int
- ParentBlockHash:  hash
- ParentBlockNum:   big.Int

Example:

```shell
curl -s -X POST -H "Content-Type: application/json" ${RPC} -d '{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "XDPoS_getMissedRoundsInEpochByBlockNum",
  "params": [
    "latest"
  ]
}' | jq
```

Response:

```json
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "EpochRound": 12134700,
    "EpochBlockNumber": 92336811,
    "MissedRounds": [
      {
        "Round": 12135188,
        "Miner": "0xe230905c99aaa7b68402af8611b89ceda743191e",
        "CurrentBlockHash": "0xbb587da87991d3cb0122e3f79c31202387022343ce4d317545ec4d676f3199fa",
        "CurrentBlockNum": 92337295,
        "ParentBlockHash": "0xd58572701671c51afa1a0f92d8eb3f59e52418f5d3fe1e08765c5b15970c26e3",
        "ParentBlockNum": 92337294
      },
      {
        "Round": 12135108,
        "Miner": "0x5454edee66858dfcc14871cc8b26f57ef528bedc",
        "CurrentBlockHash": "0x94c8ddc157a095f9f726341fdb0d46ccbced72ce352b1d583dc6a32c285c6f9c",
        "CurrentBlockNum": 92337216,
        "ParentBlockHash": "0x4ff8ad273546a982e533f2613e985eb3f5f2606e26d91011d7f555a19e88795b",
        "ParentBlockNum": 92337215
      },
      {
        "Round": 12134762,
        "Miner": "0xbbd2d417a8b6f1b1d7a267cd1d7402b443f35cfe",
        "CurrentBlockHash": "0x9fc78684a5f7fe80d60e3c6f5acf4fd3dde3c96757e1ba18c8f4f13e4e7523d0",
        "CurrentBlockNum": 92336871,
        "ParentBlockHash": "0x0ad9c7848d2464dc3886af083a06dc097f70549a046db8ebd42a233bc02934af",
        "ParentBlockNum": 92336870
      },
      {
        "Round": 12134747,
        "Miner": "0x03d9e17ae3ff2c6712e44e25b09ac5ee91f6c9ff",
        "CurrentBlockHash": "0xed4bfc8af63bdd3f9463a03aac3f3f245401a00bf1fdc126aa4f12fbd5fc3b9a",
        "CurrentBlockNum": 92336857,
        "ParentBlockHash": "0xf4ac8db092ee7d4e65d94691af22cf68b024e09c71d71899fec17b266ac16c8e",
        "ParentBlockNum": 92336856
      },
      {
        "Round": 12134704,
        "Miner": "0x2a591f3d64f3ce6b1d2afeead839ad76aab9feb2",
        "CurrentBlockHash": "0x248452a594feb9cd63bfadc5b2d9a4cdaa3c3a5f9e73275171a102693cf9f20c",
        "CurrentBlockNum": 92336815,
        "ParentBlockHash": "0x2e250ff73aab4fc9205c300f544926f7544a6e6193f1a1f5360cc2f8c5f3aaaa",
        "ParentBlockNum": 92336814
      }
    ]
  }
}
```


## Method XDPoS_getSigners

The `getSigners` method retrieves the list of authorized signers at the specified block.

Parameters:

- number: string, required, BlockNumber

Returns:

result: array of address

Example:

```shell
curl -s -X POST -H "Content-Type: application/json" ${RPC} -d '{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "XDPoS_getSigners",
  "params": [
    "latest"
  ]
}' | jq
```

Response:

See [XDPoS_getSigners_response.json](./XDPoS_getSigners_response.json)


## Method XDPoS_getSignersAtHash

The `getSignersAtHash` method retrieves the state snapshot at a given block.

Parameters:

- hash: string, required, block hash

Returns:

same as `XDPoS_getSigners`

Example:

```shell
hash=0x5a701a8ba642a9b53475bb19cb9a313829f7afb4287caa76bebaea02f0219f89
curl -s -X POST -H "Content-Type: application/json" ${RPC} -d '{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "XDPoS_getSignersAtHash",
  "params": [
    "'"${hash}"'"
  ]
}' | jq
```

Response:

See [XDPoS_getSignersAtHash_response.json](./XDPoS_getSignersAtHash_response.json)


## Method XDPoS_getSnapshot

The `getSnapshot` method retrieves the state snapshot at a given block.

Parameters:

- number: string, required, BlockNumber

Returns:

result: object PublicApiSnapshot:

- number:  block number where the snapshot was created
- hash:    block hash where the snapshot was created
- signers: array of authorized signers at this moment
- recents: array of recent signers for spam protections
- votes:   list of votes cast in chronological order
- tally:   current vote tally to avoid recalculating

Example:

```shell
curl -s -X POST -H "Content-Type: application/json" ${RPC} -d '{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "XDPoS_getSnapshot",
  "params": [
    "latest"
  ]
}' | jq
```

Response:

See [XDPoS_getSnapshot_response.json](./XDPoS_getSnapshot_response.json)


## Method XDPoS_getSnapshotAtHash

The `getSnapshotAtHash` method retrieves the state snapshot at a given block.

Parameters:

- hash: string, required, block hash

Returns:

same as `XDPoS_getSnapshot`

Example:

```shell
hash=0x5a701a8ba642a9b53475bb19cb9a313829f7afb4287caa76bebaea02f0219f89
curl -s -X POST -H "Content-Type: application/json" ${RPC} -d '{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "XDPoS_getSnapshotAtHash",
  "params": [
    "'"${hash}"'"
  ]
}' | jq
```

Response:

See [XDPoS_getSnapshotAtHash_response.json](./XDPoS_getSnapshotAtHash_response.json)


## Method XDPoS_getV2BlockByHash

Parameters:

- hash: string, required, block hash

Returns:

same as `XDPoS_getV2BlockByNumber`

Example:

```shell
curl -s -X POST -H "Content-Type: application/json" ${RPC} -d '{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "XDPoS_getV2BlockByHash",
  "params": [
    "'"${hash}"'"
  ]
}' | jq
```

Response:

```json
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "Hash": "0x5a701a8ba642a9b53475bb19cb9a313829f7afb4287caa76bebaea02f0219f89",
    "Round": 1,
    "Number": 80370001,
    "ParentHash": "0x83b8e385682ca0faa29e0cc4dbf7de08512ec36bc7d4f0cf173ca5a6dbf034dc",
    "Committed": true,
    "Miner": "0x000000000000000000000000047ffe1fc7f6d0b7168c4ccc312221089629f470",
    "Timestamp": 1727714247,
    "EncodedRLP": " ",
    "Error": ""
  }
}
```


## Method XDPoS_getV2BlockByNumber

Parameters:

- number: string, required, BlockNumber

Returns:

result: object V2BlockInfo:

- Hash:       hash
- Round:      uint64
- Number:     big.Int
- ParentHash: hash
- Committed:  bool
- Miner:      common.Hash
- Timestamp:  big.Int
- EncodedRLP: string
- Error:      string

Example:

```shell
curl -s -X POST -H "Content-Type: application/json" ${RPC} -d '{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "XDPoS_getV2BlockByNumber",
  "params": [
    "latest"
  ]
}' | jq
```

Response:

```json
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "Hash": "0x7f809fffd6b2dfb72374be8a58d66a9215e64561fdf907136196108ae8af4113",
    "Round": 11796106,
    "Number": 92002679,
    "ParentHash": "0xb9f8065697575a03dde30fae631b957b4f81cdd0f919a6be558417b57c6461f6",
    "Committed": false,
    "Miner": "0x000000000000000000000000d22fdac1459760f698618d927bbe22249e2b29b9",
    "Timestamp": 1754450490,
    "EncodedRLP": " ",
    "Error": ""
  }
}
```


## Method XDPoS_networkInformation

Parameters:

None

Returns:

result: object NetworkInformation:

- NetworkId:                  big.Int
- XDCValidatorAddress:        address
- RelayerRegistrationAddress: address
- XDCXListingAddress:         address
- XDCZAddress:                address
- LendingAddress:             address
- ConsensusConfigs:           object of XDPoSConfig

Example:

```shell
curl -s -X POST -H "Content-Type: application/json" ${RPC} -d '{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "XDPoS_networkInformation"
}' | jq
```

Response:

```json
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "NetworkId": 50,
    "XDCValidatorAddress": "0x0000000000000000000000000000000000000088",
    "RelayerRegistrationAddress": "0x16c63b79f9c8784168103c0b74e6a59ec2de4a02",
    "XDCXListingAddress": "0xde34dd0f536170993e8cff639ddffcf1a85d3e53",
    "XDCZAddress": "0x8c0faeb5c6bed2129b8674f262fd45c4e9468bee",
    "LendingAddress": "0x7d761afd7ff65a79e4173897594a194e3c506e57",
    "ConsensusConfigs": {
      "period": 2,
      "epoch": 900,
      "reward": 5000,
      "rewardCheckpoint": 900,
      "gap": 450,
      "foudationWalletAddr": "0x92a289fe95a85c53b8d0d113cbaef0c1ec98ac65",
      "SkipV1Validation": false,
      "v2": {
        "switchBlock": 80370000,
        "config": {
          "maxMasternodes": 108,
          "switchRound": 3200000,
          "minePeriod": 2,
          "timeoutSyncThreshold": 3,
          "timeoutPeriod": 10,
          "certificateThreshold": 0.667
        },
        "allConfigs": {
          "0": {
            "maxMasternodes": 108,
            "switchRound": 0,
            "minePeriod": 2,
            "timeoutSyncThreshold": 3,
            "timeoutPeriod": 30,
            "certificateThreshold": 0.667
          },
          "2000": {
            "maxMasternodes": 108,
            "switchRound": 2000,
            "minePeriod": 2,
            "timeoutSyncThreshold": 2,
            "timeoutPeriod": 600,
            "certificateThreshold": 0.667
          },
          "220000": {
            "maxMasternodes": 108,
            "switchRound": 220000,
            "minePeriod": 2,
            "timeoutSyncThreshold": 2,
            "timeoutPeriod": 30,
            "certificateThreshold": 0.667
          },
          "3200000": {
            "maxMasternodes": 108,
            "switchRound": 3200000,
            "minePeriod": 2,
            "timeoutSyncThreshold": 3,
            "timeoutPeriod": 10,
            "certificateThreshold": 0.667
          },
          "460000": {
            "maxMasternodes": 108,
            "switchRound": 460000,
            "minePeriod": 2,
            "timeoutSyncThreshold": 2,
            "timeoutPeriod": 20,
            "certificateThreshold": 0.667
          },
          "8000": {
            "maxMasternodes": 108,
            "switchRound": 8000,
            "minePeriod": 2,
            "timeoutSyncThreshold": 2,
            "timeoutPeriod": 60,
            "certificateThreshold": 0.667
          }
        },
        "SkipV2Validation": false
      }
    }
  }
}
```

