I’ll admit that I haven’t dived into the smart contracts yet. But I am hoping someone can answer these questions for me:
I’ve heard that this is indeed possible, I’ll try to find out specifics.
See this: https://github.com/CounterpartyXCP/counterpartyd/issues/452#issuecomment-64844137
A contract cannot move BTC as it can’t hold private keys. Instead we need a way to peg a native Counterparty assets to BTC.
Why wouldn’t a Turing complete smart contract be able to generate a Bitcoin wallet?
@xcp90, I think kordova above said why.
Serpent will be able to make RPC calls to external programs. There’s no need to hard code the private key into the contract. Hard code the RPC call instead, and let the contract manage the resulting Bitcoin wallet. The contract could verify ownership of the public address by signing a message in the most simple of cases. It could also run a full blown proof of reserves scheme.
It would still come down to trusting the maker of the Bitcoin wallet, and optionally the cosigners on the resulting multisig address, because the wallet will have to run on someone’s hardware. But what’s stopping me from setting this up myself to help smooth over OTC trades? You can do blockchain monitoring in any programming language, and trigger an action upon receiving XCP. So it is in fact possible to do, the only question is, is it a good idea for your use case.
There’s nothing stopping someone from setting up a DEX like this, too, for example. The DEX operator lays out the contract which generates a multisig Bitcoin wallet. It could algorithmically pick multisig cosigners, call it 12 oracles, which determine what to do with matched orders. Send BTC to the DEX operator’s multisig address and you can be sure it will be managed in a certain way. There would still be a chance for manual intervention, but in a sufficiently rich and diverse ecosystem with oracles chosen algorithmically, I think it would be more than good enough for most folks.
It’s possible like that, but not “out of the box” and it should be said that it breaks the basic premise (no counterparty risk) of Counterparty.
I sure do hope to see a variety of approaches acceptable to various participants - not every transaction and application needs zero counterparty risk. For example for occasional smaller transactions I don’t care to trust 3rd parties over a short period of time.
Are Smart contracts already working? I heard that they were on the testnet and still having problems?
The smart contracts are stored in the Bitcoin blockchain (as transactions) and executed by all Counterparty nodes. Smart contracts are indeed currently working on testnet, but they have to be absolutely secure in order to reach the mainnet.
The data storage of contracts is paid in BTC (to Bitcoin miners), and the execution fees (gas) are indirectly paid to XCP holders via deflation by reducing the supply.
Thanks deliciousowl.
And as mentioned above, the sending Bitcoins in a decentralized way from Counterparty without revealing private keys or prepackaged transactions(that could be copied out of the transaction)… seems like a maybe impossible issue…
Cross-chain trading (and BTC) should be possible: https://en.bitcoin.it/wiki/Atomic_cross-chain_trading (and the devs already mentioned that they are working on alternatives, smart contracts scripts provide a LOT of room for improvements of BTC trading)
If someone creates fake transactions that initiate smart contracts, Counterparty will just ignore these transactions since they did not pay the necessary fees. It’s that simple. No gas, no go. Those ‘fake’ transactions would essentially amount to littering… They would be completely inert. The issues you are describing are among the first to have been solved.
And the results of smart-contracts are reached by consensus of the network.
And as mentioned above, the sending Bitcoins in a decentralized way from Counterparty without revealing private keys or prepackaged transactions(that could be copied out of the transaction)… seems like a maybe impossible issue…
What do you mean?I don’t remember reading somewhere that private keys are ever disclosed to anyone.Prepackaged transactions do not have private keys either - it’s the same as Bitcoin does it.
What prevents someone from taking those prepackaged transactions out of the smart contract and sending them as normal transactions?
I googled prepackaged transactions and I’m really having trouble understanding what you mean. What do you mean?
I understand that prepackaged means precompiled.
I want to send deliciousowl 1Btc if certain conditions are met. So I package it into a smart contract and put it on the network. Those conditions aren’t meet but the smart contract contains everything needed to make that transaction. So he pulls the transaction out of the SC and send it to Bitcoin and gets paid anyway.
What prevents it?
Okay, I understand your point now.
Indeed that is directly not possible, BUT you can trade BTC for XBTC using atomic “cross-chain” trading using shared secrets and other types of smart contracts. XBTC is an asset that is 1:1 in value to BTC. And then you can use XBTC in any smart contract for any purpose possible. So essentially what you are trying to achieve is absolutely possible, although with a small extra step.
You should definitely be able to do this with serpent, although it will involve one of two workarounds.
The least efficient approach would be arranging for the smart contract to generate a multisig address. It’s inefficient because you’d have to run that contract on either your computer or a server somewhere, and trust that its private key would remain safe on that computer.
The other, better approach is to use a federated peg, which is what Blockstream is using for sidechains before soft forking Bitcoin Core. In a federated peg, you’d send your BTC to a multisig address, which would create a balance of XBTC on Counterparty’s ledger. Do whatever you want to with XBTC, hold it directly in a normal Bitcoin address, and whenever you feel like it, unpeg it back into normal BTC.