3

I've been looking at most of the example contracts and every action seems to return void. Does this mean that you can not have a return type for your actions? Instead, would you have to send a different get command to access data from your contract, i.e. "cleos get ".

If I wanted to return some data after calling an action is there a procedure for doing so?

Thanks.

  • No, you can add print and query the transaction to get console output, or you can store your result in table and query – Jimmy Guo Aug 17 '19 at 4:22
1

No, there's not. If you want to read data you must use cleos get table for Smart Contracts tables data or cleos get actions to see all the actions and transactions history data. Remember that, inside your action, you can always read data from your contract tables, or even external contracts ones.

After you push a transaction you can use the get table/actions to query results. I think the problem here is that you might wait 500ms (max) if you really want to make sure to query correct data (you won't do that for a "Facebook Like" action, but if you need to confirm a user balance from a token transfer).

  • 1
    Is this strictly true of all contracts? If so, how does cleos get currency balance work? – kkurian May 22 '18 at 22:11
  • 1
    @kkurian currency balance is stored in multi_index table. You can get same result by cleos get table eosio.token ${username} accounts. – conr2d Jan 2 '19 at 9:45
  • Yes, indeed. :-) – kkurian Jan 6 '19 at 19:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.