Questions tagged [smart-contract]

Anything related to decentralized application (dApp) development, concepts, and possibilities with smart contracts, or technical questions for the development of smart contracts.

Filter by
Sorted by
Tagged with
4 votes
2 answers
3k views

Require inline action be sent by contract, and not account

I have contractB trigger an inline action: /// @abi action void send() { action( permission_level{ _self, N(active) }, N(contractA), N(get), std::make_tuple( _self ) ...
  • 91
5 votes
1 answer
3k views

How to do an action in a contract to transfer tokens to other user accounts without adding permission in dawn4.0? [closed]

How to do an action in a contract to transfer tokens to other user accounts without adding permission? Actually, in dawn3.0 i can use the function like this below, but in dawn 4.0 it doesn't work ...
  • 555
11 votes
2 answers
601 views

How to airdrop a new token to EOS holders?

If I'm developing a project on EOS that will require a new custom token I might want to do an airdrop of that token to existing EOS holders. Are there best practices on how to go about that? Roughly ...
  • 674
8 votes
2 answers
473 views

Best practice to handle table migrations?

What is the best practice for migrating table when a member of a struct is added? For some structs, I have had no problems adding members, but for others I have. I get this error message: $cleos get ...
  • 411
3 votes
5 answers
764 views

Cryptographic Operations in Smart Contracts?

Is it possible to perform cryptographic operations inside a smart contract? I'm specifically thinking about simple hashing (SHA-1/256/3) and symmetric encryption (AES). Obviously, handling key ...
  • 1,844
16 votes
2 answers
3k views

How to read tables from other smart contracts?

I tried to look for inside the EOS repository and contracts examples but I could not find anything like this. I want to know how can I read another contract table. So, as an example: my contract ...
  • 3,023
3 votes
3 answers
1k views

How to store contract state as singleton?

What is the best way to store fields specific for contract, for example if contract has 3 fields (2 strings, 1 uint64_t) and they can be changed? Should I create new table for this, it would always be ...
  • 281
2 votes
1 answer
1k views

require_auth differs from the auth check of INLINE_ACTION_SENDER but how?

In a contract action I've got the following: require_auth(from); // NOTICE THIS LINE... INLINE_ACTION_SENDER(contract, transfer)( N(contract), {from, N(active)}, // ... AND THIS LINE. {...
  • 695
11 votes
1 answer
966 views

What are naming rules for actions, tables and contracts?

Since strings internally are converted to uint64 for space efficiency on the eos.io blockchain what are the restrictions that need to be followed for: actions tables index identifiers (within ...
10 votes
3 answers
2k views

How to do an inline transfer of a token?

When I perform a token transfer from the cleos command line, it works with no problems: $ cleos push action eosio.token transfer '["rider2","vehicle1","1000.0000 TOK","initial"]' -p rider2 executed ...
  • 411
9 votes
2 answers
1k 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) { ...
8 votes
2 answers
820 views

Encrypting with a public key

I have user specific data in a table on my smart contract that I don't want others to see. Can I encrypt that data with a public key of the user? If possible then how to encrypt that data with the ...
  • 103
7 votes
1 answer
577 views

Can we add the permission to access the table?

I know how to declare ,initialize and get,set values in a table .My question is Can we add permission to access the table to a particular user inside our smart contract ?
6 votes
2 answers
327 views

How is the total available capacity (ram/cpu/bandwidth) communicated among block producers

The token model section of the eos.io white paper states: Block producers publish their available capacity for bandwidth, computation, and state. This is a bit vague and I am trying to answer a ...
  • 885
5 votes
4 answers
880 views

How can I get my contract currency balance with c++ code?

I want to get my contract currency balance within my contract code, but the eosio::account::get (account_balance &acnt) cann't use, so how can I do that?
  • 393
4 votes
1 answer
107 views

How to check (within a smart contract) if an account has an associated smart contract?

Is it possible to check if an account has a smart contract, from within a smart contract?
4 votes
3 answers
618 views

Can not find <eosiolib/eosio.hpp> when compiling with eosiocpp #2

I'm trying to compile any smart contract. Let's say the skeleton one. When running eosiocpp -o it can't find the header file for eosio. Not a duplicate of Can not find <eosiolib/eosio.hpp> when ...
3 votes
1 answer
439 views

How to push a vector to an action

I'm troubled with a problem about how I can use command line cleos push action to push a vector to an already existing action, such as: void vectortest(const std::vector &vec) ; Anyone who can ...
  • 163
3 votes
1 answer
315 views

ICO/Payment contact

Anyone is working on some ICO/Payment contacts? What I would like to learn are following functionalities within the contract: Payment, where the fee is split into 3 accounts. a) So user sends a fee ...
3 votes
1 answer
367 views

Getting account CPU usage in smart contract

Is it possible to access the CPU usage of a given account from within a smart contract? For eg. in a smart contract transfer notification, you call get_account_info(N(some_account_name)) which ...
2 votes
1 answer
97 views

Is it possible to create new contract from another?

Ethereum has a opportunity to create new contract from another. Does eosio has the same? I found a code with new account creation, but I didn't find nothing about setting code and abi from contract.
2 votes
2 answers
580 views

Compile error: undefined symbol: apply

I am following the tutorials on EOS's Developer's Portal. My EOS build was successful. I initially had errors with BOOST but it ran fine when I installed it the second time. This is the code from ...
  • 73
2 votes
1 answer
1k views

How to get block info (e.g. block hash code) in smart contract?

I want to use action context information, such as block hash code, to generate number as "random" numbers in smart contract. But I can't find any interface to get block hash code.
  • 320
2 votes
1 answer
464 views

How can I send or store an arbitrary text message to another EOS account?

I wan't to be able to send a text string to another EOS account. How can this be done? Are there any mobile wallets that support this?
0 votes
2 answers
1k views

Convert string to float or double

I am trying to convert a string to a float or double, however none of the standard C/C++ methods seem to work. I have tried: atof strtof strtod sscanf In each case, I get an error message when ...
0 votes
2 answers
807 views

Why is [[eosio::on_notify("eosio.token::transfer")]] not working?

Network: kylin testnet. I transferred eos to this contract, but it the "deposit" function was not called. What do I miss?
  • 1
12 votes
1 answer
2k views

What is the purpose of `require_recipient`?

I saw the description of the function require_recipient and it says: Add the specified account to set of accounts to be notified I would like to understand what's the purpose of receive this ...
  • 3,023
9 votes
1 answer
2k views

How to clear all of the data in my contract table? [duplicate]

I know I can user erase to clear the table, but this method only clear one data at a time and must write a action to do that. Is there any easy way to do that?
  • 393
9 votes
2 answers
632 views

Which version of C++ can I use in smart contracts?

Which version of C++ can I use to implement smart contracts? For example: C++11, C++14 or C++17? Do we have any constant or doc where it is defined? Also, in my understanding the code is sandboxed, ...
  • 536
8 votes
1 answer
919 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 ...
  • 3,023
7 votes
2 answers
417 views

Is there a flaw in deciding who can pay for RAM?

Lets say I interact with an action from a smart contract, if I'm not careful and didn't read or couldn't understand the source code for the smart contract, is it not possible that the contract could ...
7 votes
3 answers
1k views

Why the first time I execute an action I get "Error 3080006: transaction took too long"?

WHAT I WANT Call an action and see it succeed at the first execution. WHAT IS NOT WORKING The function, which I am executing, the first time fails with error: Error 3080006: Transaction took too long ...
7 votes
1 answer
458 views

How do you define who pays and who stores on your Smart Contract tables?

Sometimes I find myself lost deciding how I will store data for my application. I have a dilemma about: Decentralization vs Accessibility for everybody? Looking to this table, which manage DAOs: // ...
  • 3,023
6 votes
3 answers
1k views

Is there event emitting function in smart contract?

I am porting Ethereum smart contract in Solidity to EOS platform, but I meet a problem: how to send some events to Dapp so as to update the UI? Now I have to poll the table the smart contract saved ...
  • 320
6 votes
3 answers
1k views

When to use or not use the Contract Scope?

Analyzing the eosio.token contract we see that the token stats is stored under the SYM scope. So if I want to read a token stat, like supply, I need to execute: cleos get table eosio.token EOS stats ...
  • 3,023
5 votes
1 answer
595 views

How to calculate the RAM size of a contract in EOSIO and then i can know how much EOS i need to pay for every contract

How can I calculate the RAM size of a contract in EOSIO? I mean, is there any tool from EOSIO? Could this tool help me to know how much EOS I need to prepare for every contract.
  • 555
5 votes
0 answers
99 views

Releasing your RAM, not caring for pre-existing records [duplicate]

Say if, I push an action to an existing contract on the EOS main net. This action creates a record in a table/multi index container with me as the payer in the emplace method. No other action ...
4 votes
1 answer
647 views

"dice" contract "withdraw" action problem

I wonder if anyone experienced a similar problem and managed to resolve it. I'm testing the "dice" contract on my local tesnet. I've setup up all necessary contracts and could deposit assets to the "...
  • 63
4 votes
1 answer
823 views

Getting an unknown key error while transfer some EOS form one account to another

I have written an action transfer in my contract which is as below // @abi action void second::transfer( account_name from, account_name to, asset ...
4 votes
3 answers
1k views

`env.is_feature_activated` error when set contract

I'm trying to set up my eos enviroment. When I post the system contracts I get this error msg: Error 3070000: WASM Exception Error Details: env.is_feature_activated unresolveable enviroment: ubuntu ...
4 votes
1 answer
914 views

How to get accounts info in smart contract

How can I get accounts info in a smart contract? Or if given a public key and account_name, is there any way can verify that account has this public key in a certain permission?
4 votes
1 answer
151 views

How RAM was allocated in dapp and how to optimize the table?

We are doing dapp development on EOS. And it seems cost more ram than we evaluated. How much ram will be used when stored a table record? And how to optimize the table structure to save the ram? See ...
  • 1,066
3 votes
2 answers
745 views

How to send EOS based tokens from one account to another?

While playing a game on Dapp if we want the user to donate some tokens in order to join the game, how can we accomplish it in the smart contract?
3 votes
2 answers
315 views

Can we freeze our deployed smart contract?

Actually, I am a little bit confused about when we say that we can freeze a deployed smart contract and cannot perform any transaction till it is unfrozen. And we can unfreeze the contract after ...
3 votes
1 answer
385 views

What's the relationship between eosio-abigen and eosiocpp?

I am running stable version v1.1.2 After running eosio_build.sh, there are one eosio-abigen executable which locate at /build/programs/ and another one is eosiocpp which locate at /build/tools ...
  • 261
3 votes
1 answer
726 views

Can actions have return types?

I've been looking at most of the example contracts and every action seems to return void. Does this mean that you can not have a return type for your actions? Instead, would you have to send a ...
3 votes
2 answers
2k views

How to send an action from one contract to another?

From contract A, I want to send an action to contract B. How to do that? There is SEND_INLINE_ACTION but that seems to need a pointer to the contract (usually *this), correct? Solution Using action....
  • 833
3 votes
1 answer
374 views

Contract A makes an inline call to contract B. How can B determine that A is the one making the call?

Contract A calls an inline action on contract B via INLINE_ACTION_SENDER(...). How can contract B determine that it is being called by contract A?
  • 695
3 votes
1 answer
66 views

Where is the smart contract is stored

I would like to know where the smart contract is stored after the copilation and deployment. Thanks
3 votes
1 answer
570 views

How to authorize inline action of another contract within a contract?

I deployed a contract omes.user. In the reguser(account_name user) action of contract omes.user I want to send an inline action to another contract eosio.token to issue some tokens to user. Here is ...