as far as i can tell it is somehow inconvenient to let the user of an contract "pay" for the cpu time. I thought that the one who manages the contract, has to stake for cpu/bandwidth, so user can use his contract. But now after i used some contracts on the blockchain, i was always the one who paid + i had to pay for the ram.
- delegate/undelegate EOS to user is an option (but you have to wait 3 Days till you can use them again).
- I read also somewhere to use inline transaction but these were also paid from the user (see example code):
test code for inline transactions:
#include "testeoscpuio.hpp"
using namespace eosio;
//@abi action
void testeoscpuio::doggos(){
auto itr_dog = tb_dogs1.begin();
if(itr_dog == tb_dogs1.end()){
tb_dogs1.emplace(_self, [&](auto& d) {
d.id = 2;
d.number = 1;
});
}else{
tb_dogs1.modify(itr_dog, _self, [&](auto& d) {
d.number = 1;
});
}
uint16_t b = 0;
for(uint16_t i = 0; i < 20000; i++){
b = b +i;
}
}
//@abi action
void testeoscpuio::calc(){
action(permission_level{ _self, N(active) },
N(testeoscpuio), N(doggos), std::make_tuple()).send();
for(uint16_t i = 0; i < 200000; i++){
b = b +i;
}
}