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
2
votes
2answers
66 views

A contract that generates another contract

If I want to create a smart contract with an action 'Create Game' and on calling that action a new contract be formed, how is it possible?
2
votes
1answer
141 views

How is a Ricardian Contract created? (file type, location, and naming convention)?

The Hello World tutorial defines a sample Ricardian Contract (abreviated snippet below): ## CONTRACT FOR HELLO WORLD ### Parameters Input parameters: NONE Implied parameters: * _**account_name**...
2
votes
1answer
70 views

How to search extra information which is attatched to a transaction?

For example, in one smart contact, a transaction is made, which contains some extra information, let's say the buyer's name. Once the transaction is committed, it is saved into one block. As you know,...
2
votes
1answer
136 views

Addition overflow when doing delegatebw in contract

So I wanted to do delegatebw in my contract as a deferred transaction: eosio::transaction out; out.actions.emplace_back(eosio::permission_level{_self, N(active) }, N(eosio), N(delegatebw), std::...
2
votes
2answers
725 views

recover_key in contract

Is there a specific sample code of using recover_key()? I got an error with recover_key() in contract. string msg="charlie"; checksum256 m_hash; sha256( const_cast<char*>(msg.c_str()), msg....
2
votes
1answer
103 views

CPU Time difference between eosflare and EOS Resource Planner

i would like know why these two sites shwo different CPU Time i have/(could have) with my Account. Example: 1000 EOS on EOS Resource Planner => 45 s/day 1000 EOS on eosflare => 14,4 s/day (scaled) ...
2
votes
1answer
262 views

Is it possible to set permission of the current account in a contract?

I thought this might solve a trust problem. I have considered the Dice example in the tutorial. If I'm the host (Dice) and I have the owner and active permission, then I'm able to transfer all of ...
2
votes
1answer
52 views

Split Smart Contracts or not?

Is it computationally more heavy to put all functions into one smart contract, even though you only call one function at a time? Or is it better to split all functions into individual smart contracts?
2
votes
1answer
113 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
2
votes
1answer
306 views

Does EOS have state variables as in Ethereum?

Ethereum and solidity define state variables which are held in the contract. What is the structure in EOS? Is there also a state variable system at the contract level? Is the virtual machine defined ...
2
votes
1answer
483 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 ...
2
votes
1answer
80 views

When will parallel execution in EOS be supported?

In the white paper, it says: To support parallel execution, each account can also define any number of scopes within their database. The block producers will schedule transaction in such a way ...
2
votes
1answer
116 views

Has the exchange contract deployed to the eos mainet?

Has the exchange contract deployed to the eos mainet? When will it be available ?
2
votes
1answer
81 views

Is it safe to assume that a function can't be called directly if it is not defined in the ABI?

I'm writing a function in my contract that is supposed to run only if I receive a transfer notification from "eosio.token". The way I handle eosio.token transfer notification is similar to this (but ...
2
votes
1answer
211 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 ...
2
votes
1answer
98 views

Why do I get “fstream not found” while compiling with eosiocpp?

Why do I get this when trying to compile a contract? root@caf8aac11bb2:/work/eosio.token# eosiocpp -o eosio.token.wast eosio.token.cpp eosio.token.cpp:8:10: fatal error: 'fstream' file not found #...
2
votes
1answer
1k views

How can I transfer Eos in Eos smart contract?

I am learning Eos smart contract. But there are no information except Eos wiki. In ethereum, ethers can be transferred by payable function. How can I transfer Eos in Eos smart contract?
2
votes
1answer
95 views

How do you stream data from an input file when writing contracts on EOS?

I emulated the tic.tac.toe tutorial code and made a simple contract that allows me to add and remove car information. However, I can only push action one at a time and this only allows me to add/...
2
votes
1answer
249 views

EOS Token Economy with Contract, Wallet, Account

i'm trying to making dApp with EOS. I have some questions. About token. Should i use "eosio.token" contract to make token economy? Or it is just for example? Then should i make new smart contract ...
2
votes
1answer
24 views

installed Local Enviroment get “unresolvable”: env.current_time error

as stated in the topic, i installed eosio new because i had a few problems with the older Version with actions in actions and now i get this error everytime i want to create a contract on the chain. ...
2
votes
2answers
197 views

Invoke the emplace function when developing contracts seems not executed?

I want to develop a contract and save data by using emplace function. Below is my code: offer_bets_index offerbets(_self, player); eosio::print("begin to write db\n"); auto bets_itr = offerbets....
2
votes
1answer
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.
2
votes
1answer
71 views

Execution order of actions

I want to implement "continious minting" which means first I should call issue, and only then transfer. My contract has a functionality of eosio.token . I call create to create my token with ...
2
votes
1answer
120 views

Is it possible to deploy contract via curl?

Using command line i am deploying smart contract "eosio.token". cleos -u http://127.0.0.1:8888 set contract eosio.token ./eosio.token -p eosio.token Is it possible to deploy smart contract using ...
2
votes
1answer
260 views

Why does using available_primary_key() as scope for a table result in this behaviour?

Scenario: Two tables, each using uint64_t as a primary key Table A rows need to reference rows in Table B Why? Relational database data duplication reasoning etc etc Both table's primary keys are ...
2
votes
1answer
54 views

Is there a way to prevent me spending tokens until an action is called?

I am creating a smart contract but came to a halt when writing the code. Is there a way, in a smart contract, to prevent me from spending tokens transferred to me by another user through the smart ...
2
votes
0answers
89 views

Where are deferred transaction errors logged to?

I'm trying to learn about deferred transactions. I'm creating a bogus deferred transaction that invokes a non-existent action "fakeaction": transaction out{}; out.actions.emplace_back(...
2
votes
2answers
285 views

A possible alternative sign in/login process instead of firebase auth / amazon cognito using an eos contract?

I had the the idea of a secure alternative login process using an EOS smart contract instead of firebase or Amazon cognito. I would like to know if something like this feasible? My idea is somewhat ...
2
votes
2answers
142 views

How do tokens that pay dividends work?

If a token is created as a standard eosio.token, what are some approaches for paying out dividends to token holders?
2
votes
1answer
81 views

Reclaim RAM for dApp that creates an account and transfers funds

A dApp that creates a new account and transfers EOS to that account will have to 'pay' for 240 bytes of RAM for the new balance object on the new account. When the new account transfers some funds, ...
2
votes
1answer
109 views

ABI File To Communicate With Unity Game Engine

So I'm building an HTML5 Unity game that will run in an internet browser attached to the Interplanetary File System. Unity allows for JSON files to be used to send and receive binary data between ...
2
votes
1answer
207 views

How do trade eosio token and other token (NFT) in contract?

I'm trying to develop NFT's contract with reference to unicoeos/eosio.nft. Also I'm trying to develop NFT's shop contract in order to trade NFT and eosio.token. The logic trading NFT and eosio....
2
votes
1answer
169 views

Send same action as `cleos push action hello hi …` in smart contract tutorial

I finished smart contract tutorial, and it worked well. Now I'm trying to send same action as cleos push action hello hi '["bob"]' -p user@active in tutorial by using RPC API, cause need to implement ...
2
votes
1answer
103 views

How to setup action access control?

Let's say contract-A has a couple of actions defined. If access to one of the contract-A's action, say action1(), needs to be controlled on account basis, how to do it? For example, only few ...
2
votes
1answer
67 views

Corrupted account name in nodeos log during action pushing

Have an issue with the action push: cleos --wallet-url "http://localhost:8889" push action contractx put '["test", "75c88c9593bec6b716f2cb9b60db79282b6f3389a39f3be9adef45e06b379b48"]' -p test Error ...
2
votes
0answers
50 views

Does eos smart contract support sha3(keccak)? [duplicate]

In the eosiolib/crypto.h, I only saw the sha1, sha256, sha512, ripemd160, and recover keys method. If I'd like to add the sha3 method, did I need to write the library in the contract? That will be ...
2
votes
1answer
261 views

Error generating abi file for type “double” or “float” using eosiocpp tool

I am writing a smart contract that uses a multi index table with a member type double. //@abi table tbltest i64 struct test{ uint64_t uid; double margin; uuid_t primary_key() const { ...
1
vote
2answers
960 views

in the system contract, what is required for require_auth(_self)

In the system contract (eosio_system.cpp) there are some functions which require require_auth( _self ); How is this auth level achieved by the 21 producers?
1
vote
2answers
990 views

inline transfer causes error

My inline transfer causes the following error. Error 3050003: eosio_assert_message assertion failure Error Details: assertion failure with message: read I dont know how to solve it. I ...
1
vote
2answers
558 views

What is the purpose for each of the eosio.* system accounts?

There are several eosio.* accounts - also referred to as system accounts - described in the bios sequence tutorial: eosio.bpay eosio.msig eosio.names eosio.ram eosio.ramfee eosio.saving eosio.stake ...
1
vote
1answer
167 views

How can I get the balance of my account with smart contracts in cdt 1.6

All previous answers before used some function called get_balance, but there is none listed like that in the api https://eosio.github.io/eosio.cdt/1.6.0/functions.html.
1
vote
1answer
433 views

Authorisation failure with deferred transaction

I have a contract action that does some cleanup: void token::cleanup() { ... } that I want to run asynchronously from another action like this: schedule("cleanup", 10). my scheduling method looks ...
1
vote
1answer
133 views

In the eosio.token contract, why are the structs private?

In my contract, I'd like to be able to check how much EOS an account has. For that, I'd write some C++ code like this: token::accounts the_table("eosio.token"_n, "useraccount1"_n.value); auto it = ...
1
vote
3answers
292 views

Interacting with a smart contract

How can a user interact with the contract? Is typing the command cleos push action the only option?
1
vote
1answer
105 views

Is there any fallback function in smart contract similar to Ethereum?

In example dice at contracts directory, alice/bob should set permission to dice account for transferring EOS token from alice/bob to dice. alice dice contract eosio....
1
vote
1answer
182 views

what does the same_payer mean in eosio contract?

user_stakes.modify(sk,same_payer,[&](auto &s){ The variable same_payer confused me sometime, so, what does the same_payer mean in eosio contract ?
1
vote
2answers
79 views

Why actions can't have return values?

I can't understand why actions can't return values. A simple use case is for adding records in multi_index. I need to return the primary key to link that to my off-chain data.
1
vote
2answers
106 views

What can prevent one from changing contract code?

I find one major characteristic of EOSIO is that the smart contract code is interchangeable, so that developers can easily fix any bugs or change its logic. But what if someone changes the code to ...
1
vote
2answers
128 views

Passing a string to an action?

I have an action that needs to operate on a string: void token::MyAction(std::string key); so I would expect I can make the call like this: cleos push action MyAccount MyAction '["burn"]' -p ...
1
vote
1answer
51 views

In Eosbetdice contract, in the transfer action, why it is able to emplace a new row in this table?

In Eosbetdice contract, https://gitlab.com/EOSBetCasino/eosbetdice_public/blob/master/EOSBetDice.cpp#L193 The code of the contract in this line should be "eosio.token". I wonder why it doesn't get "...

1
4 5
6
7 8
12