---
# System prepended metadata

title: IBC metadata interface

---

# IBC metadata interface


Example:

B-native tokens on A:

B -> A -> Osmosis -> C -> D

Data sent on chain B:
```json!
{
    "dest": {"token send to A data"}
    "metadata": {
        "forward": {
            "version": "v1"
            "address": "osmo1..."
            "next_metadata": { // Osmosis data for a swap, opaque to middleware
                "wasm": {
                    "contract": "addr"
                    "contract_data": {
                        "cosmwasm_message": {
                            "swap data"
                            "forward from C to D data" // processed within contract
                        }
                    }                    
                }
            }
        }, 
        "memo": "This is a very cool ibc transfer"
    }
}
```
(above Data received on chain B) We produce the following metadata on chain A to Osmosis:
```json!
{
    "dest": {"token send to A data"}
    "metadata": {
        "wasm": {
            "contract": "addr"
            "contract_data": {
                "cosmwasm_message": {
                    "swap data"
                    "forward from C to D data"
                }
            }
        }
    }
}
```

Alt:

```json
{
    "hops": [
        {
          "address": "cosmos1tylkasdfjalksdjf",
          "channel_id": "channel_0",
          "port_id": "transfer",
          "max_retries": 2,
          "timeout": "10s",
          "metadata": []bytes()
        },
        {
          "address": "cosmos1tylkasdfjalksdjf",
          "channel_id": "channel_0",
          "port_id": "transfer",
          "max_retries": 2,
          "timeout": "10s",
          "metadata": []bytes()  
        }
    ]
}
```

### How does 3+ hop work

Same general structure, just encode whole path as metadata

### Complex use case

So I want to do 3 actions:

* On Juno do a Contract call
* Do a stake action
* Forward

B -> A -> Juno

Architecture 1 ("wasm key"):

* Write a contract

Architecture 2 ("SDK multi-msg exec key"):

* Write SDK message execution (AKA re-build ICA but simpler)
* Expose pipeline complexity into Cosmos SDK message handling
    * We write a micro-lang for SDK messages, to handle pipelining with partial amounts
    * (This is a good idea, but a second middleware)

Architecture 3:
* Do three middleware calls and middleware complexity
* If we want this, we can a multi-middleware wrapper middleware
* This is weird

Data sent on chain B:
```json!
{
    "dest": {"token send to A data"}
    "metadata": {
        "type": "forward/v1",
        "forward": {
            "address": "osmo1..."
            "next_chain_metadata": {
                "wasm": {
                    "contract": "addr"
                    "contract_data": {
                        "cosmwasm_message": {
                            "swap data"
                            "forward from C to D data"
                            }
                        }                    
                }
            }
        }
    }
}
```
