What is the correct way to send a transaction to the bitcoin blockchain from an EOS smart contract. Can anyone provide a code example ?
-
1I am not sure, but by default something like that will not be possible. Basically that would mean, that EOS would be a sidechain of bitcoin. To send a transaction, you need to sign a transaction with your private key. Keeping a private key in a public blockchain is... problematic to say at least.– noisyCommented May 9, 2018 at 8:17
1 Answer
Transactions sent to a foreign chain will require some facilities on said foreign chain to be trustless. In the case of two EOSIO based chains, the foreign blockchain will run a smart contract (no example yet) which accepts block headers and incoming transactions from untrusted sources and is able to establish trust in the incoming transactions if they (and the associated known block headers) are provably from the originating chain. EOSIO is designed to make these Inter-Blockchain-Communication (IBC) proofs lightweight.
In this case, the relaying party can be completely untrusted. The contract on the foreign chain should be capable of discerning false information from untrustworthy sources based on the proofs available. After verifying a proof, the foreign chain contract will "echo" the transaction as a native transaction on the foreign chain triggering any side-effects (including the creation transactions that can be relayed back to the originator)
For chains with an insufficient capacity for processing the IBC proofs and establishing validity, the options degrade to trusted oracles/escrows.
For instance, if you wanted to directly control bitcoin transactions with an EOSIO based smart contract you would need something like a trusted mutisig wallet that holds the bitcoin in escrow and can be persuaded to sign/publish the bitcoin transaction based on IBC proofs from the originating chain.
Other smart contracting platforms may or may not have the capacity for trustless IBC, it would depend on the platform.