简体   繁体   English

一个人如何从浏览器创建一个新的以太坊节点?

[英]How would one create a new Ethereum node from the browser?

I'm reading the Web3 documentation and I see that using it in the console requires a running Ethereum node. 我正在阅读Web3文档,并且看到在控制台中使用它需要运行中的以太坊节点。 But since plenty of DApp users will be new to Ethereum, what are the standard ways of generating new nodes from the browser? 但是,由于大量的DApp用户将是以太坊的新手,因此从浏览器生成新节点的标准方法是什么?

Of course, this can be done with the Geth command line tools - but how does one use these tools in the console? 当然,可以使用Geth命令行工具完成此操作-但是如何在控制台中使用这些工具?

As far as I know, there is not yet a way to run a node in the browser but you can get to something apparently close using Metamask. 据我所知,还没有一种方法可以在浏览器中运行节点,但是您可以使用Metamask来达到明显关闭的目的。

If you use geth, you can start it with geth console , that will give you access to the console. 如果使用geth,则可以使用geth console启动它,这将使您可以访问控制台。

If you started a node with rpc (geth or other) you can attach geth to it with geth attach http://localhost:8545 如果您使用rpc(geth或其他)启动节点,则可以使用geth attach http://localhost:8545到该节点上。 geth attach http://localhost:8545

If you are running a DAPP in your browser, it very likely loaded web3.js into your browser for you. 如果您在浏览器中运行DAPP,则很有可能会为您将web3.js加载到浏览器中。 If you open the dev console, you can also access web3 through the console. 如果打开开发人员控制台,则还可以通过控制台访问web3。

Finally, you can also use Metamask (a chrome extension) that will inject web3.js in your browser. 最后,您还可以使用Metamask(chrome扩展程序),该工具将在浏览器中注入web3.js。 From there, you can open the dev console and start issuing commands such as web3.eth.accounts 从那里,您可以打开开发控制台并开始发出命令,例如web3.eth.accounts

In case you are running a DAPP in browser, alternative to MetaMask ( which I highly recommend ) could be connection to 如果您在浏览器中运行DAPP,则可以连接MetaMask(我强烈推荐)的替代方法

https://infura.io/ , register (api key will be generated for you), so you could "connect trough" them. https://infura.io/ ,注册(将为您生成api密钥),因此您可以“连接槽”它们。 ( even though MetaMask uses Infura as well, I think ) Something like this ( in context of code ): (尽管我认为MetaMask也使用Infura)(在代码上下文中)这样的东西:

web3 = new Web3(new Web3.providers.HttpProvider('https://ropsten.infura.io/efYr0Kza6Io9M1NPXZA1');

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何将以太坊区块链从一个节点复制到另一个 - How to copy Ethereum Blockchain from one node to another 使用以太坊节点创建钱包 - Create a wallet with ethereum node 如何在不连接以太坊节点的情况下查看以太坊地址余额? - How to check Ethereum address balance without connecting to an Ethereum node? 如何从以太坊中部署的合约部署合约? - How to deploy contract from deployed contract in Ethereum? 如何使用 Dune 创建查询以显示以太坊上新创建的 ERC-20 合约的开发情况,而不计算重复项? - How can I create a query to display the development of new created ERC-20 contracts on Ethereum with Dune without counting duplicates? 如何使用以太坊奇偶校验/ IPFS创建用于记录保存的区块链? - How to create a blockchain for record keeping using Ethereum Parity/ IPFS? 如何使用松露创建以太坊账户(不在控制台模式下) - How to create an ethereum account using truffle ( not in the console mode ) 如何使用 Nethereum 创建以太坊 HD 钱包实现 - How do I create an Ethereum HD wallet implementation with Nethereum 我可以使用Ruby on Rails或Node.js而不是Ethereum + Geth创建本地区块链吗? - Can I create a local blockchain with Ruby on Rails or Node.js instead of Ethereum+Geth? 如何在python中以太坊区块链上创建合约? - How to create contracts on Ethereum block-chain in python?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM