Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [multi-index]

Questions related to Multi-Indexes for Smart Contracts Tables

0
votes
0answers
15 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
27 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 ...
1
vote
0answers
26 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
38 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
25 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
22 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
23 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 = ...
2
votes
1answer
122 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
38 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
77 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
21 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
44 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
26 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
92 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
65 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
112 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
154 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
154 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 ...
5
votes
1answer
74 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
85 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
138 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
143 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
35 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
126 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
53 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
62 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
304 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
195 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
33 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
82 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
222 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
82 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
55 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
98 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
61 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 ...
5
votes
2answers
120 views

Where should tables be created? In the contract or in each action?

In the simple blog dapp (https://github.com/EOSIO/eosio-project-demux-example) the table (for posts) was defined in the contract but is not instantiated as a field. What are the advantages/...
4
votes
1answer
49 views

Is it possible to see the state of a multi index table for a given block number?

Does the ability currently exist in EOS to see how the state of a persistent memory table was at some point in the past?
2
votes
1answer
138 views

Multi-index table logic

I'm new to smart contracts and I'm having difficulty understanding the logic behind instantiating multi-index tables and how they persist. For example in the addressbook example, it seems a new ...
1
vote
1answer
104 views

The relationship between the Multi-Index DB and block chain?

From the document, I should save data in the Multi-Index DB, I want to know: Does it mean the data is saved into the block chain if I save the data in the DB? If yes, how the data is saved into block ...
2
votes
2answers
269 views

How can I know if I pay ram for a row in a table?

I am creating a non-fungible token. While I own the token, I pay ram for it. After transfer of the token the new owner should pay for it. My token contract updates the payer as soon as the new owner ...
2
votes
0answers
152 views

What are the main differences betwen EOSIO multi_index and Boost multi_index?

Inspired by this comment, I was wondering what are the main differences between eosio::multi_index and boost:multi_index and why do they exist? The documentation notes that there are important ...
2
votes
1answer
103 views

Error 3160003: Invalid table iterator

Getting the Error 3160003: Invalid table iterator error while trying to execute: cleos push action voting.debug debug '[ 0 ]' -p user@active I have a simple voting contract (full code) where I'm ...
3
votes
2answers
404 views

Purpose of multi_index scope

I am trying to understand what the purpose of the scope in multi_index is. Does it have performance/cost implications to put all the rows in the same scope and then just query using the keys? A ...
1
vote
1answer
145 views

How to set the “ —key-type” parameter and “--index” parameter of v1/chain/get_table_rows function?

how to set as the --key-type and --index parameters when i use the http api "v1/chain/get_table_rows" as cleos commend "cleos get table eosio eosio namebids --key-type i64 --index 2". the "--key-type"...
2
votes
1answer
97 views

Multi index can access data in contract but (RPC) cleos get table is empty

Here is the code I deployed it with the following command: cleos set contract . demo.wast demo.abi -p demo and query it with: cleos get table demo demo demos
0
votes
1answer
196 views

How should I get the data of the multi_index database?(about contract)

The return value of the action function can only be void type. I can't get data by return value. Now I have saved multiple objects in the multi_index database. I want to get them at once, what should ...
1
vote
1answer
415 views

How to access multi-index from other contract?

Contract A created a multi-index table pets like pets(_self, _self); ... pets.emplace(user1,...); Now in contract B, I would like to update a row like pets(N(A), N(A)); ... pets.modify(pet, user1, ....
2
votes
1answer
376 views

multi_index query [WHERE]

How do we query tables in EOS? Specifically like the WHERE clause in SQL Database? I see examples that uses iterator to find if the record exists, however I don't see it as the right approach ...
2
votes
2answers
690 views

HOWTO: auto increment primary key?

How do we do this in EOSIO multi_index table? Want to define a table with an auto increment primary key id.
0
votes
1answer
197 views

Is all Multi-index data stored in memory [duplicate]

I wanna know is all index data stored in memory?Is so, what if the BP suffer from ddos attack? and how to store data on disk?