1

I am starting a crowdsale and I want to add a custom function to my crowdsale contract. Basically I want users to be able to purchase tokens for fiat and bitcoins.

In order to make that work I will create a wallet with some ether and once a user purchase my tokens with a fiat transaction I want to send the equivalent amount of ether to my contract from my wallet address, convert the amount to the equivalent number of tokens, then transfer the tokens to the investor's address.

Is there a way to do that?

closed as unclear what you're asking by Nicolas Massart, flygoing, Jitendra Kumar. Balla, Achala Dissanayake, Roman Frolov Feb 20 '18 at 19:12

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

1

This is not the way it works except if you want to build an exchange. Ethereum don't know what fiat or bitcoin are. Only Ether is valid on the chain. So you'll have to accept Ether only in your contract. Users will have to buy Ether first from an Exchange using fiat or BTC for instance and then send it to your contract.

  • No I know that. As I said, I will create a separate wallet with ethereum and do a quick exchange based on the ethereum value from coinmarketcap. Basically what I am asking is how can I call a function in my contract that requires ethereum to be sent to it? Or in other words how can I make my function require and accept ethereum as a parameter – Zaid Amir Feb 12 '18 at 17:47
  • That's not clear what you want to do. Sorry. – Nicolas Massart Feb 12 '18 at 17:50
  • I think it was pretty clear. Anyways, I figured it out. – Zaid Amir Feb 13 '18 at 18:09
  • @ZaidAmir in that case feel free to answer you own question. I'm very sorry I wasn't able to help you. But you solved your problem so it's a happy ending. – Nicolas Massart Feb 13 '18 at 18:26
1

Well the solution was simple enough, just create a function that can only be called by the owner and transfer funds to whichever wallet address.

function FreeTransfer(address _investor, uint tokens) public onlyOwner returns (bool success) {
       return transfer(_investor, tokens);
    }

function transfer(address to, uint tokens) public returns (bool success) {
        balances[msg.sender] = safeSub(balances[msg.sender], tokens);
        balances[to] = safeAdd(balances[to], tokens);
        Transfer(msg.sender, to, tokens);
        return true;
    }

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