Hot answers tagged

11

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 automatically transfer another token type back to a, creating a simple exchange.


9

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 May contain: a-z, 1-5, or . May not end with . Names are encoded in base-32: . = 0 1-5 = 1 - 5 a-z = 6 - 31 The 5 MSBs of the uint64 contain the first ...


8

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 CODE ABOVE ANYMORE, OR YOU WILL BE ATTACKED! if( ((code == self && action != N(transfer) ) || (code == N(eosio.token) && action == N(transfer)) || action == N(...


7

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 eosjs lib, and by default it returns packed response. You can pass option json: true to instruct library to unpack response for you. eos.getTableRows({ code:'...


5

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 execute the corresponding transactions including their actions deterministically. If there would be concurrent write access of multiple block producers to the ...


4

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 time_point time_point_sec block_timestamp_type name bytes string checksum160 checksum256 checksum512 public_key private_key signature symbol symbol_code asset ...


4

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), std::make_tuple(from, self, price, std::string("")) ).send(); Instead of N(eosio.token) and N(transfer) you would use the external contract that you want....


4

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 macro and than define it again: #undef EOSIO_ABI #define EOSIO_ABI(TYPE, MEMBERS) \ ....


4

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-transaction-time. The max-transaction-time set by nodeos on startup or in the config file controls the time to throw the Error 3080006. The default value is 30ms. ...


4

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 contract.


3

Of course, eosjs provides method getActions. Here's an example: const Eos = require('eosjs'); const api = new Eos({ httpEndpoint: 'https://eos.greymass.com', chainId: 'aca376f206b8fc25a6ed44dbdc66547c36c6c33e3a119ffbeaef943642f0e906', }); api.getActions('wangruixiwww').then(console.log); You can send direct request to some API like this https://...


3

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 = require("eosjs") const eos = eosjs({ httpEndpoint: 'https://api1.eosdublin.io', chainId: 'aca376f206b8fc25a6ed44dbdc66547c36c6c33e3a119ffbeaef943642f0e906' }) ...


3

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-watcher, I filter all the transactions relevant to my dapp and call get_transaction for them. The thing is that you could just shortcut it by running ...


3

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 connected peers. This process repeats until all nodes in the network eventually run this transaction. Some of the connected nodes will be block producing nodes ...


3

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/dacc1b09d2c10cc3ca4cea7821c04ea2a47487fe/contracts/eosio.system/delegate_bandwidth.cpp#L147 This is the code: if( payer != N(eosio) ) { INLINE_ACTION_SENDER(eosio::token, ...


3

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 like this: cleos push action your_account vectortest '{"vec":[1.2,2.5,4.6]}' -p your_account your_account is the account with which you set your contract.


3

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 declaring them, and client code needs to pack them into transactions in a different way than normal.


3

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@active


3

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 sign the transaction with your mycontract@active key. There are then two problems with the example you post: You sign the action with bob@active, it should be ...


2

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. If you require a particular user permission you need to provide that as an extra parameter and call require_auth(user) current_receiver is the account name ...


2

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 restrict access to the buy function to only be accessible by the contract itself, using require_auth(_self). Ideally do both, as you can never be too safe...


2

Your code should be like this // @abi action void token::create( account_name issuer, asset maximum_supply ) { require_auth( _self ); auto sym = maximum_supply.symbol; eosio_assert( sym.is_valid(), "invalid symbol name" ); eosio_assert( maximum_supply.is_valid(), "invalid supply"); eosio_assert( ...


2

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 search eosio on github and look around, there is always new libraries and boilerplates popping up. https://github.com/EOSIO/demux-js https://github.com/EOSIO/eosjs


2

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(active) }, N(eosio.token), N(transfer), std::make_tuple(_self, to, quantity, string("some memo here")) ).send(); Also note that you will need grant ...


2

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, if they are not you need to generate .abi and .wast file of eosio.token that can be done like this: # eosiocpp -o ./contracts/eosio.token/eosio.token.wast ./...


2

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 the Jungle testnet: http://jungle.cryptolions.io/#accountHist:testexample. In order to get the actions printed on your terminal, you can try to call: cleos get ...


2

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 auto it = instantiation_cache.find(code_id); if(it == instantiation_cache.end()) { auto timer_pause = fc::make_scoped_exit([&](){ trx_context....


2

The EOSIO documentation could frankly be a lot better than it is. With much difficulty, I found out how to invoke the send_context_free() function from within an existing ACTION function of your contract: std::vector<permission_level> auths; // You can also declare a single permission_level object instead of a vector // set authorization size to ...


2

yeah, this happens if you change the structure of your table without erasing the previous content see https://github.com/clockknock/eos-contract-example/tree/master/02-erase-table


2

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 or deleted any of the other thousands of reasons why you can get a seg fault


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