Stack Exchange Network

Stack Exchange network consists of 174 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
27 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; ...
0
votes
0answers
23 views

How to implement CRUD with a two-fields (or more) secondary index table in EOS?

I want to create a table in an EOS smart that has a secondary index of consisting of two fields like for example: ItemsBoughtByUser table with fields: username, itembought, itemtype. Example data: ...
2
votes
1answer
50 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 ...
2
votes
0answers
57 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
79 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 ...
3
votes
1answer
32 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 recieved the specific action , It will ...
2
votes
1answer
55 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
48 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
77 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
30 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
73 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
36 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 ...
1
vote
0answers
23 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
158 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
0answers
119 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
27 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
49 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
131 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
63 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
47 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
62 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
48 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
76 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
36 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
82 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
80 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
169 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
116 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
73 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
288 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
106 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
89 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
178 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
281 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
328 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 ...
1
vote
2answers
432 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
164 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?
1
vote
0answers
81 views

How do I see how many objects are in the multi_index table? [duplicate]

Is there a simple way to get how large the table is? like: table.size()
1
vote
1answer
166 views

How to understand RAM and log storage from the view of Smart Contract?

The knowledge on RAM and smart contract is obscure to me. In white paper, RAM is defined and I know now there're only 64GBs in total. However in developer manual https://developers.eos.io/ it never ...
1
vote
0answers
134 views

how to make public_key to be table index?

The contract in eos only support idx64, idx128, idx256 type for the secondary index, and key only support idx64, how can I set the public_key as the index? The public_key in is char[34], it's length ...
1
vote
1answer
459 views

Multiple parameters for search

I understand how to use primary and secondary keys for index. I want to search the primary key for all payments by a specific user. Then from that result set I want to search by a secondary key to see ...
9
votes
1answer
948 views

Delete all multi_index records without iterator?

I am running a multi_index in my contract and want to include an abi action that will clear it. Is there a clever way to delete all records? At the moment I am using something like this: //@abi ...
7
votes
1answer
102 views

Table key smaller than 64bit

Here is my some code. To reduce the data size, 'id', 'knight', and 'sale_id' are not uint64_t, even though they are keys. Because 'primary_key()', 'by_knight()' and 'by_saleid()' functions convert ...
1
vote
0answers
234 views

How do I add second and third indices to the multi_index object?

I have thoroughly read the documentation and isolated my problem down to a small set of sample code. I'm not sure where my problem is. I am trying to add multiple indices to a multi_index object so ...
9
votes
2answers
502 views

Is there a function to return the size of a multi_index table?

Is there a function to return the size of a multi_index table? If not is there a better way then looping through them? uint64_t count; for (auto itr = table.begin(); itr != table.end(); ++itr) { ...
0
votes
1answer
105 views

Can an arbitrary account add to a table (eosio::multi_index) belonging to a particular account?

I'm imagining elements in a queue that correspond to a particular class/struc format being added to a master list by an arbitrary account. Any easy way to create such a list via a contract? I'm also ...
3
votes
1answer
162 views

Can an action in a smart contract concurrently executed?

In a smart contract if an action is executed simultaneously and if it tries to modify the same record in a table(using multi index API), How to add mutual exclusion to the shared resources? For eg. ...
2
votes
1answer
316 views

How to allow duplicates in an eosio::multi_index object?

How do I create a struct and multi_index table that allow for duplicate records? For example, I have the below struct and multi_index table that is populated via an emplace call that selects a ...
4
votes
1answer
282 views

How to set “deep structures” for Smart Contracts Tables?

I have a table that I'm playing with that I want to have a map that links the id with a specific structure. I tried to use map and the code compiles fine, but when generating the abi file it takes ...
8
votes
1answer
340 views

How to use two secondary keys as a filter? (WHERE f1 AND f2)

In the contract multi index tables we can filter by the primary key or we can just create an indexed_by as an additional index. Then we have basically two options: filter by the primary key or ...