Skip to content

Commit

Permalink
Validate message (#44)
Browse files Browse the repository at this point in the history
* Add message validate doc

* Polish it
  • Loading branch information
boundless-forest authored Jul 9, 2024
1 parent cb86ff4 commit 7e1c591
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
12 changes: 12 additions & 0 deletions docs/build/tutorial/validation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Validating Received Messages

For the application that receives cross-chain messages, it is crucial to validate the received messages to ensure they come from the intended source chain and application. Adding these validations to your application can help prevent unexpected changes to the contract's state.

The basic validation materials are provided by the Msgport [Application](../interfaces.md#application) contract. It provides the following functions:

* `_msgPort()`: Returns the `msg.sender` of the received message, typically the address of the corresponding message port.
* `_messageId()`: Returns the message ID of the received message.
* `_chainId()`: Returns the chain ID of the source chain. It is recommended to validate it by default.
* `_xmsgSender()`: Returns the application address in the source chain from which the received message originates. It is recommended to validate it by default.

Since it is recommended that the application receiving the message extends the `Application` contract, these validation materials can be used directly by the application. You can refer to the [examples](https://github.com/msgport/msgport-examples) for more information.
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ nav:
- Tutorial:
- Sending Messages:
- Using Remix: "build/tutorial/remix-demo.md"
- Validating Messages: "build/tutorial/validation.md"
- Explore More Examples: "build/tutorial/examples.md"
- Community:
- Ring DAO: "community/ringdao.md"
Expand Down

0 comments on commit 7e1c591

Please sign in to comment.