8

I will create my personal token and I would like to be able to sell it for ETH and BTC. I know how to add the sell function for ETH, but how can I sell the tokens for BTC?

The ETH sell function I will use is the following:

function sell(uint256 amount) {
        if (balanceOf[msg.sender] < amount ) throw;
        balanceOf[this] += amount;
        balanceOf[msg.sender] -= amount;
        msg.sender.send(amount * sellPrice);
        Transfer(msg.sender, this, amount);
}
1
  • can someone explain me in detail how this will work? i am beginner and have written test ICO contract which accept ethers and would now like to extend it for bitcoins.
    – Ether
    Oct 31, 2017 at 9:41

3 Answers 3

7

This is not as easy as with ETH, since a contract cannot own a BTC address. However you can use services like http://btcrelay.org/ which allow you to watch a btc address.

0
3

Quoted from Vitalik Buterin on reddit: (https://www.reddit.com/r/ethereum/comments/4d5z1y/is_it_possible_for_bitcoin_to_live_on_the/)

BTC -> ethereum convertibility can be done fine; the hard part is the ethereum -> BTC conversion. There would need to be some kind of sidechain protocol that can "understand" receipts being created on the ethereum blockchain; this is nontrivial and would have to be done as a softfork and accepted by BTC miners; if you don't want to do this, then the two alternative routes are (1) a federated multisig peg with independent and known parties, and (2) a multisig peg with security deposits on ethereum to incentivize participants to sign transactions correctly. (2) does rely on ETH continuing to have value and not dropping too quickly though, as otherwise the collateral may suddenly be insufficient to provide an adequate incentive not to steal the BTC.

0

You can have a process to convert BTC to WBTC which is a 1:1 ERC20 token. https://www.wbtc.network/

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