智能合约 eos.js 调用 Helloword 合约都失败了
经过漫长的学习,大多数经历跟环境在做斗争,从 EOS 的环境搭建到各种命令的学习,到最后智能合约的部署和调用都成功了
后面尝试做一个简单的 DAPP,就是他 ping-eos
合约嘛,我都部署了,命令行里都可以成功
就是用 eos.js 去调用就是不行,一直觉得是配置问题
const EOS_CONFIG = {
contractName: "pingacount", //合约执行账户
contractSender: "pingatest", // 合约测试账户
clientConfig: {
keyProvider: ['5HwAGYEZp4EXndzogy32tp3WYEYRVbAp53M9LS4kbWbG745H4u2'], // 合约测试账户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) })
})
}
看 js 代码没毛病啊,就是调不通,错误如下:
apigen.js:97 POST http://127.0.0.1:8888/v1/chain/push_transaction 500 (Internal Server Error)
apigen.js:118 api error => http://127.0.0.1:8888/v1/chain/push_transaction {"compression":"none","transaction":{"expiration":"2018-10-13T07:57:15","region":0,"ref_block_num":6156,"ref_block_prefix":4058033983,"max_net_usage_words":0,"max_kcpu_usage":0,"delay_sec":0,"context_free_actions":[],"actions":[{"account":"pingacount","name":"ping","authorization":[{"actor":"pingatest","permission":"active"}],"data":"0000c85865c3a6ab"}]},"signatures":["EOSJuKqks2PbRxwarrT5dReftvxcGmn2bqHN28TqWG7kAF6sbKi1Y5S5bhaPfqQJpoKXFKVfqS4diXxtehsbySZUSsBeWZgUV"]} Error: {"code":500,"message":"Internal Service Error","error":{"code":3010011,"name":"packed_transaction_type_exception","what":"Invalid packed transaction","details":[{"message":"Invalid packed transaction","file":"chain_plugin.cpp","line_number":770,"method":"push_transaction"},{"message":"pivot != std::string::npos: No delimiter in string, cannot determine type: EOSJuKqks2PbRxwarrT5dReftvxcGmn2bqHN28TqWG7kAF6sbKi1Y5S5bhaPfqQJpoKXFKVfqS4diXxtehsbySZUSsBeWZgUV","file":"signature.cpp","line_number":20,"method":"parse_base58"},{"message":"Failed to deserialize variant","file":"abi_serializer.hpp","line_number":516,"method":"from_variant"}]}}
at eval (apigen.js:102)
"code":3010011,"name":"packed_transaction_type_exception","what":"Invalid packed transaction","details":[{"message":"Invalid packed transaction"
错误关键在这里
希望有大佬知道的,路过的,回答一下呗