5. MoveCall - counter::lz_receive
- Receives the Call object
- Validates and processes
- Destroys the Call
Objects used:
- 0x5f24...0c8e: Executor shared object (immutable)
- 0x00a7...9fc2: Executor CallCap (owned)
- 0xd45b...bf91: EndpointV2 shared object (immutable)
- 0x9b01...1843: MessagingChannel shared object (mutable)
- 0x6903...8c4d: Counter OApp shared object (mutable)
- 0x224b...fbb3: Counter Peer shared object (immutable)
- 0x608a...6f27: Counter's internal state (mutable)
// Events emitted:
- PacketDeliveredEvent
```
***
## Key IOTA-Specific Patterns
### Object Ownership in Message Flow
| Object Type | Ownership | Access Pattern | Example |
| - | - | - | - |
| `EndpointV2` | Shared | Anyone reads, admin writes | `&EndpointV2` or `&mut EndpointV2` |
| `MessagingChannel` | Shared | Anyone reads, owner writes | `&mut MessagingChannel` |
| `OApp` | Shared | Anyone reads, admin writes | `&mut OApp` |
| `CallCap` | Owned | Must own to use | Owned by OApp module or user |
| `AdminCap` | Owned | Must own to use | Owned by admin address |
| `Call` | Neither | Must be consumed in PTB | Created and destroyed in same TX |
### Call Pattern vs EVM/Solana
| Aspect | EVM | Solana | IOTA |
| - | - | - | - |
| **Cross-Contract Calls** | `delegatecall` | CPI (Cross-Program Invocation) | `Call` objects |
| **Authorization** | `msg.sender` | Signer checks + PDAs | `CallCap` validation |
| **Return Values** | Function returns | CPI returns | `Call.complete()` sets result |
| **Call Hierarchy** | Call stack (implicit) | CPI depth limit (4) | `Call` parent/child relationships |
| **Atomicity** | Transaction revert | Transaction revert | PTB revert |
### Nonce Management
**EVM**:
```solidity wrap theme={null}
// Mapping-based nonce storage
mapping(address => mapping(uint32 => mapping(bytes32 => uint64))) outboundNonce;
```
**Solana**:
```rust wrap theme={null}
// PDA account per pathway
#[account(seeds = [NONCE_SEED, sender, dst_eid, receiver], bump)]
pub nonce: Account<'info, Nonce>,
```
**IOTA**:
```rust wrap theme={null}
// Table within MessagingChannel, nested in Channel struct
public struct MessagingChannel has key {
channels: Table, // Maps (eid, remote_oapp) → Channel
}
public struct Channel has store {
outbound_nonce: u64, // Incremented on each send
lazy_inbound_nonce: u64, // Last executed inbound nonce
inbound_payload_hashes: Table, // Maps nonce → hash
}
```
### Fee Payment Model
**EVM**:
```solidity wrap theme={null}
// Direct transfer in msg.value
Transfer.native(executor, executorFee);
```
**Solana**:
```rust wrap theme={null}
// Token account transfer
transfer(from_account, to_account, amount);
```
**IOTA**:
```rust wrap theme={null}
// Coin object splitting and transfer
let fee_coin = coin::split(&mut provided_coin, fee_amount, ctx);
transfer::public_transfer(fee_coin, recipient_address);
```
***
## Configuration Management
### Send Library Configuration
OApps can set custom send libraries per destination:
```rust wrap theme={null}
/// From endpoint_v2 (called by OApp with AdminCap)
public fun set_send_library(
self: &mut EndpointV2,
caller: &CallCap,
oapp: address,
dst_eid: u32,
new_lib: address,
) {
self.assert_authorized(caller.id(), oapp);
self.message_lib_manager.set_send_library(oapp, dst_eid, new_lib);
}
```
**Default Fallback**:
```rust wrap theme={null}
/// From message_lib_manager
public(package) fun get_send_library(
self: &MessageLibManager,
sender: address,
dst_eid: u32,
): (address, bool) {
// Try OApp-specific config first
let key = SendLibraryKey { sender, dst_eid };
if (self.send_libraries.contains(key)) {
return (self.send_libraries[key], false) // Custom library
};
// Fall back to default
let default_lib = self.default_send_libraries[dst_eid];
(default_lib, true) // Default library
}
```
### DVN Configuration
OApps configure DVN sets through the ULN:
```rust wrap theme={null}
/// ULN configuration structure
public struct UlnConfig has copy, drop, store {
confirmations: u64, // Block confirmations required
required_dvn_count: u8, // Number of required DVNs
optional_dvn_count: u8, // Number of optional DVNs
optional_dvn_threshold: u8, // How many optional DVNs must verify
required_dvns: vector, // Required DVN addresses
optional_dvns: vector