Hot answers tagged

12 votes
Accepted

What is the purpose of `require_recipient`?

Think of it as sending a carbon copy of the action. Since eosio.token does it with transfer, contracts can monitor and respond to deposits. e.g. if user a transfers EOS to contract b, then b could ...
user avatar
  • 1,985
9 votes
Accepted

What are naming rules for actions, tables and contracts?

Action names, table names, index names, account names, and everything else you use N(foo), "foo"_n, or eosio::name("foo") for, have these rules. A contract belongs to an account. 12 characters max ...
user avatar
  • 1,985
8 votes
Accepted

Reading table rows with EOSJS

You have several ways to retrieve data from eos chain as i know. They differs a lot, so you should find a better one for you case. #1. Get from table As you noted there is getTableRows method in ...
user avatar
8 votes
Accepted

How to do something when your contract is an action notification recipient (like when it receives funds)?

Extend EOSIO_ABI macro to handle eosio.token transfer notification. Please pay attention to if statements: if( code == self || **code == N(eosio.token)** || action == N(onerror) ) DO NOT USE THIS ...
user avatar
  • 320
5 votes
Accepted

Can an action in a smart contract concurrently executed?

If I understood everything correctly: A transaction stores multiple actions. Transactions are stored in blocks. Every block producer has its turn (approx. 0.5 sec for this DPOS) to create a block and ...
user avatar
  • 2,104
5 votes

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

The execution time is based on many factors in each execution. It could be the cache missing or process management could blocks the nodeos process and makes the execution time exceeds the max-...
user avatar
  • 174
4 votes

List of available datatypes for action parameter

You can use this list for built-in types (Todd Fleming shared the link on Telegram): bool int8 uint8 int16 uint16 int32 uint32 int64 uint64 int128 uint128 varuint32 varint32 float32 float64 float128 ...
user avatar
  • 5,524
4 votes
Accepted

How to send an action from one contract to another?

Maybe you can try to use N(yourcontract) instead of *this. If it does not work you can also try this: action(permission_level{ from, N(active) }, N(eosio.token), N(transfer), ...
user avatar
  • 3,023
4 votes

How to do something when your contract is an action notification recipient (like when it receives funds)?

The solution is to redefine EOSIO_ABI macro. @ofo's solution is correct for the code generation part but to make auto abi generation work EOSIO_ABI macro has to be used. To do this you first undefine ...
user avatar
  • 41
4 votes
Accepted

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

Abort Called is usually an indicating of a segmentation violation. So look for things like: accessing elements of a vector or pointer calling new or delete on objects that have already been created ...
user avatar
4 votes

Is it possible to create new contract from another?

You can call eosio::setcode and eosio::setabi as inline-action to external contract or deferred-action and set code and abi of a contract you have the necessary permissions for, from within your ...
user avatar
  • 1,794
3 votes

How to get operations history of account?

Of course, eosjs provides method getActions. Here's an example: const Eos = require('eosjs'); const api = new Eos({ httpEndpoint: 'https://eos.greymass.com', chainId: '...
user avatar
  • 131
3 votes

How to get operations history of account?

You can simply request a node to give you the action history of an account. Using cleos: cleos --url https://api1.eosdublin.io get actions <EOS account name> Using eosjs: const eosjs = ...
user avatar
3 votes

Can we get all the actions from all blocks?

You can get the inline actions in get_actions RPC History API endpoint or inside the details of a transaction using also the RPC API get_transaction. So that's exactly what I'm doing in that eos-node-...
user avatar
  • 3,023
3 votes
Accepted

What happens when a non-producing node receives an action?

The node that receives the transaction, validates and runs it first (even a non-producing node). If it's successfully run, the transaction becomes pre-validated and the node forwards it to all the ...
user avatar
3 votes
Accepted

Example of smart contract action that itself executes a transaction

Check this example of delegate bandwith, it executes the transfer action from the eosio.token contract using the INLINE_ACTION_SENDER to buy ram: https://github.com/EOSIO/eos/blob/...
user avatar
  • 3,023
3 votes

List of available datatypes for action parameter

An action parameter type can be a built-in type or it can be a user defined type. For a better understanding please read this documentation page from the beginning and pay special attention to the &...
user avatar
  • 371
3 votes
Accepted

How to push a vector to an action

suppose your action looks like this: first define type of your vector let say you need a vector of double void vectortest(const std::vector<double> &vec) ; than you should be able to call ...
user avatar
3 votes
Accepted

Is it possible to overload contract actions?

Non-variant actions aren't overloadable. If you need actions with different behavior, then give them different names. Variant actions aren't ready for general use. They have (undocumented) methods of ...
user avatar
  • 1,985
3 votes

Cannot pass arguments to push action in bash script

You have to use single quotes to allow these arguments that are within json. Like this: cleos -u https://api-kylin.eoslaomao.com:443 push action user1account create '["'$2'","'$3'"]' -p user1account@...
user avatar
3 votes
Accepted

Make a transfer inline

The problem is you are trying to transfer tokens, which requires mycontract@active permission. But when you send tokens from within a contract, the permission is mycontract@eosio.code - even if you ...
user avatar
3 votes
Accepted

Dispatcher in smart contract

Usually, you don't need to implement dispatcher by yourself. [[eosio::action]] and [[eosio::on_notify]] will generate a proper action dispatcher automatically. There were some security accidents by ...
user avatar
  • 2,255
2 votes
Accepted

Account of caller of action

The caller of the action (which is simlar to msg.sender in ETH) is not available in the action itself. As actions can be called with several user permissions at the same time there is no unique caller....
user avatar
  • 833
2 votes

How do I ensure my Action Listener responds only to authentic senders?

There are two ways that you can prevent this: You remove the buy function from the ABI, it can therefore never be called manually, but only through another function that is part of the ABI. You ...
user avatar
2 votes

empty actions - abi file

Your code should be like this // @abi action void token::create( account_name issuer, asset maximum_supply ) { require_auth( _self ); auto sym = maximum_supply....
user avatar
2 votes

Interacting with a smart contract

Like Patrick said you need to build a front end to communicate with smart contracts on the eosio blockchain. Here a couple of library's to get you started. I have seen a few others as well. Just ...
user avatar
2 votes

Transfer EOS tokens inside a smart contract from an account to another

Use the following code in your smart contract to initiate a transfer of EOS tokens. asset quantity = asset( 10000, symbol_type(S(4, EOS)) ); // equals to 1 EOS action( permission_level{ _self, N(...
user avatar
2 votes

Transfer EOS tokens inside a smart contract from an account to another

First of all you need to provide the permission of eosio.code. After that you can use the transfer action of eosio.token contract. before assigning tokens see if both .abi and .wast file are there, ...
user avatar
2 votes

How to check if smartcontract action has been actually run? How to count how many times?

Concerning the count of how many times your action has been called, you can both in mainnet and testnet see the account history of any account. There are listed all the actions called. Like here for ...
user avatar
2 votes

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

I think, it may related with cache (as twksos commented). https://github.com/EOSIO/eos/blob/11c25394b6dd05cc3c97f0b7471a84f3d7cfbca3/libraries/chain/include/eosio/chain/wasm_interface_private.hpp#L58 ...
user avatar
  • 102

Only top scored, non community-wiki answers of a minimum length are eligible