I have a action in my contract :

// @abi action
void ContractClass::submittxn(string memo,string memo2,uint64_t a = 61)

I try to set a as default parameter but when I push the transaction, it shows the following error:

Error 3015014: Pack data exception
Error Details:
Missing 'a' in variant object

I push the transaction as :

cleos push action contract_name submittxn'{"memo":"qwerty","memo2":"asdfgh"}' -p account_name

Is this possible in EOS or I have to find some other way? It works fine if I send this with full params.

3 Answers 3


Not recommended, but you can mimic default value feature with eosio::binary_extension.


#include <eosio/eosio.hpp>
#include <eosio/binary_extension.hpp>

using namespace eosio;
using namespace std;

class [[eosio::contract]] test : public contract {
   using contract::contract;

   void submittxn(string memo, string memo2, binary_extension<uint64_t> a) {
       // if a is passed, _a has same value of a
       // if a is NOT passed, _a becomes 61 (default value)
      uint64_t _a = a.value_or(uint64_t(61));

      // use _a instead of a


$ cleos push action test submittxn '["eosio", "token"]' -p test@active
>> 61

$ cleos push action test submittxn '["eosio", "token", 10]' -p test@active
>> 10
  • 1
    This is actually very interesting and creative. Thanks for sharing even though it isn't really a recommended practice. Commented Aug 25, 2019 at 14:54

You cannot use default parameters in actions. You could, however, check the value of the parameters and decide how to handle null or empty strings.

ACTION democontract::defaulttest( uint16_t i ) {
  if (i == 0) {
    i = 61;
  printf("i is %u", i);

Another option would be to declare a vector of types to send into the action and only use what is required.

However you decide to proceed, you have to send in the same parameters that are declared in the ABI. A future version of EOSIO may add Variant actions, however they are not currently supported.


I guess, You use default and then save "a" with default to table database if it doesn't set.

If yes, You can use this way when declare table data

     struct account {
        string       memo;
        string       memo2;
        uint64_t     a = 61;
  • Yes,This can be doable in table but why this is not supported in EOS ? may be possible I am not clear. Commented Sep 29, 2018 at 3:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.