In this how-to lesson, we’re going to go over how to query and submit to two blockchains simultaneously, using Bitcoin and Bitcoin Cash as examples. We can imagine, for instance, a crypto-friendly merchant wants to process payments across multiple cryptocurrencies. Below, we’ll outline the required steps. Be sure to reference the “Getting Started” post if you haven’t already.
client id and
id/secret is akin to a username/password combo that allows your code to interact with the Bloq API. You can generate client keys through the Bloq Command Line.
First, sign in with
bcl login. Once logged in, you can produce new client keys with
bcl client-keys create.
client id and
Query/Submit: Multiple Blockchains
Bitcoin and Bitcoin Cash method calls use the same syntax. To make calls to both chains at once, the first step is to place the existing code into a function that takes the specified chain as the input. Make sure to update the
'coin' field to reflect the input chain value:
Below that, place two method calls below the function. One for BTC, another for BCH:
One final step, let’s update the output string to reflect both BTC and BCH outputs:
From here, you can add as many calls to both chains within the function as you like. This can be useful to compare block times, mining difficulty, fees, and so on between both chains. As highlighted above, the ability to interact with multiple blockchains simultaneously also established the base layer for interoperability between chains.