揭秘 Flashbot:保护您的以太坊交易并利用 MEV(最大可提取价值)

本文为机器翻译
展示原文

介绍

在不断发展的以太坊领域,矿工(现为验证者)对区块内交易的纳入具有一定程度的影响力。这种影响力可以用来获取额外的价值,通常以牺牲普通用户为代价。这种现象被称为最大可提取价值 (MEV)。Flashbots 作为一种解决方案应运而生,旨在减轻 MEV 的影响并让用户更好地控制自己的交易。

Đây là cách có thể bảo vệ blockchain Ethereum khỏi bị thao túng

什么是 Flashbots?

Flashbots Transparency Report — February 2021 - The Flashbots Ship - The  Flashbots Collective

Flashbots 是一家研究和开发组织,致力于减轻最大可提取价值 (MEV) 的负面外部性,并避免 MEV 可能对以太坊等有状态区块链造成的生存风险。我们的主要重点是通过三管齐下的方法为 MEV 实现无需许可透明可持续的生态系统:

使用Flashbots的好处

增强交易速度: Flashbots 交易通常比公共内存池中滞留的交易更快地获得纳入,从而加快了确认速度。

MEV 保护:通过绕过公共内存池,Flashbots 可以保护您的交易免受可能试图操纵交易以谋取私利的 MEV 机器人的攻击。

灵活性: Flashbots 允许用户指定他们愿意向区块构建者提供的最大 MEV 份额,从而确保透明度。

谁应该考虑使用 Flashbots?

虽然 Flashbots 具有诸多优势,但它主要针对特定​​的用户群体:

在 JavaScript 中使用 Flashbots Protect

先决条件:

一步步:

  1. 项目设置:

  2. 安装依赖项:

  3. 创建 JavaScript 文件:

  4. 导入库

    const ethers = require("ethers.js");const { FlashbotsBundleProvider,} = require("@flashbots/ethers-provider-bundle");
  5. 定义交易细节:

     // Standard json rpc provider directly from ethers.js. You can use Infura, Alchemy, or your own node.const provider = new ethers.providers.JsonRpcProvider({url: ETHEREUM_RPC_URL,});// `authSigner` is an Ethereum private key that does NOT store funds and is NOT your bot's primary key.// This is an identifying key for signing payloads to establish reputation and whitelistingconst authSigner = new ethers.Wallet("0x0000000000000000000000000000000000000000000000000000000000000000");// Flashbots provider requires passing in a standard provider and an auth signerconst flashbotsProvider = await FlashbotsBundleProvider.create(provider,authSigner);
  6. 创建交易:

     const transaction = {from: signer.address,to: signer.address,value: "0x42",gasPrice: BigNumber.from(99).mul(1e9),gasLimit: BigNumber.from(21000),};
  7. 发送交易:

     const res = await flashbotsProvider.sendPrivateTransaction({transaction,signer,},{maxBlockNumber: (await provider.getBlockNumber()) + 5, // only allow tx to be included for the next 5 blocks},);
  8. 检查已发送交易的状态:

     const waitRes = await res.wait();if (waitRes === FlashbotsTransactionResolution.TransactionIncluded) {console.log("Private transaction successfully included on-chain.");} else if (waitRes === FlashbotsTransactionResolution.TransactionDropped) {console.log("Private transaction was not included in a block and has been removed from the system.",);}

更多文档: https://docs.flashbots.net/flashbots-protect

结论

总之,Flashbots 代表了以太坊交易处理的革命性进步,提供了增强的隐私性、效率和安全性。通过绕过公共内存池并促进与矿工的直接互动,Flashbots 使用户能够以前所未有的速度和隐私性执行交易,彻底改变了我们与去中心化应用程序互动的方式。随着以太坊生态系统的不断发展,Flashbots 将在塑造区块链技术的未来方面发挥关键作用,使用户和开发人员都能在去中心化金融、数字所有权等领域开启新的可能性。

感谢阅读 Verichains!免费订阅以接收新帖子并支持我的工作。

来源
免责声明:以上内容仅为作者观点,不代表Followin的任何立场,不构成与Followin相关的任何投资建议。
喜欢
收藏
评论