0

With the last CDT, to send transaction inside smart contract, here is my code

  eosio::transaction out;
  out.actions.emplace_back(eosio::permission_level{get_self(), "active"_n}, get_self(), "profilesum"_n, packed_data);
  out.delay_sec = 0;
  out.send( _self, _self,true);

When i compile with cdt. the error shows at below

error: no viable conversion from 'eosio::name' to 'const uint128_t' (aka 'const unsigned __int128') out.send( _self, _self,true);

Here is send() function, we need input sender_id with data type uint128_t. But what is sender_id? when i tried to build with old version, evething work fine with above code. Anyone know the reason?

 void send(const uint128_t& sender_id, account_name payer, bool replace_existing = false) const {
     auto serialize = pack(*this);
     send_deferred(sender_id, payer, serialize.data(), serialize.size(), replace_existing);
  }

2 Answers 2

0

I know 1.4.4 broke some things like removing types.hpp from the basic eosio.hpp import, so I would recommend getting on 1.5.

Here is an example of a spamming action that you may be able to compare and see what's different | code link:

    [[eosio::action]]
   void spam( name from, name to, uint64_t msg_id, const string& msg_str, uint32_t delay_sec ) {
      require_auth( from );

      if( msg_id > 10 )
         return;

      {
         eosio::transaction out;
         out.actions.emplace_back( eosio::permission_level{_self, "active"_n}, to, "sendmsg"_n,
                                   std::make_tuple( from, to, ++msg_id, msg_str ));
         out.delay_sec = delay_sec;
         out.send( msg_id, _self );
      }
      {
         eosio::transaction out;
         out.actions.emplace_back( eosio::permission_level{_self, "active"_n}, _self, "spam"_n,
                                   std::make_tuple( from, to, ++msg_id, msg_str, delay_sec ));
         out.delay_sec = delay_sec;
         out.send( msg_id, _self );
      }
   }
0

The sender ID is expecting a 128-bit integer, but you are providing an instance of the name class. In order to access the integer version of this, you must type _self.value.

Disclaimer: I haven't test this yet

Your Answer

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

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