Good Day,
I am working on a contract where for example, If I send 2 ETH to a contract, ( 1 ETH = 2 Cryptokitty tokens ) then that contract is supposed to return me 4 Cryptokitty tokens.
What I Have done so far
So far, I am able to transfer the funds from my account to the contract, but I am unsure how to automatically transfer back X amount of funds to the person who sent the 2 Eth.
This is my code called when a transfer takes place on this account.
[[eosio::on_notify("eosio.token::transfer")]]
void fundpurchase(name from, name to, asset quantity, std::string memo){
//Bunch of other code which was removed for simplicity.
});
My question is, when I execute
cleos transfer peter bigger "2 CRYCOIN" "memooo" -p peter@active
How can I make it so that, I automatically transfer something back to Peter's account.