Relay tx (Morden Test Net)

Create and deploy a BitcoinProcessor contract with a processTransaction function with the following signature:

function processTransaction(bytes txn, uint256 txHash) returns (int256)

From your frontend, call BTC Relay relayTx

BTC Relay

This is a sample of using BTC Relay relayTx, which is the easiest way to integrate BTC Relay because the ABI can remain in the frontend.

A Bitcoin transaction is relayed to BitcoinProcessor.sol that has been deployed at 0x59c9fb53d658b15a7dded65c693703baf58cf63c

The easiest way to run this sample is with the Metamask Chrome plug-in

Otherwise you need a testnet client configured like:

geth --testnet --unlock 0 --rpc --rpcport 8545 --rpccorsdomain=* --rpcaddr localhost


Find a transaction

Bitcoin transaction hash


Raw transaction
Merkle proof
Block hash
Verification Fee


Relay transaction

If you're using MetaMask, make sure it is configured for Morden Test Net


relayTx hash

When this tx is mined, check the BitcoinProcessor sample contract. In its storage, lastTxHash should be the same as your input Bitcoin transaction hash, and ethBlock will be the mined Ethereum block number containing relayTx hash.

If isn't running, you can use web3.eth.getStorageAt('0x59c9fb53d658b15a7dded65c693703baf58cf63c', 0) and web3.toDecimal(web3.eth.getStorageAt('0x59c9fb53d658b15a7dded65c693703baf58cf63c', 0)) to look up the values in storage.

This example shows the use of a BitcoinProcessor contract, which receives Bitcoin transactions via relayTx. This is the easiest way to use BTC Relay because the ABI can remain on the frontend.

View page source of testnetSampleRelayTx.html to see the main steps:

  • Getting a raw transaction and its index from a hash
  • Using bitcoin-proof to get a Merkle proof
  • Invoking relayTx