> For the complete documentation index, see [llms.txt](https://docs.ramestta.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.ramestta.com/welcome-to-ramestta/bridge/core/ramestta-to-polygon.md).

# Ramestta To Polygon

The process of transferring data from Ramestta to Polygon, involving RAMA instead of MATIC, and Ramestta Testnet in place of Mumbai, follows a specific mechanism facilitated by checkpoint transactions and validation by Validators. Here is a detailed explanation of the process:

#### Data Transfer Mechanism from Ramestta to Polygon

1. **Transaction Creation on Ramestta:**
   * Execute a transaction on the child contract deployed on Ramestta, emitting an event that includes the data intended for transfer to Polygon.
   * The data is encoded in bytes and emitted in the event.
2. **Checkpoints by Validators:**
   * Validators on the Ramestta network pick up the transaction at specific intervals (typically 10-30 minutes), validate it, and add it to the checkpoint on Polygon.
3. **Checkpointing on Polygon:**
   * Validators create a checkpoint transaction on the RootChain contract in Polygon, ensuring the inclusion of the Ramestta transaction hash.
   * The rama.js(coming soon) library can be used to check the checkpoint addition.
4. **RootChainManager Contract:**
   * After checkpointing, submit the hash of the Ramestta transaction to the RootChainManager contract on Polygon as proof.
   * The RootChainManager contract validates the transaction, confirms its inclusion in the checkpoint, and decodes the event logs.
5. **Predicate Contract Usage:**
   * Utilize a Predicate contract, triggered only by the RootChainManager contract, to secure state changes on Polygon.
   * The state changes on Polygon occur only when the Ramestta transaction is checkpointed and verified by the RootChainManager contract.

#### Overview:

* A transaction is executed on the child contract on Ramestta, emitting an event with the data to transfer.
* Validators validate and checkpoint the transaction on Polygon.
* The rama.js library is used to trigger the exit function of the RootChainManager contract, ensuring secure state changes on Polygon.

#### Implementation:

1. **Child Contract (Ramestta):**

```solidity
contract Child {
    event Data(address indexed from, bytes bytes_data);
    uint256 public data;

    function setData(bytes memory bytes_data) public {
        data = abi.decode(bytes_data, (uint256));
        emit Data(msg.sender, bytes_data);
    }
}
```

2. **Root Contract (Polygon):**

```solidity
contract Root {
    address public predicate;

    constructor(address _predicate) public {
        predicate = _predicate;
    }

    modifier onlyPredicate() {
        require(msg.sender == predicate);
        _;
    }

    uint256 public data;

    function setData(bytes memory bytes_data) public onlyPredicate {
        data = abi.decode(bytes_data, (uint256));
    }
}
```

#### Mapping Contracts:

* Deploy these contracts on Ramestta and Polygon.
* Use the PoS bridge to map these contracts to maintain a connection between them across chains.

#### Testing the Implementation:

1. Create a transaction on Ramessta by calling the setData function of the child contract.
2. Wait for the checkpoint to be completed.
3. Check the checkpoint inclusion.
4. Use the rama.js SDK to call the exit function of the RootChainManager.

The provided exit script can be used to verify the inclusion of the Ramestta transaction hash on the Polygon chain and trigger the exitToken function of the Predicate contract. This ensures secure state changes on the root contract in Polygon.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.ramestta.com/welcome-to-ramestta/bridge/core/ramestta-to-polygon.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
