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 ) ...
Tyrick's user avatar
  • 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 ...
Harry Ma's user avatar
  • 555
11 votes
2 answers
606 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 ...
Soleone's user avatar
  • 674
8 votes
2 answers
486 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 ...
Max's user avatar
  • 411
3 votes
5 answers
770 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 ...
John Haager's user avatar
  • 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 ...
Leo Ribeiro's user avatar
  • 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 ...
Bida's user avatar
  • 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. {...
kkurian's user avatar
  • 695
11 votes
1 answer
975 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 ...
Dallas Johnson's user avatar
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 ...
Max's user avatar
  • 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) { ...
Magic Man Xpress's user avatar
8 votes
2 answers
840 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 ...
kstnew's user avatar
  • 103
7 votes
1 answer
580 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 ?
Nirdesh Kumar Choudhary's user avatar
6 votes
2 answers
328 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 ...
Vlad's user avatar
  • 885
5 votes
4 answers
890 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?
yang24201's user avatar
  • 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?
Phillip Hamnett - EOS42's user avatar
4 votes
3 answers
623 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 ...
JavaHead1560's user avatar
3 votes
1 answer
374 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 ...
Jeff Zheng's user avatar
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 ...
Filip Niziol's user avatar
3 votes
1 answer
446 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 ...
fen chen's user avatar
  • 163
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.
ofo's user avatar
  • 320
2 votes
3 answers
442 views

Need to perform automatic smart contract function execution

Can we have a function in a smart contract to be executed automatically after some time? for example, transfer some tokens after every 5 seconds.
yash vadhvani's user avatar
2 votes
1 answer
472 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?
Patoshi パトシ's user avatar
2 votes
2 answers
588 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 ...
Jyothi's user avatar
  • 73
2 votes
1 answer
99 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.
harriton's user avatar
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 ...
Phillip Hamnett - EOS42's user avatar
0 votes
2 answers
813 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?
Shane's user avatar
  • 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 ...
Leo Ribeiro's user avatar
  • 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?
yang24201's user avatar
  • 393
9 votes
2 answers
640 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, ...
Danail's user avatar
  • 536
8 votes
1 answer
925 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 ...
Leo Ribeiro's user avatar
  • 3,023
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 ...
Riccardo Persiani's user avatar
7 votes
1 answer
463 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: // ...
Leo Ribeiro's user avatar
  • 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 ...
Phillip Hamnett - EOS42's user avatar
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 ...
Leo Ribeiro's user avatar
  • 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 ...
ofo's user avatar
  • 320
5 votes
1 answer
596 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.
Harry Ma's user avatar
  • 555
5 votes
0 answers
100 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 ...
John Williamson's user avatar
4 votes
1 answer
837 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 ...
Nirdesh Kumar Choudhary's user avatar
4 votes
1 answer
648 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 "...
kolkhi's user avatar
  • 63
4 votes
1 answer
152 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 ...
Jimmy Guo's user avatar
  • 1,066
4 votes
1 answer
924 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?
Alvin Sun's user avatar
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 ...
KrisKoin's user avatar
3 votes
2 answers
327 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 ...
Rajat Chaudhary's user avatar
3 votes
1 answer
67 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
user3819's user avatar
3 votes
2 answers
752 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?
Gaurav Kumar's user avatar
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 ...
Sheldon's user avatar
  • 261
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....
friedger's user avatar
  • 833
3 votes
2 answers
138 views

What is needed to get the EOS ~1.1.4 tutorials working on Ubuntu 16.04 (having compiled from source)?

I've found lots of info for Dawn 3.0, but there's a note in the 1.1.0 release notes that acknowledges that the EOS Developer Portal tutorials (token, exchange, helloWorld) don't work and need updating,...
Mike's user avatar
  • 151
3 votes
2 answers
1k views

get token balance from another contract

How do we accomplish this on EOSIO? In Ethereum we get the reference of another contract using the contract address, what about for EOSIO? Can anyone provide a sample code for this? Would like to ...
Dominic's user avatar
  • 131