GetScatter / scatter-js

Importable JavaScript library that allows web applications to directly interface with Scatter Desktop, Classic and Mobile.
MIT License
262 stars 148 forks source link

Can't call eos contract by use WalletAPI CreateTransaction #148

Closed AnyPang closed 5 years ago

AnyPang commented 5 years ago

I want to use WALLET_METHODS.createTransaction to call a contract,but it didn't callback and responses nothing.

Here is a part of my code: const network = ScatterJS.Network.fromJson({ blockchain:'eos', chainId:'e70aaab8997e1dfce58fbfac80cbbb8fecec7b99cf982a9444273cbc64c41473', host:'api.jungle.alohaeos.com', port:443, protocol:'https' }); ScatterJS.connect('MyTest', {network:network}).then(connected => { if(!connected) { console.log("connect false"); return false; } const requiredFields = { accounts:[network] }; ScatterJS.getIdentity(requiredFields).then(identity => { const account = identity.accounts.find(x => x.blockchain === 'eos'); console.log("getIdentity", account.name); const action = { contract:'eosio.token', action:'transfer', params:[account.name, "eosio", "0.0100 EOS", account.name + "transfer to eosio"] }; ScatterJS.createTransaction('eos', [action], account, network).then(result3 => { console.log("createTransaction", result3); }); }); });

Anybody tell me how to fix it?

nsjames commented 5 years ago

createTransaction should not be used. That is a deprecated method used for languages with no pre-existing libraries.

You should be using eosjs after instantiating the ScatterJS.eos(...) object to send transactions. See the readme on this repo, and the quick-examples for more information.