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
30 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
15 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
55 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
20 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
28 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
24 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
42 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
48 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
87 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
100 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
116 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
67 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
73 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
84 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
111 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
92 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
48 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
41 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
230 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
168 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
31 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
65 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
178 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
68 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
53 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
81 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
56 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
101 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
46 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
110 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
93 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
230 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
135 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
89 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
343 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
132 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
91 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
187 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
348 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
359 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
545 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
183 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
87 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
172 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 ...
2
votes
1answer
154 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
551 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
1k 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
107 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
253 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 ...