# LInea测试网奥德赛活动Lifi交互教程

By [Web3见闻](https://paragraph.com/@jackson-you) · 2023-05-07

---

1\. Lifi目前的问题
=============

Lifi由于过量的访问导致无法实现跨链桥的访问，本教程现在通过合约调用Lifi智能合约进行交互。

2\. 访问Lifi测试网
=============

由于Lifi智能合约需要相应的参数才能够运行，我们这里需要访问一下的地址:

**USDT代币**我们使用下面的命令在命令行中请求, **这里我们需要讲fromAddress地址换成各位的地址**:

    curl --request GET      --url 'https://staging.li.quest/v1/quote?fromChain=5&toChain=59140&fromToken=0x41e5e6045f91b61aacc99edca0967d518fb44cfb&toToken=0x7823E8DCC8bfc23EA3AC899EB86921f90e80F499&fromAddress=0x9fa45Ac2A676cdeE77df20766D4F7D2C04cc9305&fromAmount=10&slippage=0.01&allowBridges=&allowExchanges='      --header 'accept: application/json' > 1.txt
    

在命令行输入上面的命令后，我们保存在1.txt文件中:

![图1](https://storage.googleapis.com/papyrus_images/cf7c0d75d5934cc770bf16994e0d6ec8f2b28ed0875850666d87a01ea500329c.png)

图1

上面表示我们请求成功了

接下来，我们在命令行输入:

    open .
    

这个时候我们就可以打开我们的文件目录了：

![图2](https://storage.googleapis.com/papyrus_images/65f975260b34efbd5b6b4796b863035064518936bbc5dc211f284d4485e84423.png)

图2

我们现在打开文件1.txt，可以得到如下的内容:

    {"type":"lifi","id":"86af425e-7927-442e-a726-c6a8a3490d06","tool":"hop","toolDetails":{"key":"hop","name":"Hop","logoURI":"https://raw.githubusercontent.com/lifinance/types/main/src/assets/icons/bridges/hop.png"},"action":{"fromToken":{"address":"0xfad6367e97217cc51b4cd838cc086831f81d38c2","symbol":"USDT","decimals":6,"chainId":5,"name":"Tether USD","coinKey":"","logoURI":"","priceUSD":"0"},"fromAmount":"10","toToken":{"address":"0x1990bc6dfe2ef605bfc08f5a23564db75642ad73","symbol":"USDT","decimals":6,"chainId":59140,"name":"Tether USD","coinKey":"","logoURI":"","priceUSD":"0"},"fromChainId":5,"toChainId":59140,"slippage":0.01,"fromAddress":"0x9fa45Ac2A676cdeE77df20766D4F7D2C04cc9305","toAddress":"0x9fa45Ac2A676cdeE77df20766D4F7D2C04cc9305"},"estimate":{"tool":"hop","approvalAddress":"0x1231DEB6f5749EF6cE6943a275A1D3E7486F4EaE","toAmountMin":"10","toAmount":"10","fromAmount":"10","feeCosts":[{"name":"LP Fee","description":"Fee paid to the Liquidity Provider","percentage":"0","token":{"address":"0x1990bc6dfe2ef605bfc08f5a23564db75642ad73","symbol":"USDT","decimals":6,"chainId":59140,"name":"Tether USD","coinKey":"","logoURI":"","priceUSD":"0"},"amount":"0","included":true},{"name":"Bonder Fee","description":"Fee paid to the Bonder","percentage":"0","token":{"address":"0x1990bc6dfe2ef605bfc08f5a23564db75642ad73","symbol":"USDT","decimals":6,"chainId":59140,"name":"Tether USD","coinKey":"","logoURI":"","priceUSD":"0"},"amount":"0","included":true},{"name":"Destination Tx Fee","description":"Fee paid to account for gas costs on the destination chain","percentage":"0","token":{"address":"0x1990bc6dfe2ef605bfc08f5a23564db75642ad73","symbol":"USDT","decimals":6,"chainId":59140,"name":"Tether USD","coinKey":"","logoURI":"","priceUSD":"0"},"amount":"0","included":true},{"name":"Relayer Fee","description":"Fee charged on source chain to pay for relaying","percentage":"NaN","token":{"address":"0x0000000000000000000000000000000000000000","symbol":"ETH","decimals":18,"chainId":5,"name":"ETH","coinKey":"ETH","logoURI":"","priceUSD":"0"},"amount":"10000000000000000","amountUSD":"0.00","included":false}],"gasCosts":[{"type":"SEND","price":"2629338600378","estimate":"345703","limit":"460938","amount":"1211960761111734375","amountUSD":"0.00","token":{"address":"0x0000000000000000000000000000000000000000","symbol":"ETH","decimals":18,"chainId":5,"name":"ETH","coinKey":"ETH","logoURI":"","priceUSD":"0"}}],"executionDuration":5000,"fromAmountUSD":"0.00","toAmountUSD":"0.00"},"includedSteps":[{"id":"b5007e5b-2c29-4952-9dd9-59686209f50b","type":"cross","action":{"fromChainId":5,"fromAmount":"10","fromToken":{"address":"0xfad6367e97217cc51b4cd838cc086831f81d38c2","symbol":"USDT","decimals":6,"chainId":5,"name":"Tether USD","coinKey":"","logoURI":"","priceUSD":"0"},"toChainId":59140,"toToken":{"address":"0x1990bc6dfe2ef605bfc08f5a23564db75642ad73","symbol":"USDT","decimals":6,"chainId":59140,"name":"Tether USD","coinKey":"","logoURI":"","priceUSD":"0"},"slippage":0.01,"destinationGasConsumption":"0","fromAddress":"0x1231DEB6f5749EF6cE6943a275A1D3E7486F4EaE","toAddress":"0x9fa45Ac2A676cdeE77df20766D4F7D2C04cc9305"},"estimate":{"tool":"hop","fromAmount":"10","toAmount":"10","toAmountMin":"10","approvalAddress":"0x53B94FAf104A484ff4E7c66bFe311fd48ce3D887","executionDuration":5000,"feeCosts":[{"name":"LP Fee","description":"Fee paid to the Liquidity Provider","percentage":"0","token":{"address":"0x1990bc6dfe2ef605bfc08f5a23564db75642ad73","symbol":"USDT","decimals":6,"chainId":59140,"name":"Tether USD","coinKey":"","logoURI":"","priceUSD":"0"},"amount":"0","included":true},{"name":"Bonder Fee","description":"Fee paid to the Bonder","percentage":"0","token":{"address":"0x1990bc6dfe2ef605bfc08f5a23564db75642ad73","symbol":"USDT","decimals":6,"chainId":59140,"name":"Tether USD","coinKey":"","logoURI":"","priceUSD":"0"},"amount":"0","included":true},{"name":"Destination Tx Fee","description":"Fee paid to account for gas costs on the destination chain","percentage":"0","token":{"address":"0x1990bc6dfe2ef605bfc08f5a23564db75642ad73","symbol":"USDT","decimals":6,"chainId":59140,"name":"Tether USD","coinKey":"","logoURI":"","priceUSD":"0"},"amount":"0","included":true},{"name":"Relayer Fee","description":"Fee charged on source chain to pay for relaying","percentage":"NaN","token":{"address":"0x0000000000000000000000000000000000000000","symbol":"ETH","decimals":18,"chainId":5,"name":"ETH","coinKey":"ETH","logoURI":"","priceUSD":"0"},"amount":"10000000000000000","amountUSD":"0.00","included":false}],"gasCosts":[{"type":"SEND","price":"2629338600378","estimate":"215625","limit":"287500","amount":"755934847608675000","amountUSD":"0.00","token":{"address":"0x0000000000000000000000000000000000000000","symbol":"ETH","decimals":18,"chainId":5,"name":"ETH","coinKey":"ETH","logoURI":"","priceUSD":"0"}}],"toolData":{"amountOut":"10","rate":"1","priceImpact":"0","requiredLiquidity":"10","lpFees":"0","bonderFeeRelative":"0","adjustedBonderFee":"0","adjustedDestinationTxFee":"0","totalFee":"0","estimatedReceived":"10","relayFeeEth":"10000000000000000"}},"tool":"hop","toolDetails":{"key":"hop","name":"Hop","logoURI":"https://raw.githubusercontent.com/lifinance/types/main/src/assets/icons/bridges/hop.png"}}],"integrator":"lifi-staging-api","transactionRequest":{"data":"0xb3b6358700000000000000000000000000000000000000000000000000000000000001200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000645897f1000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000645897f1000000000000000000000000b47de784ab8702ec35c5eab225d6f6ce476ddd280000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002386f26fc10000e8b0339fd1aea078bd91b389e4c43f627be74f2e9aa52ffdc0430ccc06f1c21b000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000001800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000fad6367e97217cc51b4cd838cc086831f81d38c20000000000000000000000009fa45ac2a676cdee77df20766d4f7d2c04cc9305000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000e704000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003686f70000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000106c6966692d73746167696e672d61706900000000000000000000000000000000","to":"0x1231DEB6f5749EF6cE6943a275A1D3E7486F4EaE","value":"0x2386f26fc10000","from":"0x9fa45Ac2A676cdeE77df20766D4F7D2C04cc9305","chainId":5,"gasPrice":"0x026430cb13ba","gasLimit":"0x07088a"}}
    

我们将最后的data的几行复制下来:

![图3](https://storage.googleapis.com/papyrus_images/4eedae64272ca5d66925634984dbf8c8d71c1fb01fd284b88ab2f49934dd7717.png)

图3

可以得到下面的内容:

> {     "data":"0xb3b6358700000000000000000000000000000000000000000000000000000000000001200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000645897f1000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000645897f1000000000000000000000000b47de784ab8702ec35c5eab225d6f6ce476ddd280000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002386f26fc10000e8b0339fd1aea078bd91b389e4c43f627be74f2e9aa52ffdc0430ccc06f1c21b000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000001800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000fad6367e97217cc51b4cd838cc086831f81d38c20000000000000000000000009fa45ac2a676cdee77df20766d4f7d2c04cc9305000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000e704000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003686f70000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000106c6966692d73746167696e672d61706900000000000000000000000000000000",     "to":"0x1231DEB6f5749EF6cE6943a275A1D3E7486F4EaE",     "value":"0x2386f26fc10000",     "from":"0x9fa45Ac2A676cdeE77df20766D4F7D2C04cc9305",     "chainId":5,     "gasPrice":"0x026430cb13ba",     "gasLimit":"0x07088a" }

这个是我们内容必须的，我们稍后会用到。

接下来我们需要访问

[https://goerli.etherscan.io/address/0xfad6367E97217cC51b4cd838Cc086831f81d38C2#writeContract](https://goerli.etherscan.io/address/0xfad6367E97217cC51b4cd838Cc086831f81d38C2#writeContract)

这里我们可以看到下面的内容:

![](https://storage.googleapis.com/papyrus_images/7b19cf5eca76869c9cee04fb1d615ac09a8b000b48b5f091c6685d9fc7fe2ede.png)

然后点击“connetct to web3”

![](https://storage.googleapis.com/papyrus_images/03ee43410d4abe80c8ac66ac01a9430525ed2e5b6587f42777307bc6e7ef0faf.png)

我们可以看到下面的：

![](https://storage.googleapis.com/papyrus_images/808bdc1618be930d1464b61dfc0864da2c1522f1058bab7b190eb99b83eff343.png)

然后找到这个第7个函数,在第一个位置输入

**0x1231DEB6f5749EF6cE6943a275A1D3E7486F4EaE**

第二个位置输入10000000000000000，点击write

![](https://storage.googleapis.com/papyrus_images/39a353430aaec8a6a23ebfbbe359b21925daa7e03c4efe90c82424c9e2f9846d.png)

这里点击确认：

然后找到第3个，就是下面的函数：

![](https://storage.googleapis.com/papyrus_images/cbb94d7869f4f30f803debee79ba45629a2d01c23cd5d6de22e62a5d840f1329.png)

第一个位置输入**0x1231DEB6f5749EF6cE6943a275A1D3E7486F4EaE**

**第二个位置输入**10000000000000000

然后点击write，然后确认

![](https://storage.googleapis.com/papyrus_images/a713f84879f320cb01739e7569c892edc49d36d4fe1737c714a390c954e69af8.png)

选择最大，然后点击下一步：

![](https://storage.googleapis.com/papyrus_images/d4594e4f4e275a04cb2b94ec0b4690fa553cc407d306bd978d794a4cb6766a34.png)

点击批准，等待确认成功。

复制下面的代码:

    const ethereumButton = document.querySelector('.enableEthereumButton');
    const sendEthButton = document.querySelector('.sendEthButton');
    
    let accounts = [];
    
    // Send Ethereum to an address
    sendEthButton.addEventListener('click', () => {
      ethereum
        .request({
          method: 'eth_sendTransaction',
          params: [
            {    "data":"0xb3b6358700000000000000000000000000000000000000000000000000000000000001200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000645897f1000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000645897f1000000000000000000000000b47de784ab8702ec35c5eab225d6f6ce476ddd280000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002386f26fc10000e8b0339fd1aea078bd91b389e4c43f627be74f2e9aa52ffdc0430ccc06f1c21b000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000001800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000fad6367e97217cc51b4cd838cc086831f81d38c20000000000000000000000009fa45ac2a676cdee77df20766d4f7d2c04cc9305000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000e704000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003686f70000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000106c6966692d73746167696e672d61706900000000000000000000000000000000",    "to":"0x1231DEB6f5749EF6cE6943a275A1D3E7486F4EaE",    "value":"0x2386f26fc10000",    "from":"0x9fa45Ac2A676cdeE77df20766D4F7D2C04cc9305",    "chainId":5,    "gasPrice":"0x026430cb13ba",    "gasLimit":"0x07088a"}
            ,
          ],
        })
        .then((txHash) => console.log(txHash))
        .catch((error) => console.error(error));
    });
    
    ethereumButton.addEventListener('click', () => {
      getAccount();
    });
    
    async function getAccount() {
      accounts = await ethereum.request({ method: 'eth_requestAccounts' });
    }
    

**上面data那一部分是我们前面请求的内容，需要替换成你自己的。**

然后在相同目录中写html页面，这里需要首先安装metamask的相关插件，具体内容可以查看一下的内容：

[https://docs.metamask.io/wallet/how-to/send-transactions/](https://docs.metamask.io/wallet/how-to/send-transactions/)

安装好metamask之后，可以可以写如下代码:

    <button class="enableEthereumButton btn">Enable Ethereum</button>
    <button class="sendEthButton btn">Send ETH</button>
    

点击Send ETH即可。

3\. 联系与捐赠
---------

如果有问题，可以联系我

[https://twitter.com/jackson63891075](https://twitter.com/jackson63891075)

如果觉得我写的不错，可以打赏哟:

ETH： 0x0290e9cE53972B7a9cC59cCc11224DfB16612271

BSC: 0x0290e9cE53972B7a9cC59cCc11224DfB16612271

---

*Originally published on [Web3见闻](https://paragraph.com/@jackson-you/linea-lifi)*
