• 以太坊:选择网络及部署


    选择网络及部署

    Even the smallest project will interact with at the very least two blockchain nodes: One on the developer’s machine, like Ganache or Truffle Develop, and the other representing the network where the developer will eventually deploy their application (such as the main public Ethereum network or a private consortium network, for instance). Truffle provides a system for managing the compilation and deployment artifacts for each network, and does so in a way that simplifies final application deployment.

    Configuration

    See the Configuration section for more information.

    Specifying a network

    Most Truffle commands will behave differently based on the network specified, and will use that network’s contracts and configuration. You can specify a network using the --network option, like below:

    $ truffle migrate --network live
    

    In this example, Truffle will run your migrations on the “live” network, which – if configured like the example – is associated with the public Ethereum blockchain.

    Build artifacts

    As mentioned in the Compiling contracts section, build artifacts are stored in the ./build/contractsdirectory as .json files. When you compile your contracts or run your migrations using a specific network, Truffle will update those .json files so they contain the information related to that network. When those artifacts are used later – such as within your frontend or application via truffle-contract – they’ll automatically detect which network the Ethereum client is connected to and use the correct contract artifacts accordingly.

    Application deployment

    Because the network is auto-detected by the contract artifacts at runtime, this means that you only need to deploy your application or frontend once. When you run your application, the running Ethereum client will determine which artifacts are used, and this will make your application very flexible. As an example, if you were to deploy a web application to http://mydapp.io, you could navigate to that address using your favorite wallet-browser (like MetaMask, or Mist) and your dapp would work correctly regardless of the Ethereum network the wallet-browser was connected to. If the wallet-browser was connected to the live network, your dapp would use the contracts you deployed on the live network. If on Ropsten, the contracts you deployed to Ropsten would be used.

  • 相关阅读:
    MySQL-EXPLAIN执行计划字段解释
    MySQL-EXPLAIN执行计划Extra解释
    HTTP与HTTPS的区别
    【面试】Java中sleep和wait的区别
    Nginx之前后端分离(入门)
    玩程序 之 一 . 字符串处理工具(可通过C#脚本扩展)
    C#实现下载功能,可用于软件自动更新
    对c#剪切板Clipboard占用的问题一点解决方法
    C# 制作 仪表
    C#使用自定义字体(从文件获取)
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13313073.html
Copyright © 2020-2023  润新知