2

What is the meaning of scope argument in the get table command?

For example, in the todo_contract, (https://developers.eos.io/eosio-cleos/reference#cleos-get-table)

we have

cleos --wallet-url http://wallet:5555 -u http://server:7777 get table mynewaccount todo todos

The scope is todo. I just wonder where todo comes from.

One more question is how to display the rows entirely.

The get table command shows only 10 rows.

At the end, I have

  "more": true
}

How can I see the rest of the rows?

1
  • try cleos --wallet-url http://wallet:5555 -u http://server:7777 get table mynewaccount mynewaccount todos Dec 18, 2018 at 11:08

1 Answer 1

8

Meaning of scope

You can just make up a scope as you go along. As a general rule there are 3 ways to use the scope:

Globally - all table entries are kept in one scope (usually with the name of the contract)

cleos get table censuscensus global population

Groups - All table entries that are similar in some way share the same scope

cleos get table censuscensus male population

Individual - Each entry has its own scope (usually used to obfuscate or have quick access)

cleos get table censuscensus phillhamnett population

Seeing all table rows

To see all table rows, just add -l -1 (minus el, minus one) somewhere after get table.

Within smart contract

Lets say you have a typedef set up in a smart contract for a multi_index array.

typedef eosio::multi_index< eosio::name("censuscensus"), struct_for_table_goes_here > census_table;

You can set a scope when you initialize the census_table:

census_table global_table(get_self(), eosio::name("global").value);
census_table male_table(get_self(), eosio::name("male").value);
census_table individual_table(get_self(), eosio::name("phillhamnett").value);

You don't need to do anything else to start using the table with the scope other than initialize it as shown above

6
  • Thank you for your answer. Then, the problem is how we can set the scope for a given table. At least in the todo_contract example, there is no step to set or configure the scope "todo". It seems that I can use any string instead of todo when I use the "get table" command. Dec 18, 2018 at 7:35
  • I will update my answer to give more examples within a smart contract. Dec 18, 2018 at 11:04
  • No problem. If my answer solves your question, you should upvote it and choose "accept answer" in order to help other people in the future. Dec 19, 2018 at 9:47
  • I also added a bit that shows how to get more than 10 rows from the table Dec 19, 2018 at 10:04
  • Got no known conversion from 'eosio::name' to 'uint64_t' and after looking at the tictactoe example I added .value, ie. eosio::name("global").value
    – standup75
    Aug 19, 2019 at 21:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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