Cross Chain Authorization
Cross-chain authorization refers to a process in which users provide a set of instructions in textual format. The user interacts only with the instructions themselves, while the underlying functionalities—such as validation and execution—are encapsulated within the module, abstracting complexity.
The instruction structure is composed of three primary components:
- Enable Flag: Indicates whether a specific message index bypasses authorization.
- Immutable Object: Represents data that remains unaltered and can be validated directly. Examples include whitelisted addresses, transfer limits, etc.
- Each object consist of three information that user needs to provide:
- What is the data type of variable that will be validated
- What is the operator function that will be executed
- What is the expected value that will be compared by the operator.
- Each object consist of three information that user needs to provide:
- Mutable Object: Represents data that changes over time and requires computation for validation. Examples include daily transfer limits, cumulative totals, etc.
- Each object consist of three information that user needs to provide:
- What is the data type of variable that will be validated
- What is the operator function that will be executed
- What is the expected value that will be compared by the operator.
- Each object consist of three information that user needs to provide:
Below is an example illustrating cross-chain authorization:
- Messages Example
[
{
"@type": "/cosmos.bank.v1beta1.MsgSend",
"from_address": "cosmos1zypqa76je7pxsdwkfah6mu9a583sju6xqt3mv6",
"to_address": "cosmos1mgp7qnvumhlcq6e4z2q05r29dchcyug0z3zxeg",
"amount": [
{
"denom": "ubeta",
"amount": "50000000"
}
]
},
{
"@type": "/cosmos.bank.v1beta1.MsgSend",
"from_address": "cosmos1zypqa76je7pxsdwkfah6mu9a583sju6xqt3mv6",
"to_address": "cosmos1mgp7qnvumhlcq6e4z2q05r29dchcyug0z3zxeg",
"amount": [
{
"denom": "ubeta",
"amount": "30000000"
}
]
}
] - Authorizations Example
[
{
"enable": true,
"immutable": {
"from_address": [
{
"type": "string",
"operator": "equal",
"value": "cosmos1zypqa76je7pxsdwkfah6mu9a583sju6xqt3mv6"
}
],
"to_address": [
{
"type": "array.string",
"operator": "equal",
"value": "cosmos1mgp7qnvumhlcq6e4z2q05r29dchcyug0z3zxeg,cosmos1zypqa76je7pxsdwkfah6mu9a583sju6xqt3mv6"
}
],
"amount": [
{
"type": "array.coin",
"operator": "lte",
"value": "50000000ubeta"
}
]
},
"mutable": {
"amount": [
{
"type": "array.coin",
"operator": "sum",
"value": "100000000ubeta"
},
{
"type": "array.coin",
"operator": "daily.sum",
"value": "100000000ubeta"
}
]
}
},
{
"enable": false
}
]
In this example, the message parameters such as to_address, from_address, and amount serve as variables that undergo validation during authorization.
- Message at Index 0:
- Immutable Object Validation:
- Validates the transfer amount.
- Ensures the address is whitelisted.
- Mutable Object Validation:
- Tracks and updates the total sum of transferred tokens.
- Tracks and updates the daily sum, which resets at the start of each day.
- Immutable Object Validation:
- Message at Index 1:
- No validation is performed due to the enabled flag.
This concludes the overview of the concept. For more details like data types and flowchart, refer to advanced concept.