> For the complete documentation index, see [llms.txt](https://orbits-1.gitbook.io/orbits/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://orbits-1.gitbook.io/orbits/technology/rollup-data-restore.md).

# Rollup data restore

All transaction data on the shard chain has full data visibility on the beacon chain, so anyone is able to restore the data on the shard chain without permission. The process of data restoration involves rebuilding the Genesis root node by getting records from the beacon chain based on the Genesis hash, and then restoring the state tree and all rollup transactions based on `transaction.input`. The details are as follows.

### Restore the Genesis Root Node <a href="#restore-the-genesis-root-node" id="restore-the-genesis-root-node"></a>

All the operations of the sharded chain are stored in `transaction.input` on the base chain. We can get the record of Genesis hash to reconstruct the Genesis root node information by the eth\_getTransactionByHash method, which is stored from the `transaction.input.0` `commitment` field to extract the 6 smart contract addresses.

```
transaction.input=[
{
    _blocknumber: unit32
    _priority_operations: uint32
    _pending_onchain_operations_hash: bytes32
    _timestamp: unit256
    _state_hash: bytes32
    _commitment: bytes32
},
[{
    _encoded_root : bytes32
    _calldata: bytes (public_data)
    _timestamp: unit256
    _eth_witness: bytes
    _blocknumber: uint32
    _feeaccount: uint32
}]
]

transaction.input[0]._commitment = 6 * INPUT_DATA_ADDRESS_BYTES_WIDTH(32) + INPUT_DATA_ROOT_HASH_BYTES_WIDTH(32)
```

### Restore Rollup Transaction Data <a href="#restore-rollup-transaction-data" id="restore-rollup-transaction-data"></a>

The `calldata` field of `transaction.input.1` contains the original compressed data of all blocks of the shard chain, which can restore all transaction data.

`transaction.input[1]._calldata = tx_type | chips * chip_bytes(10bytes)`

#### DepositTx structure <a href="#deposittx-structure" id="deposittx-structure"></a>

| tx\_type | chips |
| -------- | ----- |
| 0x01     | 6     |

| account\_id  | token        | amount        | to             |
| ------------ | ------------ | ------------- | -------------- |
| 1 \~ 5 bytes | 5 \~ 9 bytes | 9 \~ 25 bytes | 25 \~ 45 bytes |

#### TransferToNewAddrTx & TransferToNewAddrNFTTx structure <a href="#transfertonewaddrtx-transfertonewaddrnfttx-structure" id="transfertonewaddrtx-transfertonewaddrnfttx-structure"></a>

| tx\_type | chips |
| -------- | ----- |
| 0x02     | 6     |

| from\_id     | token        | amount        | to             | to\_id         | fee            |
| ------------ | ------------ | ------------- | -------------- | -------------- | -------------- |
| 1 \~ 5 bytes | 5 \~ 9 bytes | 9 \~ 14 bytes | 14 \~ 34 bytes | 34 \~ 38 bytes | 38 \~ 40 bytes |

#### WithdrawTx structure <a href="#withdrawtx-structure" id="withdrawtx-structure"></a>

| tx\_type | chips |
| -------- | ----- |
| 0x03     | 6     |

| account\_id  | token        | amount        | fee            | to             |
| ------------ | ------------ | ------------- | -------------- | -------------- |
| 1 \~ 5 bytes | 5 \~ 9 bytes | 9 \~ 13 bytes | 25 \~ 27 bytes | 27 \~ 47 bytes |

#### TransferTx & TransferNFTTx structure <a href="#transfertx-transfernfttx-structure" id="transfertx-transfernfttx-structure"></a>

| tx\_type | chips |
| -------- | ----- |
| 0x05     | 2     |

| account\_id  | token        | to            | amount         | fee            |
| ------------ | ------------ | ------------- | -------------- | -------------- |
| 1 \~ 5 bytes | 5 \~ 9 bytes | 9 \~ 13 bytes | 13 \~ 18 bytes | 18 \~ 20 bytes |

#### FullWithdrawTx & FullWithdrawNFTTx structure <a href="#fullwithdrawtx-fullwithdrawnfttx-structure" id="fullwithdrawtx-fullwithdrawnfttx-structure"></a>

| tx\_type | chips |
| -------- | ----- |
| 0x06     | 11    |

| account\_id  | eth\_address  | token          | amount         | creator\_address | content\_hash  |
| ------------ | ------------- | -------------- | -------------- | ---------------- | -------------- |
| 1 \~ 5 bytes | 5 \~ 25 bytes | 25 \~ 29 bytes | 29 \~ 45 bytes | 45 \~ 65 bytes   | 65 \~ 97 bytes |

#### UpdatePublicKeyTx structure <a href="#updatepublickeytx-structure" id="updatepublickeytx-structure"></a>

| tx\_type | chips |
| -------- | ----- |
| 0x07     | 6     |

| account\_id  | new\_pk\_hash | account        | nonce          | fee\_token     | fee            |
| ------------ | ------------- | -------------- | -------------- | -------------- | -------------- |
| 1 \~ 5 bytes | 5 \~ 25 bytes | 25 \~ 45 bytes | 45 \~ 49 bytes | 49 \~ 53 bytes | 53 \~ 55 bytes |

#### ForcedWithdrawTx structure <a href="#forcedwithdrawtx-structure" id="forcedwithdrawtx-structure"></a>

| tx\_type | chips |
| -------- | ----- |
| 0x08     | 6     |

| initiator\_account\_id | target\_account\_id | token         | amount         | fee            | target         |
| ---------------------- | ------------------- | ------------- | -------------- | -------------- | -------------- |
| 1 \~ 5 bytes           | 5 \~ 9 bytes        | 9 \~ 13 bytes | 13 \~ 29 bytes | 29 \~ 31 bytes | 31 \~ 51 bytes |

#### MintNFTTx structure <a href="#mintnfttx-structure" id="mintnfttx-structure"></a>

| tx\_type | chips |
| -------- | ----- |
| 0x09     | 5     |

| creator\_account\_id | recipient\_account\_id | content\_hash | fee\_token\_id | fee            |
| -------------------- | ---------------------- | ------------- | -------------- | -------------- |
| 1 \~ 5 bytes         | 5 \~ 9 bytes           | 9 \~ 41 bytes | 41 \~ 45 bytes | 45 \~ 47 bytes |

#### WithdrawNFTTx structure <a href="#withdrawnfttx-structure" id="withdrawnfttx-structure"></a>

| tx\_type | chips |
| -------- | ----- |
| 0x0a     | 10    |

| account\_id  | creator\_id  | creator\_address | serial\_id     | content\_hash  | to             | token          | token\_fee     | fee            |
| ------------ | ------------ | ---------------- | -------------- | -------------- | -------------- | -------------- | -------------- | -------------- |
| 1 \~ 5 bytes | 5 \~ 9 bytes | 9 \~ 29 bytes    | 29 \~ 33 bytes | 33 \~ 65 bytes | 65 \~ 85 bytes | 85 \~ 89 bytes | 89 \~ 93 bytes | 93 \~ 95 bytes |

#### SwapTx & SwapNFTTx structure <a href="#swaptx-swapnfttx-structure" id="swaptx-swapnfttx-structure"></a>

| tx\_type | chips |
| -------- | ----- |
| 0x0b     | 5     |

| account\_id\_0 | recipient\_id\_0 | account\_id\_1 | recipient\_id\_1 | submitter\_id  | token\_0       | token\_1       | fee\_token    | amount\_0      | amount\_1      | fee            | swap\_fee\_0 | swap\_fee\_1   | nonce          |
| -------------- | ---------------- | -------------- | ---------------- | -------------- | -------------- | -------------- | ------------- | -------------- | -------------- | -------------- | ------------ | -------------- | -------------- |
| 1 \~ 5 bytes   | 5 \~ 9 bytes     | 9 \~ 13 bytes  | 13 \~ 17 bytes   | 17 \~ 21 bytes | 21 \~ 25 bytes | 25 \~ 29 bytes | 29 \~ 33 byte | 33 \~ 38 bytes | 38 \~ 43 bytes | 43 \~ 45 bytes | 45\~47 bytes | 47 \~ 49 bytes | 49 \~ 49 bytes |
