eosjs icon indicating copy to clipboard operation
eosjs copied to clipboard

why eosjs can not call eos contract

Open healthwallet opened this issue 8 years ago • 5 comments

index.js?ad58:118 TypeError: Unknown struct 'hi' for contract 'eosio', locate this struct or provide serialized action.data action.data = {"user":"2222"} transaction.actions = [{"account":"eosio","name":"hi","authorization":[{"actor":"eosio","permission":"active"}],"data":{"user":"2222"}}] at actionDataAppendByteBuffer (structs.js?aec2:669) at Object.appendByteBuffer (struct.js?3ac1:108) at Object.appendByteBuffer (types.js?9f63:353) at Object.appendByteBuffer (struct.js?3ac1:110) at toByteBuffer (fcbuffer.js?f94e:284) at Function.toBuffer (fcbuffer.js?f94e:271) at _callee2$ (write-api.js?ff8f:616) at tryCatch (runtime.js?ce45:65) at Generator.invoke [as _invoke] (runtime.js?ce45:303) at Generator.prototype.(:8080/anonymous function) [as next] (webpack-internal:///./node_modules/babel-polyfill/node_modules/regenerator-runtime/runtime.js:117:21) (anonymous) @ index.js?ad58:118 callback @ write-api.js?ff8f:571 (anonymous) @ write-api.js?ff8f:778 Promise.catch (async) (anonymous) @ write-api.js?ff8f:777 (anonymous) @ exported-helpers.js?f7c9:69 (anonymous) @ exported-helpers.js?f7c9:79 callback @ process-args.js?8db6:70 callback @ apigen.js?f08d:99 (anonymous) @ apigen.js?f08d:126 Promise.then (async) (anonymous) @ apigen.js?f08d:121 (anonymous) @ exported-helpers.js?f7c9:55 (anonymous) @ exported-helpers.js?f7c9:79 callback @ process-args.js?8db6:70 callback @ apigen.js?f08d:99 (anonymous) @ apigen.js?f08d:126 Promise.then (async) (anonymous) @ apigen.js?f08d:121 createTransaction @ exported-helpers.js?f7c9:48 api.(anonymous function) @ apigen.js?f08d:46 transaction @ write-api.js?ff8f:591 _callee$ @ write-api.js?ff8f:294 tryCatch @ runtime.js?ce45:65 invoke @ runtime.js?ce45:303 prototype.(anonymous function) @ runtime.js?ce45:117 tryCatch @ runtime.js?ce45:65 invoke @ runtime.js?ce45:155 (anonymous) @ runtime.js?ce45:165 Promise.then (async) invoke @ runtime.js?ce45:164 (anonymous) @ runtime.js?ce45:202 callInvokeWithMethodAndArg @ runtime.js?ce45:201 enqueue @ runtime.js?ce45:224 prototype.(anonymous function) @ runtime.js?ce45:117 runtime.async @ runtime.js?ce45:248 _callee @ write-api.js?ff8f:101 dealtable @ HelloWorld.vue?18db:197 click @ HelloWorld.vue?e25d:550 invoker @ vue.esm.js?efeb:2027 fn._withTask.fn._withTask @ vue.esm.js?efeb:1826 structs.js?aec2:669 Uncaught (in promise) TypeError: Unknown struct 'hi' for contract 'eosio', locate this struct or provide serialized action.data action.data = {"user":"2222"} transaction.actions = [{"account":"eosio","name":"hi","authorization":[{"actor":"eosio","permission":"active"}],"data":{"user":"2222"}}] at actionDataAppendByteBuffer (structs.js?aec2:669) at Object.appendByteBuffer (struct.js?3ac1:108) at Object.appendByteBuffer (types.js?9f63:353) at Object.appendByteBuffer (struct.js?3ac1:110) at toByteBuffer (fcbuffer.js?f94e:284) at Function.toBuffer (fcbuffer.js?f94e:271) at _callee2$ (write-api.js?ff8f:616) at tryCatch (runtime.js?ce45:65) at Generator.invoke [as _invoke] (runtime.js?ce45:303) at Generator.prototype.(:8080/anonymous function) [as next] (webpack-internal:///./node_modules/babel-polyfill/node_modules/regenerator-runtime/runtime.js:117:21) actionDataAppendByteBuffer @ structs.js?aec2:669 appendByteBuffer @ struct.js?3ac1:108 appendByteBuffer @ types.js?9f63:353 appendByteBuffer @ struct.js?3ac1:110 toByteBuffer @ fcbuffer.js?f94e:284 toBuffer @ fcbuffer.js?f94e:271 _callee2$ @ write-api.js?ff8f:616 tryCatch @ runtime.js?ce45:65 invoke @ runtime.js?ce45:303 prototype.(anonymous function) @ runtime.js?ce45:117 tryCatch @ runtime.js?ce45:65 invoke @ runtime.js?ce45:155 (anonymous) @ runtime.js?ce45:165 Promise.then (async) runtime.async @ runtime.js?ce45:248 _callee @ write-api.js?ff8f:101 dealtable @ HelloWorld.vue?18db:197 click @ HelloWorld.vue?e25d:550 invoker @ vue.esm.js?efeb:2027 fn._withTask.fn._withTask @ vue.esm.js?efeb:1826

version eos dawn-v4.2.0 eosjs 13.0.0

contract source

using namespace eosio;

class hello : public eosio::contract { public: using contract::contract;

  /// @abi action
  void hi( account_name user ) {
     print( "Hello, ", name{user} );
  }

};

EOSIO_ABI( hello, (hi) ) ~

contract abi

"____comment": "This file was generated by eosio-abigen. DO NOT EDIT - 2018-05-29T08:42:54", "version": "eosio::abi/1.0", "types": [], "structs": [{ "name": "hi", "base": "", "fields": [{ "name": "user", "type": "name" } ] } ], "actions": [{ "name": "hi", "type": "hi", "ricardian_contract": "" } ], "tables": [], "ricardian_clauses": [], "error_messages": [], "abi_extensions": [] }

cleos call run well

cleos push action eosio hi '["2222"]' -p eosio executed transaction: 5795a63f6568e336b788099f4392188263b08fa353a8041ab931bbd13040d346 104 bytes 293 us

eosio <= eosio::hi {"user":"2222"}

warning: transaction executed locally, but may not be confirmed by the network yet ➜ hello git:(00c786974) ✗

healthwallet avatar May 29 '18 08:05 healthwallet

i'm also looking for something like this

vicraft18 avatar May 29 '18 10:05 vicraft18

What account did you deploy the contract too? Unlikely that you deployed it to eosio .. I used inita .. it works like this:

bash$ cleos set contract inita contracts/hello -p inita@active
node$ eos.contract('inita').then(inita => { inita.hi('jim', {authorization: 'inita'}) })

jcalfee avatar May 29 '18 15:05 jcalfee

yes ,i deployed it to eosio ,this account can't deploy contract ??? but it can run well at cleos

healthwallet avatar May 30 '18 00:05 healthwallet

My understanding is that the eosio.system contract gets deployed to eosio and the eosio.token gets deployed to the eosio.token account (or another account of your choosing).

https://github.com/EOSIO/eosjs/blob/v13.0.0/docker/up.sh#L56-L57

jcalfee avatar May 30 '18 17:05 jcalfee

@healthwallet how did you resolve this? Experiencing the same issue.

dominic-healid avatar Aug 13 '18 02:08 dominic-healid