> For the complete documentation index, see [llms.txt](https://docs.fly.trade/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.fly.trade/flycn/developers/deprecated-magpie-contracts/magpieaggregator-diamond-proxy/data-transfer/datatransferfacet.md).

# DataTransferFacet

This is a Solidity contract implementing the IDataTransfer interface. It contains several functions related to updating settings and receiving data transfers.

### **updateLayerZeroSettings**

allows the contract owner to update the LayerZeroSettings struct, which contains settings for Layer 0 networks.

**Input**

<table><thead><tr><th width="216.99999999999997">Field</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td><p></p><pre class="language-solidity"><code class="lang-solidity">layerZeroSettings
</code></pre></td><td><p></p><pre class="language-solidity"><code class="lang-solidity">LayerZeroSettings
</code></pre></td><td><p></p><pre class="language-solidity"><code class="lang-solidity">struct LayerZeroSettings {
    address routerAddress;
}
</code></pre></td></tr></tbody></table>

### **addLayerZeroChainIds**&#x20;

allow the contract owner to add LayerZero chain IDs.

**Input**

<table><thead><tr><th width="216.99999999999997">Field</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td><p></p><pre class="language-solidity"><code class="lang-solidity">networkIds
</code></pre></td><td><p></p><pre class="language-solidity"><code class="lang-solidity">uint16[]
</code></pre></td><td>An array of network identifier for each blockchain. These are defined by the magpie team.</td></tr><tr><td><p></p><pre class="language-solidity"><code class="lang-solidity">chainIds
</code></pre></td><td><p></p><pre class="language-solidity"><code class="lang-solidity">uint16[]
</code></pre></td><td>An array of blockchain identifiers</td></tr></tbody></table>

### addLayerZeroNetworkIds

allows the contract owner to add LayerZero network IDs.

**Input**

<table><thead><tr><th>Field</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td><p></p><pre class="language-solidity"><code class="lang-solidity">chainIds
</code></pre></td><td><p></p><pre class="language-solidity"><code class="lang-solidity">uint16[]
</code></pre></td><td>An array of blockchain identifiers</td></tr><tr><td><p></p><pre class="language-solidity"><code class="lang-solidity">networkIds
</code></pre></td><td><p></p><pre class="language-solidity"><code class="lang-solidity">uint16[]
</code></pre></td><td>An array of network identifier for each blockchain. These are defined by the layerzero team.</td></tr></tbody></table>

### **updateWormholeSettings**

allows the contract owner to update the WormholeSettings struct, which contains settings for the Wormhole bridge.

**Input**

<table><thead><tr><th width="216.99999999999997">Field</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td><p></p><pre class="language-solidity"><code class="lang-solidity">wormholeSettings
</code></pre></td><td><p></p><pre class="language-solidity"><code class="lang-solidity">WormholeSettings
</code></pre></td><td><p></p><pre class="language-solidity"><code class="lang-solidity">struct WormholeSettings {
    address bridgeAddress;
    uint8 consistencyLevel;
}
</code></pre></td></tr></tbody></table>

### **addWormholeNetworkIds**

allows the contract owner to add mappings between Wormhole chain IDs and network IDs.

**Input**

<table><thead><tr><th width="216.99999999999997">Field</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td><p></p><pre class="language-solidity"><code class="lang-solidity">chainIds
</code></pre></td><td><p></p><pre class="language-solidity"><code class="lang-solidity">uint16[]
</code></pre></td><td>An array of blockchain identifiers</td></tr><tr><td><p></p><pre class="language-solidity"><code class="lang-solidity">networkIds
</code></pre></td><td><p></p><pre class="language-solidity"><code class="lang-solidity">uint16[]
</code></pre></td><td>An array of network identifier for each blockchain. These are defined by the wormhole team.</td></tr></tbody></table>

### getWormholeCoreSequence

this function provides a way to obtain the core sequence from a transfer key's core sequence by calling the `getCoreSequence` function from the `LibWormhole` library. It allows external callers to retrieve the core sequence without modifying the contract's state.

**Input**

<table><thead><tr><th>Field</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td><p></p><pre class="language-solidity"><code class="lang-solidity">transferKeyCoreSequence
</code></pre></td><td><p></p><pre class="language-solidity"><code class="lang-solidity">uint64
</code></pre></td><td>The sequence provide by magpie team for the data transfer</td></tr></tbody></table>

### **lzReceive**

called by LayerZero to initiate a data transfer. It enforces that the function is called by a LayerZero contract and then calls the lzReceive function in the LibLayerZero library, which handles the actual data transfer.

**Input**

<table><thead><tr><th width="216.99999999999997">Field</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td><p></p><pre class="language-solidity"><code class="lang-solidity">senderChainId
</code></pre></td><td><p></p><pre class="language-solidity"><code class="lang-solidity">uint16
</code></pre></td><td>The chain id of the source chain</td></tr><tr><td><p></p><pre class="language-solidity"><code class="lang-solidity">localAndRemoteAddresses
</code></pre></td><td><p></p><pre class="language-solidity"><code class="lang-solidity">bytes
</code></pre></td><td>The address which will receive the data</td></tr><tr><td><p></p><pre class="language-solidity"><code class="lang-solidity">nonce
</code></pre></td><td><p></p><pre class="language-solidity"><code class="lang-solidity">uint64
</code></pre></td><td>random or pseudo-random number that is used only once.</td></tr><tr><td><p></p><pre class="language-solidity"><code class="lang-solidity">extendedPayload
</code></pre></td><td><p></p><pre class="language-solidity"><code class="lang-solidity">bytes
</code></pre></td><td>Payload + extra information like which data transfer type has been used</td></tr></tbody></table>

### dataTransferIn():

It calls the `dataTransfer` function from the `LibDataTransfer` library, passing the `dataTransferInArgs` as an argument.

**Input**:

<table><thead><tr><th>Field</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td><p></p><pre class="language-solidity"><code class="lang-solidity">dataTransferInArgs
</code></pre></td><td><p></p><pre class="language-solidity"><code class="lang-solidity">DataTransferInArgs
</code></pre></td><td><p></p><pre class="language-solidity"><code class="lang-solidity">struct DataTransferInArgs {
    DataTransferInProtocol protocol;
    TransferKey transferKey;
    bytes payload;
}
</code></pre></td></tr></tbody></table>

### dataTransferOut():

It calls the `getPayload` function from the `LibDataTransfer` library, passing the `dataTransferOutArgs` as an argument.

**Input**:

<table><thead><tr><th>Field</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td><p></p><pre class="language-solidity"><code class="lang-solidity">dataTransferOutArgs
</code></pre></td><td><p></p><pre class="language-solidity"><code class="lang-solidity">DataTransferOutArgs
</code></pre></td><td><p></p><pre class="language-solidity"><code class="lang-solidity">struct DataTransferOutArgs {
    DataTransferType dataTransferType;
    bytes payload;
}
</code></pre></td></tr></tbody></table>
