测试网络 关于和浏览器交互的 eosAsia 的 ping 例程的问题

qq6783807qq · October 14, 2018 · Last by sbihgu replied at December 30, 2019 · 1603 hits

npm start 运行正常 打开浏览器访问http://localhost:8080/ F12 显示报错

HMR] Waiting for update signal from WDS... log.js:24:4
Download the React DevTools for a better development experience: https://fb.me/react-devtools react-dom.development.js:18239:9
[WDS] Hot Module Replacement enabled. client:71:5
api error => http://127.0.0.1:8888/v1/chain/get_code {"account_name":"ping3.str"} TypeError: "NetworkError when attempting to fetch resource." apigen.js:118:7
fetchMethod/</<
webpack:///./node_modules/eosjs-api/lib/apigen.js?:118:7
TypeError: "NetworkError when attempting to fetch resource." index.js:110:7
consoleObjCallbackLog/<
webpack:///./node_modules/eosjs/lib/index.js?:110:7
callback
webpack:///./node_modules/eosjs-api/lib/apigen.js?:82:11
fetchMethod/</<
webpack:///./node_modules/eosjs-api/lib/apigen.js?:120:9

index.JSX 代码为

import React from 'react'
import ReactDOM from 'react-dom'
import EOS from 'eosjs'


const EOS_CONFIG = {
  contractName: "ping3.str", // Contract name合约执行账户
  contractSender: "liuyunlong32", // User executing the contract (should be paired with private key)  合约测试账户
  clientConfig: {
    keyProvider: ['5HpRbCGf3D3m2NiLgSTf3WXZm9SMUa9etJyW5aQKipAmCg28NnV'], // Your private key合约测试账户密钥
    httpEndpoint: 'http://127.0.0.1:8888' // EOS http endpoint
  }
}

class Pingdemo extends React.Component {
  constructor(props) {
    super(props)
    this.state = { pingStatus: false }
  }

  sendPing() {
    this.setState({ pingStatus: 'loading' })
    let eosClient = EOS.Localnet(EOS_CONFIG.clientConfig)

    eosClient.contract(EOS_CONFIG.contractName)
      .then((contract) => {
        contract.ping(EOS_CONFIG.contractSender, { authorization: [EOS_CONFIG.contractSender] })
          .then((res) => { this.setState({ pingStatus: 'success' }) })
          .catch((err) => { this.setState({ pingStatus: 'fail' }); console.log(err) })
      })
  }

  render() {
    if (!this.state.pingStatus){
      return (<button onClick={this.sendPing.bind(this)}>Ping EOS</button>)
    } else if (this.state.pingStatus == "loading") {
      return (<span style={{ color: "gray" }}>Pinging EOS...</span>)
    } else if (this.state.pingStatus == "success") {
      return (<span style={{ color: "green" }}>Ping successful!</span>)
    } else if (this.state.pingStatus == "fail") {
      return (<span style={{ color: "red" }}>Ping unsuccessful</span>)
    }
  }
}

ReactDOM.render(<Pingdemo />, document.getElementById('app'));

module.hot.accept();

求解,百度了很多没找到答案。以前也没怎么学过前端,真是一脚一个坑

2018-10-14T11:03:58.323 thread-0   http_plugin.cpp:580           handle_exception     ] FC Exception encountered while processing chain.get_code
2018-10-14T11:03:58.324 thread-0   http_plugin.cpp:581           handle_exception     ] Exception Details: 3100008 unsupported_feature: Feature is currently unsupported
Returning WAST from get_code is no longer supported
    {}
    thread-0  chain_plugin.cpp:1535 get_code

Returning WAST from get_code is no longer supported

你是 1.3 版本吗

你搞定了吗、我也遇到了,找资料都没有相关的。

需要 Sign In 后方可回复, 如果你还没有账号请点击这里 Sign Up