Questions tagged [multi-index]

Questions related to Multi-Indexes for Smart Contracts Tables

Filter by
Sorted by
Tagged with
0
votes
1answer
10 views

call to implicitly-deleted copy constructor

I'm unable to compile a small test contract and am hoping for guidance. I have a class called Account, in the following 2 files: // --- account.hpp #pragma once #include <string> #include &...
0
votes
1answer
20 views

Why I didn't initialize database?

I want to add the my multi_index in controller db. And Finally Adding all class is set up. But When eos program initialize the database, it didn't work. my error log : /eos/libraries/chainbase/...
0
votes
1answer
47 views

How can we retrieve table data with secondary Index in EOS table

this is my table struct [[eosio::table]] payment_made { uint64_t pay_id; uint64_t loan_id; uint64_t pay_amunt; time_point_sec pay_date_req; time_point_sec pay_date_approve; ...
0
votes
1answer
8 views

Multi index table asks an unusual permission to emplace new row

Problem I'm trying to emplace a new row in a multi-index table, but it tells me that I don't have the authotity of the row key name to do it. Code Multi-index table definition struct [[eosio::...
0
votes
1answer
46 views

How to upgrade a multi_index table in a smart contract

I have initially the following multi_index table: struct [[eosio::table]] plastict { uint64_t id; uint64_t type; uint64_t primary_key() const { return id; } }; typedef eosio::multi_index&...
0
votes
2answers
52 views

How to loop a multi_index table in a smart contract

I have very simple table items with the following structure: struct [[eosio::table]] item { uint64_t id; uint64_t state; string description; uint64_t primary_key() ...
0
votes
1answer
48 views

How do I access (sha256) / sort (i128) a secondary/tertiary indices with cleos / curl?

I'm trying to access either of our additional indices of the accountext table. I'm able to access the 3rd index but I'm not sure how to sort it, the second index returns an empty table: // this I ...
1
vote
1answer
26 views

Unable to make use of secondary index in multi-index table

I am trying to add secondary index to my table so I can use it to query for elements based on it. My struct looks like this: struct [[eosio::table]] user { name userAccount; // user ...
0
votes
2answers
53 views

How do I return an iterator?

I have a multi-index defined such that I can do: <type?> test() { myTable t(_self, _self.value); auto r = t.find(...); return r; } but how do I return the iterator? what is the ...
0
votes
0answers
49 views

Search in a multi_index table by multiple fields (compound search)

Here is defined a sample table with four fields, two of them (account and type) I am going to use in my compound search: struct [[eosio::table]] total { uint64_t id; uint64_t account; ...
0
votes
0answers
26 views

Fetching Rows from Table using Secondary Index with Duplicate Values

If I have a table in a smart contract with a secondary (non-unique) index, and I am retrieving the rows in this table via the RPC get_table_rows endpoint, how can I retrieve all the rows in the table ...
1
vote
0answers
20 views

Fetching More Table Rows via RPC

I have a contract with a table in it. I'm querying the contents of the table using the RPC interface, but I'm having trouble getting all the rows. To limit the memory usage of my application, I'm ...
2
votes
1answer
57 views

What is the meaning of “scope” in a Smart Contract?

Since I have read the tutorial. I don't understanding the following: Note that scopes are used to logically separate tables within a multi-index (see the eosio.token contract multi-index for an ...
1
vote
1answer
112 views

How to create composite primary key?

I have a table of prices where I want to store 2 prices per cross defined like this: struct [[eosio::table]] _prices { symbol base; symbol quote; float value = 0.0; uint128_t ...
0
votes
0answers
27 views

How to return a record found?

suppose I have: struct [[eosio::table]] _test { asset supply; uint64_t primary_key() const { return supply.symbol.code().raw(); } }; typedef eosio::multi_index<name("test"), _test> ...
0
votes
0answers
47 views

how can I get sorted table rows by using getTableRows()?

my contract: user.hpp: struct [[eosio::table]] user{//[[eosio::table]] // uint64_t id; // string username; // uint64_t id; //rank ...
0
votes
1answer
69 views

How do you define uuid indexes in contract tables?

I would get table entries by uuid. how can I convert string format 16cadf15-dda7-4be2-8026-c3c7875322d0 to an indexable eosio type ( uint64_t, uint128_t, uint256_t, double or long double). Or even ...
4
votes
1answer
223 views

Get Table Rows with Pagination

How do we get records from a table by pages? My requirement: I have a table with 100 records and want to display all these records in my front-end-application with 10 records per page and if the user ...
1
vote
1answer
92 views

Retrieve data from multi index table

I found that it is possible to define up to 16 secondary indices for a multi index table. Is it possible to return data from the table using these secondary key? I have a table like, result is set as ...
0
votes
1answer
33 views

How is memory aligned in the EOSIO smart contract consensus memory?

Are there any memory savings if I declare a table record that has, say, a 64-bit integer (occupies 8 bytes) and a 16-bit integer (occupies 2 bytes)? Or is it aligned at 64 bits and said record would ...
0
votes
1answer
32 views

why i get “uniqueness constraint was violated” on error on empty table?

i defined a table but i made a mistake putting the fields in wrong order within EOSLIB_SERIALIZE EOSLIB_SERIALIZE( tablename,(field1)(field4)(field3)(field2)); i did some insertions with emplace ...
0
votes
1answer
34 views

Contract won't keep index count inside index table

Attempting to keep track of an index for future use as an index in another container. uint64_t namehash = ::eosio::string_to_uint64_t(my_name.c_str()); auto name_iter = ...
5
votes
1answer
466 views

How to use checksum256 secondary index to get table rows

Does anyone know the correct way to get table rows using checksum256 (fixed_bytes<32>) secondary index through the get_table_rows RPC API? I found a way using key256, but key256 is deprecated ...
1
vote
1answer
71 views

Search multi_index by nonprimary key

#include <eosiolib/eosio.hpp> using namespace eosio; class [[eosio::contract("addressbook")]] addressbook : public eosio::contract { public: using contract::contract; addressbook(name ...
0
votes
2answers
116 views

Multi_index issues

I'm getting a lot of errors related to multi_index after updating to the newest eosio.cdt. Here is part of my code related to hash. struct st_hash { capi_checksum256 hash; uint64_t expiration; ...
0
votes
0answers
23 views

why it prints only one “record/row”?

I created a table with 5 rows/records. I tried to print the whole table content with the following code: require_auth(_self); accounts_table accounts(_self, _self.value); for(auto itr = accounts....
1
vote
1answer
91 views

Is there a way to query table with the value of a particular data field

Is there a way to query table with the value of a particular data field (for example, a token value) when using 'get_table rpc'? Only users whose token value is greater than 30 are output.
1
vote
0answers
27 views

cannot get latest state of table after modifying table in inline action

As shown with code below, I modify table in an inline action, and then want to get the latest data. But the data I get is not the latest. Why? void mycontract::myfunc() { action ( ...
2
votes
1answer
208 views

Iterating through secondary indices

I have a table with some secondary indices. I want to iterate through the rows whose values are act >= 1 and discard the rest. So: table holders(_self, _self.value); auto index_by_act = holders....
0
votes
1answer
119 views

EOSIO: name.value secondary index returns end iterator, even though searched value exists in table

I've got a multi-index table going with two secondary indices: TABLE entry { uint64_t id = 0; eosio::name player; std::vector<uint16_t> allocation; ...
2
votes
1answer
186 views

Using name as secondary index

I want to save name in table, and to search by it. It doesn't seems that it is possible to have secondary index with type name for some reason. I would like also to pass name in function and to have ...
3
votes
1answer
272 views

How do I create a Multi-Index DB secondary index from a String?

I'm developing a Smart Contract for EOSIO. I have a Multi-Index table with a uint64_t primary key. I'd like to add a secondary index to the table. Ideally the data I'd be indexing on would be a std::...
1
vote
1answer
204 views

Multi Index table local instance

I am creating a local instance of multi index table (following the example given in this tutorial: https://developers.eos.io/eosio-cpp/docs/using-multi-index-tables) but when I try to compile I get ...
4
votes
1answer
89 views

BUG when two accounts send action at the same time to modify multiindex table

It took me several days to find the bug. I got a table like this TABLE t {uint64_t key, name player1, name player2, uint64_t status}; When the contract received the specific action, it will go ...
2
votes
1answer
107 views

Performance: Would it be a problem to store 100,000 or 1,000,000 rows in a multi_index table?

So, let's say we had the necessary ram, cpu, and net to store a lot of records in a multi_index table. (100,000 to 1,000,000). Considering that a transaction in EOS has a max execution time (150 ms), ...
1
vote
1answer
175 views

How does “tablename”_n differ to N(tablename) when defining a multi_index?

I've seen two examples of how to define the table name of multi_index: N(tablename) "tablename"_n (source) Initially I tried using the former, but resulted in the below compilation error. I have ...
3
votes
2answers
243 views

Is it possible to use a type other than uint64_t for a table primary key?

I want to use a uint128_t as a primary key in a multi_index table. Is this possible? If so, how should the ABI file be written to accomodate it?
1
vote
1answer
38 views

Why don't need ram_payer for erase method in mulit_index class?

mulit_index class has three methods (emplace, modify, erase) to update a table. emplace and modify methods need to select ram_payer. But erase method doesn't need to select it. I think these methods ...
2
votes
2answers
196 views

Using Demux to store data offchain in EOS blockchain

Does anyone have any idea dea how to use Demux with EOS Blockchain. There is this repo where they give example how to use Demux. I want to ask if there is any example for how to "use Demux without ...
2
votes
1answer
76 views

Stored vector of strings in table implicitly converting to vector of unsigned char, why?

I'm trying to store an object in a multi-index table with one of the members a vector of std::string. When retrieving the data however it comes back as a vector of unsigned char, and I can't do ...
2
votes
1answer
93 views

About Updation of contract

I have 2 questions about updation of contract and multi-indexed tables? 1)Can i update contract as if i want to change ram payer for multi indexed tables can i change it after deploying contract ? ...
1
vote
2answers
409 views

Multi_index query with new CDT

Because name is no longer a uint64_t type I created my struct like this: struct [[eosio::table]] game { uint64_t id; //auto increment name host; name guest= name("none"); name ...
2
votes
1answer
225 views

Samples with eosio.cdt v1.3.0? multi_index with secondary indexes and get_index

Has anyone been successful getting a contract which uses secondary indexes to compile against the latest versions of the CDT (1.3.2)? I'm having trouble and don't see any updated samples which use ...
0
votes
1answer
41 views

Maximum number of multi index tables an account can hold

Is there a limit on the number of multi index tables an account can hold? Is it limited by the RAM?
2
votes
1answer
105 views

Multi-index storing complex types

Is it possible to make a multi-instance table of a struct Base with a couple of virtual methods, and then store entries of derived classes and have it be able to differentiate? So ie: struct animal { ...
1
vote
1answer
295 views

Trying to pass a sha256 hash to my contract and store it

I'm new to the EOS platform. For my use case I'm trying to pass a sha256 hash to a function in my contract and store it in a table which is indexed by that hash. I've realized you can't have the ...
1
vote
3answers
98 views

I want to have permissioned data access over eos

Is it possible to have permissioned data access? Suppose I am having a multi_index table and whoever adds data to that table only can access the data because I am having a table storage and one ...
1
vote
1answer
56 views

Same name table of different contracts got merged

I wrote a contract, suppose C defining the multi-index table T. Table struct has two parameter suppose x and y. x was the primary key. I made some entries in T and when i tried to access it back, I ...
1
vote
1answer
119 views

How to erase data with secondary index?

auto index = table.get_index<N(exp)>(); auto upper = index.upper_bound(100); for(auto itr = index.begin(); itr != upper; ) { itr = index.erase(itr); } above is not work, who can give me an ...
0
votes
2answers
75 views

A contract without struct and multi index table

Actually, I am looking to create a contract in which a variable can be set and later on can be retrieved. All the contracts available there involves struct and multi index table. In EOS, is it ...