[Music]
so C can an ethereum contract own
Bitcoins could it own your
Bitcoins the direct answer is
no but if it is possible that an
ethereum contract could have a lot of
incentives so that effectively it does
own and control your
Bitcoins imagine a contract that has a
massive amount of ether or assets that
you
wanted this contract could be programmed
to you know uh give you a large amount
of these assets when it receives a proof
that that Bitcoins from your address
were sent to an address that the
contract
specified the the first secret to
interacting with Bitcoin in ethereum is
the use of payment
proofs BTC relay is a bridge that
empowers daps to accept Bitcoin payments
process arbitr Bitcoin
transactions and empowers Innovation
across Bitcoin and ethereum such as
decentralized exchange and side
chains it has four primary advantages
the the First Advantage is it is
trustless with its inputs it doesn't
care who sends them whether they are
reputable or
malicious and the outputs produced by
the relay follow the cryptographic rules
behind Bitcoin and
ethereum the and it's also fully open
source and this leads to the second
advantage that it is fully
decentralized there are no owners no
administrators no back doors I can't
change it once it's deployed there
effectively it's owned by everyone the
community the third Advantage is
the relay is
autonomous unlike other
contracts autonomy is actually a
requirement for the Relay because it
must be alive with a Bitcoin blockchain
where new blocks are generated every 10
minutes on
average the fourth Advantage is that the
relay is modular it is a building block
that is easy to integrate with and an
EXT sensible foundation
for Innovation such as decentralized
exchange and side
chains so the first secret was using
payment proofs but what would these
payment proofs be verified against so
the second secret
is the BTC relay builds a mini version
of the blockchain a smaller version of
the Bitcoin blockchain in an ethereum
contract
act
and I'll call this an SPV chain and this
SPV chain is what the payment proofs are
verified
against so again not much time for this
talk so I'm going to give a whirlwind
technical introduction to BTC
relay it starts with Bitcoin and SPV
simplified payment
verification so in Bitcoin a a block
has both a a header which is 80 bytes
and then all the transactions in that
block this header has
a quite a few remarkable properties that
lead to the Bitcoin
blockchain for example one of the one of
the fields in header has
the uh the hash of the previous block
another property is that it has
a the header has a root of the Merkel
tree formed by all the transactions in
that
block so
there now now here's an example of we've
heard a lot of about Merkel and Merkel
trees so I'm going to give a quick
example of how that works so we have all
of the transactions here at the bottom
where these are all the transactions in
this block so there's only four for this
example so with take for all of these
transactions we hash them Bitcoin uses
um a hash that will produce a 32 bite
value so that's how we get the that Lev
the the level
above now for each pair of transaction
hashes we concatenate them so we
temporarily get a 64 byte value and then
we hash that again to end up again with
another 32 by value so at this level we
always take pairs them pairwise
concatenate them and then hash them and
we keep repeating that process until
there's only one hash left and that is
basically the root of your Merkel
tree
now with this root you can
verify whether there's a whether a
transaction exists in that block or not
that that is all that you need and BTC
relay uses just headers to build an SPV
chain for example suppose you paid LS1
Bitcoin in
tx3 now you could you could provide the
relay with all the transactions in the
block all of these the relay would run
the algorithm that I just explained it
would compute a Merkel
route and then with that route that it
computed it would just check the actual
header and does that computed route
match
what's in the header if it does match
then then the relay will be will have
verified that yes tx3 is in this
block now it's possible to have um
shorter
proof instead of having to send all the
transactions because this could be
really really long down
here
and and for an example for
tx3 that that Miracle proof would
include hash two and just hash 01 so you
would just need these two instead of all
the transactions in the
block
now I'll I'll have to let you ruminate
on that and but you can see that it's
logarithmically shorter than the naive
approach
so here are the apis that the BTC relay
contract the two main verification apis
it exposes verify TX and relay TX so all
the all this data here is the
transaction and merel
proof and basically this asks the
relay there's this transaction in this
block it's the nth transaction in this
block is is that valid is that true BTC
relay will return true based on three
conditions the first is is this
transaction in that block is that block
on the Bitcoin main chain and the third
is does this block have enough six
confirmations at least six
confirmations the real ATX API is has
the same parameters with two additional
ones the first additional one is the
actual transaction cuz recall that this
is only the hash of the transaction so
you've lost a lot of data here but this
is all the inputs outputs of the Bitcoin
transaction it's arbitrary and then the
additional parameter is your contract
address where you want to be able to
process these
transactions there there are two main
parties in BTC
relay the Rel layers who submit the
block headers which are used to build
the SPV chain and verifiers
to uh verify Bitcoin payments and
transactions
and so every 10 minutes there's a new
Bitcoin block and BTC really needs that
header so this leads to the Third Secret
which is having incentives for the
community to be relays so that their
contract itself the BTC relay contract
is
autonomous now now there are
different incentive uh plans and ideas
that were considered but given limited
time I will discuss the current one in
this current
one when when a relayer submits a header
they get to see a fee for that
header now the the verifier who uses
that who has a payment or transaction in
that block needs to pay that fee to the
fee recipient the initial fee recipient
is
is is the relayer so for example it's
called him
Romeo now to prevent excessive
fees there could be another person or
party it's called Tango Tango decides to
pay an amount
C to relayer Romeo now what what happens
is now Tango gets to become the fee
recipient so any future verifications
there Tango will receive the fees
but to also in addition to paying C
Tango would have had to also set a fee
lower than what Romeo had
set and C is roughly double the double
the amount that it initially cost Romeo
to submit the
header to to be a relayer and uh earn
some ether there's this repository here
where it's right now it's a currently a
Comm line tool that accept that uh
fetches block block headers using a
Bitcoin block Explorer like
blockchain.info Compares it with what
the relay has and submits the ones the
relay doesn't
have and it's on a public test net so
you don't need to spend real ether and
you don't have to worry about what's
this unlocked account that you have to
provide here there's more information
and I'm going to give an example of um
extensibility so a basic CH side chain
flow
is you have let's consider that your
Bitcoin blockchain is here and your side
chain your side chain is here
now time is going vertically downwards
so at the start in Bitcoin and the
Bitcoin blockchain you lock some BTC
let's call that a lock BTC
transaction now when appr proof of that
is sent to a side chain then the side
chain can create some side chain tokens
here uh and then you know time goes by
and let's say we want to get the
Bitcoins back okay now those side chain
tokens are destroyed and then when those
side chain tokens are destroyed a proof
of it is sent back and verified in
Bitcoin blockchain over here and that's
how this uh the Bitcoin blockchain can
then unlock the original BTC that was
locked so in this short example you can
see that if you're a side chain contract
the the first part where there's a lock
BTC transaction you can just pass that
to BTC relay to get the answer of if
that lock BTC transaction has been
confirmed now an example for integrating
it into a
Dap there's so this example is basically
adding a just another contract to to
whatever dap you have and two important
points the ones in
blue the first point is you need to have
a process transaction function with this
exact
signature if the signature doesn't match
then it won't your contract won't get
the data that BTC relay is sending it
the second important point is you have
to check that message sender is BTC
relay otherwise your contract anyone can
send your contract for fake
transactions and as as this sample does
it's recommended to to uh set the
address of BTC relay in a
Constructor there's a minor minor thing
about deliberately emitting braces there
just so it fits on the slides
there there are other things that you
also will want to do afterwards right so
for example you probably want to keep
track of the transaction hashes that
you've seen otherwise people could just
replay them and you know keep getting
your side chain
tokens so I have a couple more demos but
I'm going toh do it after the references
because requires me going off the slides
but for the conclusion the okay the
conclusion is okay so there's three
Secrets the first one is it BTC relay
Builds an SPV chain it verifies
transactions using Merkel
proofs and it has incentives for the
community to relay the block headers so
that BTC Relay can build the SPV chain
it is trustless
decentralized autonomous and
modular and these are uh yeah I want to
thank these people uh supporters of BTC
relay for their uh yeah Priceless time
thought and
work and here are
references
and the site is BTC relay. org which
I'll show right
now
okay me Scot
there
okay
so so this is where um BTC relay is
that's the address it's on a public
ethereum test
net that anyone can connect to at
this you get the information that link
there's the ABI there uh there was some
issue in the test net right now where
someone minded on it so it's a little
slower but all you can compare it with
what what has usually it's up to date
with the uh the the block blockchain
explorers
the quickly um yeah this is the site
that has more so BTC relay. org that has
more information there and the other
quick example that I wanted to show was
so here we do I've already run this
because I'm not connected to the Wi-Fi
but this is the first transaction in
Block
38100 when we do a lookup it gets all
the transactions in that block and then
it's going to pass pass them to a
module that I've put an npm to generate
that Merkel proof so the module is
pretty easy to use you pass in all your
transactions the index of which one you
want to proof from and if we go back
to if we go back to the example that
that's an example of it but of course
you know you don't need to show your
users any of this stuff because once you
have the data then you can just pass it
along to the contract BTC relay and when
you click uh call it's just going to
return one or
zero this is just a sample to to show it
and and I guess just more some some
Source since we have a bit couple of
minutes here
um
so okay let's see so this is this is
where where where where the call is done
the the verifi TX call anyway you can
look at this as well um online it's
uh
but but uh there so the mod the module
is here the Bitcoin proof module
and it's uh yeah we call it yeah we call
it somewhere the the npm code that I
showed
um so so that's yeah I guess maybe time
for one question or two yeah if anyone
has any questions yeah I can this be
used to uh to connect with meta
protocols as well meta coins like Master
coin
countery so it could but you would have
to um you would have to write something
similar so you can't leverage it
directly unless those use um you know
bit Bitcoin
directly unfortunately the answer no
basic because yeah for for script is
expensive is there is there another
question works because the miners are
actually putting their hash power behind
Lo say stuff transactions but protols
like party basically to get any
information at all abely
okay y okay one one more yeah okay two
okay I do know all right yeah the yep
the uh the headers yes uh are you
storing that on the E blockchain yes
it's like 20 something megabytes no no
no it uh yeah well if you start from yes
satous Genesis yeah then it would be
that that big but yeah that's something
that we can configure you'll just you'll
just pay the fees to put that in when
you start well no that's the thing um
that's why we have the the incentives so
we're probably just going to start at a
future
block that's not satoshi's Genesis okay
and then let you know let it be yeah the
community in mhm yes
Alex
yep uh yeah there yeah there can be
plans here hang are there plans to build
a uh a BTC token on ethereum that Maps
one to one with actual
Bitcoins so yeah that's yeah that could
be definitely a future um thing that's
possible to to build the the next main
thing that I'm building is just a
decentralized swap of ether and
Bitcoins and then after that you know
with the side
chains then these ideas can can be
done any others okay thanks thank you
Joseph Joseph
[Applause]
[Music]
Chow