Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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

0
votes
0answers
2 views

Can I deploy a contract from within a contract?

We can create accounts from contract code: https://github.com/angelol/smart_account_creator and we can query things about accounts: https://github.com/nsjames/Account-Has-Code is there a way to ...
1
vote
1answer
24 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.
1
vote
1answer
13 views

Is it possible to lock publish contract with set permission?

Is it possible to setup a lock (multisig) for the command cleos set contract ? in order to request one or more signatures to deploy a contract ? cleos set action permission eosio eosio set ...
1
vote
0answers
20 views

CPU-Usage Optimization

I'm trying to figure out how to optimize one of my smart contracts for less billed CPU-usage. There are typically different methods to optimize performance of algorithms but I'm not clear about if a ...
1
vote
0answers
20 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 ...
1
vote
2answers
30 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
1answer
51 views

on_notify not being fired on local or jungle testnet

I'm using the following contract on both my local and jungle testnets, the on_notify methods are not being fired. Everything appears to be in order, I'm hoping I've missed something obvious. I ...
0
votes
0answers
16 views

Duplicate symbol WASM compilation error when using header/hpp for contract

I'm looking to use a hpp file as an interface for multiple contracts. I've created a test contract and receiving a WASM compilation error. I based the test contract on the format used by eosio.token....
0
votes
1answer
18 views

Is there a library for encryption/decryption in EOS? [duplicate]

I want to perform some encryption on a given message, so I am wondering if there is a library that I can use in EOS? And I have checked the post Cryptographic Operations in Smart Contracts?, but the ...
0
votes
1answer
16 views

Smart contract - find on two columns

I am currently writing a blog PoC on EOS. I would like the ability to delete a post. Now deleting by the ID alone is simple, I have it implemented as follows: whisper::post_index posts(_code, _code....
0
votes
1answer
20 views

Stake EOS and then unstake

Is there any documentation on staking or unstaking EOS using smart contracts? I basically want to provide an escrow service where the seller needs to stake the value of the item and the buyer stakes ...
1
vote
0answers
21 views

No tables in abi file

I am trying to write a smart contract but for some reason my tables aren't being added to the abi file and therefore aren't being added to the blockchain. My code is as follows. Am I possibly ...
0
votes
1answer
26 views

Is there any API in EOS Smart Contract to decrypt message? [duplicate]

I would like to create a smart contract that would be able to decrypt some symmetrically encrypted message. Here is the scenario: Party "A" sends a message encrypted with key "123456" to ...
0
votes
0answers
12 views

Eclipse IDE configuration

I am using Eclipse IDE for EOS smart contract development. I followed https://developers.eos.io/eosio-cpp/docs/ide-configuration but unfortunately, I have many false positives spotted by Eclipse. Any ...
1
vote
1answer
39 views

Broadcast Smart Contract 'Hello World' error

I am going through the eos tutorial but I got stuck at the contract broadcast. When I compile the contract with eosio-cpp -o hello.wasm hello.cpp --abigen the console seems to get stuck and I have ...
0
votes
2answers
29 views

Transaction took too long while using std::shuffle

Get the error when I push a action on my contract on the local testnet: But if I remove this code from the action I called, there is no problem: class urng: Does anyone know what caused this?I just ...
1
vote
0answers
23 views

What could be the reason for 'Error 3050008: Abort Called'

I'm getting the following error without any further description. What could be the issue for that? I'm performing some binary arithmetics when calling this action, are there any known problems with ...
0
votes
0answers
53 views

How to use checksum256 secondary index to get table rows

Does anyone know the correct way to get table rows using checksum256 (fixed_bytes<32>) secondary index through the get_table_rows RPC API? I found a way using key256, but key256 is deprecated ...
0
votes
2answers
49 views

require_auth() not working as expected

I adapted the hello contract, expanding with require_auth() and added an additional account oliver that should be able to execute the action hashin on behalf of the contract owner doctest1. I adjusted ...
3
votes
2answers
64 views

How to get current time in different versions of EOSIO

Depending on which version of EOSIO you use, there are different options available for finding the current time. What are they?
2
votes
1answer
62 views

Make a transfer inline

I would like to send SYS token owned by the smart contract account to a third party account when anyone call a specific action. I have tried the following code but I am getting an error: [[eosio::...
2
votes
1answer
52 views

How do I set my smart-contract / account to “immutable”?

What's the correct cleos command to yield the active/owner permissions of a deployed contract to "eosio.code", exclusively?
0
votes
0answers
9 views

Items on EosKnight management

I am trying to understand what happened behind the scene with the EosKnight smart contract. When I buy an item, it is only an EOS token transfer with a memo. However, it seems that the contract table "...
0
votes
0answers
9 views

How long do it take for transaction to become irreversible? [duplicate]

imagine someone made a transfer of Tokens. Why should happen to reverse it?
1
vote
1answer
28 views

How to convert a public key string to a eosio::publickey object inside a smart contract?

The smart contract takes a string as an input for the public key. I need to convert it into a public key object within the contract.
0
votes
3answers
85 views

Custom dispatcher new CDT

I'm having compilation issues when creating a custom dispatcher. I'm getting issues when calling EOSIO_DISPATCH. Is it related to changes in new CDT? class [[eosio::contract("mycontract")]] ...
0
votes
2answers
66 views

Multi_index issues

I'm getting a lot of errors related to multi_index after updating to the newest eosio.cdt. Here is part of my code related to hash. struct st_hash { capi_checksum256 hash; uint64_t expiration; ...
0
votes
1answer
38 views

Does EOSIO Have Native Contracts Built-Into Protocol Layer?

On the Bitshares site I read https://bitshares.org/technology/industrial-performance-scalability Based upon the lessons we learn from LMAX, we know that a virtual machine for a blockchain should be ...
1
vote
1answer
51 views

Issue while compiling smart contract - eosio.cdt

I have installed eosio.cdt in Ubuntu system by using commands from EOS Developers Portal wget https://github.com/EOSIO/eosio.cdt/releases/download/v1.4.1/eosio.cdt-1.4.1.x86_64.deb sudo apt install ./...
1
vote
2answers
61 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
0answers
24 views

cannot get latest state of table after modifying table in inline action

As shown with code below, I modify table in an inline action, and then want to get the latest data. But the data I get is not the latest. Why? void mycontract::myfunc() { action ( ...
2
votes
1answer
57 views

How to have real-time communication in dapp?

How would a real-time 1v1 game work on the EOS Blockchain? I've noticed that many of the games/gambling dapps on EOS are mostly player vs. blockchain, like EOSBet. Could I have real-time updates to ...
3
votes
1answer
39 views

Require authorization with conditions require_auth(name1 OR name2)

Is there any possibility to implement conditional require_auth(<condition>) or what is a good practice to make contract accept invocations from a set of predetermined accounts? Is there any ...
1
vote
1answer
25 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
2answers
56 views

How to avoid cpu usage limits

Task Compute some fields for all table rows when action called contract::priceupdate(price) Input data: Table with 10000 rows Problem Cpu limit 30ms so i cant update whole table in 1 transaction ...
0
votes
1answer
38 views

Passing the action name having return type to EOSIO_DISPATCH in EOSIO smart contract

I have following EOSIO smart contract: #include <eosiolib/eosio.hpp> #include <eosiolib/print.hpp> using namespace eosio; class random : public contract { public: using contract::...
1
vote
1answer
50 views

Example of resource staking from contract

I'm looking for any relevant code example or documentation describing how to make contract stake resources for some account. I'm aware of delegatebw function of cleos however, I need the following ...
1
vote
0answers
30 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(...
0
votes
1answer
30 views

Can a contract know the creation date of accounts?

Is the creation date of accounts part of consensus? Can I query it within contracts? If so, how to do it?
0
votes
1answer
60 views

How to list all balances of tokens managed by an eosio.token contract?

Let's say I have deployed the standard eosio.token contract to an account called "myeosiotoken," and I have used it to create an "ABC" token. Then, I issue 1,000 ABC to "someaccount1" and 2,000 ABC to ...
1
vote
1answer
58 views

How to extend the functionality of eosio.token?

I want to create an EOSIO token with additional functionality. For example, I want users to be able to claim() an additional token per day (since e.g. account creation date). Should I create a new ...
0
votes
1answer
31 views

Token transfer missing_auth_exception

{ "code":500,"message":"Internal Service Error", "error":{"code":3090004,"name":"missing_auth_exception", "what":"Missing required authority", "details":[{"message":"missing authority of thomsoimj21","...
0
votes
1answer
26 views

How to deploy a contract to api-kylin.eosasia.one testnet

I have written a helloworld contract and got compiled that successfully thomsonim123 is my kylin testnet account with some EOS when I want to deploy the contracct to the testnet I get few errors. ...
0
votes
1answer
20 views

Is it possible to overload contract actions?

I had a method: -- t.hpp -- [[eosio::action]] void exchange(); -- t.cpp -- void token::exchange() { ... } EOSIO_DISPATCH(eosio::token, (exchange)) and then decided that if a parameter were ...
0
votes
1answer
86 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 ...
0
votes
0answers
32 views

Exception Details: 3080006 deadline_exception: Transaction took too long

I'm getting this error and have read all there is to read on the net (which isn't much) about it. mostly I see others complaining about this error when they run an action for the first time in my ...
0
votes
1answer
42 views

Erasing records with for loops

if I want to erase a table: orderbook b(_self, _self.value); auto m = b.get_index<name("idxprod")>(); for (auto &i : m) { m.erase(i); } I get the error: Error 3160005: The table ...
4
votes
1answer
55 views

How to sort a table?

I'm following this explanation https://developers.eos.io/eosio-cpp/v1.1.0/docs/multi-index-table-tutorial using v1.5.0 of the CDT. Here's what I've got: struct [[eosio::table]] order_struct { ...
1
vote
1answer
23 views

Symbol stringification?

an action in my contract accepts an asset: void token::burn(asset a) which I want to print out: printf("Asset [%s] burnt\n", a.symbol.to_string()); except the symbol class does not offer ...
0
votes
2answers
30 views

Asset instantiation woes

if I declare an asset: asset a(10, symbol("TST", 0); and I print it: a.print(); I get pretty much what I'd expect: TST the format's not quite right (10 TST would have been better), but ...