geth remix 连接不上

本文详细介绍了使用Remix IDE编写并发布智能合约的过程,包括在不同环境下编译和部署的方法,以及解决连接测试链常见问题的策略。

remix编写智能合约,编译之后发布。run ->environments选择发布环境:

  • javaScript VM (用于本地测试)
  • Injected Web3 (使用metaMask发布智能合约)
  • Web3 Provider (指定测试链)

第三个环境指定测试链时,如http://localhost:8545 有如下提示:

Not possible to connect to the Web3 provider. Make sure the provider is running and a connection is open (via IPC or RPC).

这个错误有两个方面的原因:

1、指定的测试链的地址是http,而remix是https的;

解决方案:
https://remix.ethereum.org改成https://remix.ethereum.org

2、指定的测试链的启动方式不对,少参数

解决方案:

./geth --identity “TestNode” --rpc --rpcaddr “0.0.0.0” --rpcport “8545” --rpcapi “web3,eth,net,debug” --rpccorsdomain “*” --datadir=/Users/qianrongli/eth/data0/eth-test --port “30303” --nodiscover console

  • identity:指定私链的名称(可不指定)
  • nodiscover:让别人看不到这个私链
  • console:命令行启动
  • rpc:允许 HTTP-RPC 访问
  • rpcaddr:允许访问的ip
  • rpcport:HTTP_RPC的访问端口,默认为8545
  • rpcapi:HTTP_RPC访问的api
  • datadir: 指定节点数据存放位置
  • port:网络监听端口,默认为30303

后台启动:

nohup ./geth --identity “TestNode” --rpc --rpcaddr “0.0.0.0” --rpcport “8545” --rpcapi “web3,eth,net,debug” --rpccorsdomain “*” --datadir=/Users/qianrongli/eth/data0/eth-test --port “30303” --nodiscover & > nohup.out

访问控制台:

./geth attach ipc:/opt/eth/geth.ipc

按上述方式启动,是可以连接让remix连接到链的。

希望对您有帮助

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值