• 02. 最佳实践


    参考

    https://geth.ethereum.org/docs/getting-started/dev-mode

    在开发模式下启动 Geth

    您可以使用该--datadir选项指定一个数据目录来维护两次运行之间的状态,否则,数据库是临时的并且在内存中:

    mkdir test-chain-dir
    

    对于本指南,在开发模式下启动 geth,并启用RPC以便您可以将其他应用程序连接到 geth。在本指南中,我们使用基于 Web 的以太坊 IDE Remix,因此也允许其域接受跨域请求。

    geth --datadir test-chain-dir --http --dev --http.corsdomain "https://remix.ethereum.org,http://remix.ethereum.org"
    

    从另一个终端窗口连接到节点上的 IPC 控制台:

    geth attach <IPC_LOCATION>
    

    一旦 geth 在开发模式下运行,您就可以像当 geth 以其他方式运行时一样与它进行交互。

    例如,创建一个测试帐户:

    > personal.newAccount()
    

    并将以太币从 coinbase 转移到新账户:

    > eth.sendTransaction({from:eth.coinbase, to:eth.accounts[1], value: web3.toWei(0.05, "ether")})
    

    并查看账户余额:

    > eth.getBalance(eth.accounts[1])
    

    如果你想用真实的区块时间测试你的 dapps,请在使用参数--dev.period启动开发模式时使用该选项--dev.period 14

    geth --datadir test-chain-dir --http --http.addr 0.0.0.0 --dev.period 14 --http.corsdomain "https://remix.ethereu
    m.org,http://remix.ethereum.org"
    

    宿主机无法访问容器

    添加 --http.addr 0.0.0.0

    geth --datadir test-chain-dir --http --http.addr 0.0.0.0 --dev --http.corsdomain "https://remix.ethereum.org,http://remix.ethereum.org"
    
  • 相关阅读:
    标签,css,排版
    浏览器的内核
    焦点事件
    cookie
    浏览器的行为
    百叶窗分析
    水仙花数
    递归函数
    拖拽的问题解决
    正则的具体
  • 原文地址:https://www.cnblogs.com/1766af/p/15337917.html
Copyright © 2020-2023  润新知