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

eosiocpp tool generates different types

If you look into every ABI file in the contract folder you will find: { "version": "eosio::abi/1.0", "types": [{ "new_type_name": "account_name", "type": "name" }], ... } when I am ...
4
votes
2answers
443 views

Custom struct abi serialization

I am trying to understand, how the string "100000000.000 SYS" is serialized into struct asset from eosio.token example ( cleos push action eosio.token create '[ "eosio", "1000000000.0000 SYS", 0, 0, 0]...
8
votes
1answer
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?
5
votes
3answers
747 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?
3
votes
1answer
76 views

Conditional behavior based upon auth

Imagine a contract that does not require_auth() but instead has conditional behavior depending upon which auth is present. if (<conditional that checks auth>) { // do stuff given auth from ...
5
votes
1answer
350 views

Require at least one auth from a set of auths

require_auth() asserts that a particular auth is present. How to write a contract that proceeds if and only if at least one of a set of auths is present?
3
votes
1answer
367 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?
4
votes
1answer
692 views

How can I create a custom permission within a contract and limit it to certain actions?

For example, say I wanted to create a custom permission called delegatee. An account with this permission would be only permitted to preform certain actions within my contract. Is this possible as of ...
2
votes
1answer
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. {...
4
votes
2answers
563 views

Tables are not generated in abi file

I have the contract class test : public contract { public: using contract::contract; test(account_name self) : contract(self) {} ... private: struct test_rec { test_hash ...
6
votes
3answers
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 ...
1
vote
1answer
526 views

Where is 'INLINE_ACTION_SENDER' macro defined?

I am trying to use INLINE_ACTION_SENDER to use an action from another contract but get the following error. error: use of undeclared identifier 'INLINE_ACTION_SENDER' How do I include this macro in ...
5
votes
1answer
550 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.
2
votes
1answer
404 views

Example of smart contract action that itself executes a transaction

Can anyone point me to example code for writing a smart contract that calls actions on other smart contracts? The general method of doing this is documented here but example code is not provided.
11
votes
2answers
568 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 ...
5
votes
2answers
510 views

Is it possible to get the creation timestamp of a record of a Smart Contract Table?

Usually in centralized apps we have the fields created_at and created_by to know when and who created this record and also sometimes modified_at and modified_by to register who and when was the last ...
6
votes
1answer
138 views

How to add third part libraries when developing smart contracts in EOS?

For example, if I want to add a random digital generator library, what can I do? I want to add all the source files into my contract directory?
7
votes
2answers
357 views

What libraries are supported by contracts?

What libraries can be used when writing a contract in C++? What are the limitations? If I have a library I normally use and like, how do I compile it for use by contracts?
1
vote
1answer
39 views

Validation for contract which has data which varies

How does the EOS contract system handle data which varies? This could be from using a true random number, or receiving real-world data like a token price. Every time the contract executes, different ...
3
votes
1answer
660 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
1answer
233 views

How can I call third party APIs from inside a smart contract at a set time or interval?

In a scenario where a smart contract needs to check against a third party service (Let's say an API with weather information from a trusted source like Weather.com) and make a decision on moving ...
2
votes
2answers
192 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....
5
votes
1answer
2k 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 ...
5
votes
2answers
856 views

Can someone explain EOS sidechains to me?

Independent platform, Main chain, sidechains, smart contracts. Can someone define these terms for me? I don't quite understand the idea of sidechains. Is sidechains something like threads in ...
6
votes
3answers
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 ...
7
votes
1answer
395 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: // ...
7
votes
1answer
425 views

Unit testing custom contracts [duplicate]

What is the best way to write contracts in a TDD style? The eos source repo has unit tests which seem to be focused around testing the platform but my question is focused at the next level up (based ...
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....
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.
4
votes
1answer
614 views

How to set “deep structures” for Smart Contracts Tables?

I have a table that I'm playing with that I want to have a map that links the id with a specific structure. I tried to use map and the code compiles fine, but when generating the abi file it takes ...
9
votes
2answers
607 views

Is there any method to remove a useless contract from the blockchain just like “selfdestruct” in ETH?

As I know, in ETH, when a contract would be useless, it could be destroyed by using the "selfdestruct" action. So, is there any same method to remove a useless contract from the eos blockchain?
3
votes
5answers
713 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 ...
9
votes
2answers
557 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, ...
11
votes
1answer
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
votes
1answer
52 views

When would the branch “native-contract-debugging” be merged to the master?

I've gotten a message that there would be a better method to debug a custom contract from Telegram. This would be implemented in the branch "native-contract-debugging" which would be merged to the ...
6
votes
2answers
319 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 ...
8
votes
1answer
848 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 ...
5
votes
1answer
49 views

What's the difference between register() and claimAll()?

I'm using MyEtherWallet to register/map the EOS key. The steps suggests to use register() function, however in another tutorial I've seen it's using claimAll() function. So, I'd like to know the ...
16
votes
1answer
2k 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 ...
9
votes
2answers
2k views

How to validate if an Account exists?

I know that we have require_auth to check for permission, but I'm looking for something like is_valid_account to check if the account exists and is active in the chain. Do we have anything like that?...
3
votes
1answer
108 views

Error 3030002 when trying to set contract steps

I'm following steps from exchange-tutorial-python's README file inside the Docker container: $ docker run -it eosio/eos # nodeosd.sh 2>/dev/null & # cleos wallet create Creating wallet: ...
11
votes
1answer
832 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 ...
7
votes
1answer
343 views

Developing Smart Contracts with Docker

If I have the eos chain running in a Docker container, how can I interact with it from my local file system? I would love to be able to create my contracts, compile them, and deploy to my docker ...
9
votes
1answer
107 views

Issue a transaction on a foreign blockchain

What is the correct way to send a transaction to the bitcoin blockchain from an EOS smart contract. Can anyone provide a code example ?
28
votes
3answers
528 views

Is there a standard for naming and formatting that EOS projects should follow / EOS C++ coding style?

Coming from other C++ projects like Unreal Engine I was surprised to see coding standards in the EOS codebase is all lowercase, not only for variables but even for class names. Is there any resource ...

1
8 9 10 11
12