Eos: You can try embedding eosio nonce action inside your transaction to ensure uniqueness.

Created on 29 May 2018  ·  9Comments  ·  Source: EOSIO/eos

when I push action on twice, error occured!
details are as follows:
cleos push action child.acnt ercbalanceof '["child.acnt"]' -p child.acnt
Error 3040008: duplicate transaction
You can try embedding eosio nonce action inside your transaction to ensure uniqueness.
Error Details:
duplicate transaction 798086f342c8261ff0324253a6b5362f7cfb64f4280e9aea5e8d017581fb538b
what should I do? How can I embedding eosio nonce action inside my transaction?
give me some suggesstion,please!

Most helpful comment

Just add -f option like that :

cleos push action child.acnt ercbalanceof '["child.acnt"]' -p child.acnt -f

All 9 comments

Just add -f option like that :

cleos push action child.acnt ercbalanceof '["child.acnt"]' -p child.acnt -f

@lingyiliu016 "duplicate transaction" maybe a sign of another problem - your nodeos is not producing blocks.
Otherwise transactions submitted even with 1 second interval should be unique since they reference different head blocks (even if all other fields in the transactions are exactly the same). In your case head block seem to be not advancing.

Meanwhile I am closing this ticket - there is no issue with EOS software and there is no information to say what was wrong with nodeos (most likely block production was not enabled).

1 second is a long time if your running a test suite where calls take fractions of a second. I'm having the same issue but using eosjs, which I don't believe supports an equivalent of --force-unique. any recommendations?

You can add an attribute to your action and send a random number or incrementing number. Or add a memo field and add unique strings.

I had tried sending a random number in the memo field but it didn't work. I also read in other posts about the inclusion of a "nonce" though I find no authoritative documentation on how that might be done

Here is how nonce is done in cleos

chain::action generate_nonce_action() {
   return chain::action( {}, config::null_account_name, name("nonce"), fc::raw::pack(fc::time_point::now().time_since_epoch().count()));
}

in my case the transaction is composed in eosjs. I'm not yet familiar with creating transactions from c++

in fact, what's odd is that if I change the amount I'm transferring it solves the problem, but adding a memo field with a random number doesn't

Sorry, I'm not familiar with eosjs. Maybe ask there. A random number on memo should work just fine.

@ekkis, Check eoslime, the JS framework supports it

Was this page helpful?
0 / 5 - 0 ratings

Related issues

williamleecn picture williamleecn  ·  3Comments

guaiguaihw picture guaiguaihw  ·  3Comments

bezalel picture bezalel  ·  3Comments

ResponsiveWebApps picture ResponsiveWebApps  ·  3Comments

hoopslb picture hoopslb  ·  3Comments