1

I have build a Smart Contract with 14-15 Tables for I/O. It will be used to store important data of our platform. I have used require_auth(_self) as this contract will not be used by 3rd person. It will be used to insert data and retrieve it by a single account.

So is the Authorization valid? Or I need to use get_self(). I started working on EOS from last 5 days and I need to deliver the project.

It takes close 900Kb of RAM to deploy on Testnet. How to optimize it.

There are more than 50 String Data types in struct can it be replaced by something else to optimize usage?

What kind of integration I would need in my Node Server to Call this transactions? Would I need a Wallet or I can store the private key in contract itself.

Sample Function:

// Service Request Table

struct [[eosio::table]] service_req {
  uint32_t        ID;
  std::string     subscription;
  std::string     service;
  std::string     status = 'pending';                              
  
  auto primary_key() const { return ID; }        

};

typedef eosio::multi_index<name("srvreqs"), service_req> srvreqs_table;   

srvreqs_table _srvreqs; 

Thanks In Advance

1

Separate your question into multiple posts next time. Q&A in stackoverflow become a knowledge base for those who experience similar issue, but this kind of question is difficult to be referred by others.

  1. They mean same. get_self() returns _self. [link]

  2. Contract deployment consumes 10x of wasm binary size. There are several optimization options to reduce binary size, but it is difficult to tell without seeing your code.

  3. It depends on the contents of the string. Are there many duplications among strings, are those strings are case insensitive? Without these kinds of information, it's also hard to explain an efficent way to store them.

  4. You can use JsSignatureProvider provided by eosjs in development, but will need a secure way in production environment.

4
  • 1. Ok So if I dont want any payer then I can use require_auth(_self) ------- 2. I will share a snippet of Insert Method // Service Request Table struct [[eosio::table]] service_req { uint32_t ID; std::string subscription; std::string service; std::string status = 'pending'; auto primary_key() const { return ID; } }; typedef eosio::multi_index<name("srvreqs"), service_req> srvreqs_table; srvreqs_table _srvreqs; ---------------- 3). Case is insensitive Dec 10 '20 at 13:47
  • 4). What to do in case of Production? I need to deploy in production. Sorry cant post the whole contract as it has 1000 Lines of code. Dec 10 '20 at 13:55
  • It's hard to share optimization options here. They are related requirements to your project, too. For example, you can make a shared string reference table, and each row keep the index of the string, not raw string itself. However, if you need to use standard get_table_rows RPC API for fetching data from blockchain, you cannot use this shared string reference table. (You need a backend API server to convert data to your required format.)
    – conr2d
    Dec 11 '20 at 1:36
  • You have a valid point. I have an backend API to process though it will be better if I keep the struct in same way. Yes I would be using get_table_rows. Can you please check my other post as well. Thanks in Advance. Dec 11 '20 at 5:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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