1. Home
  2. bloXroute Documentation
  3. Gateway-API
  4. Sending Transactions

Sending Transactions

Sending transactions directly to the Gateway using the Gateway-API allows you to send a single or batch of transactions that will be distributed faster in the blockchain network using the BDN.

Sending Transactions to the Gateway-API requires a subscription to a paid tier. In order to use this service, you must register an account on the bloXroute website and use a paid tier.

During the registration process, a certificate, private key, and secret-hash will be generated for your account. The certificate and key will be used to authenticate your account by the Gateway-API. Visit this page more information on running the Gateway with an account.

The bloXroute best practice is for users to send transactions to both the Gateway-API and to their blockchain node. You should first send transactions to the Gateway (consider using asynchronous mode to improve performance) and then to your blockchain node as a backup.

Sending transactions asynchronously blxr_tx using curl

>>> curl http://127.0.0.1:28332 --data '{"method": "blxr_tx", "id": "c85c96c2-587f-4be0-a58a-ac9b91716312", "params": {"transaction": "f86683018371843b9aca0082520894e26150519a0cfdcaab8f4b6343adfddb1bd1aaf5808029a07115486389bbb1f8d19f3c9b4fa16dab2bb125f14c6b9fe3f22b09858305776ca06a52bf64c5170daf1422f328b3f0a557e2b7f0d034c0c8f41e97c5ca3e21c1ff"}}' --header "Content-Type:text/plain" --header "Authorization:xxxxxxxxxxx" 

Explanation:

  • --data '{...}' – This section includes a json string on the requested command
  • "method": "blxr_tx" – This is a blxr_tx command – sending a transaction to bloXroute Gateway
  • "id": "c85c96c2-587f-4be0-a58a-ac9b91716312" – Each command can have its own id, so your code can check the response and match them to the requests. You can enter any value here
  • "params": {...} – This section includes a json string that has additional parameters required for the execution on the command. In this example, the parameters should include the raw transaction and optionally an indication if to send it asynchronous or synchronous
  • "transaction": "..." – This is a raw transaction based on your blockchain protocol
  • --header "Content-Type:text/plain" – required by the protocol to indicate the format of the http request
  • --header "Authorization:xxxxxxxxxxx" – used to authenticate the request. Authentication is done against the –rpc-user and –rpc-password the Gateway started with

 
The following is an example for a Gateway reply:

<<< "{\"jsonrpc\": \"2.0\", \"id\": \"c85c96c2-587f-4be0-a58a-ac9b91716312\", \"result\": {\"tx_hash\": \"not available with async\", \"quota_type\": \"paid_daily_quota\", \"synchronous\": \"False\"}}",

 
Sending transactions synchronously blxr_tx

>>> curl http://127.0.0.1:28332 --data '{"method": "blxr_tx", "id": "c85c96c2-587f-4be0-a58a-ac9b91716312", "params": {"transaction": "f86683018371843b9aca0082520894e26150519a0cfdcaab8f4b6343adfddb1bd1aaf5808029a07115486389bbb1f8d19f3c9b4fa16dab2bb125f14c6b9fe3f22b09858305776ca06a52bf64c5170daf1422f328b3f0a557e2b7f0d034c0c8f41e97c5ca3e21c1ff", <mark>"synchronous": "true"</mark>}}' --header "Content-Type:text/plain" --header "Authorization:xxxxxxxxxxx" 

Explanation:

  • --data '{...}' – This section includes a json string on the requested command
  • "method": "blxr_tx" – This is a blxr_tx command – sending a transaction to bloXroute Gateway
  • "id": "c85c96c2-587f-4be0-a58a-ac9b91716312" – Each command can have its own id, so your code can check the response and match them to the requests
  • "params": {...} – This section includes a json string that has additional parameters required for the execution on the command. In this example, the parameters should include the raw transaction and optionally an indication if to send it asynchronous or synchronous
  • "transaction": "..." – This is a raw transaction based on your blockchain protocol
  • "synchronous": "true" – Indicates the api will return an answer after processing the transaction
  • --header "Content-Type:text/plain" – required by the protocol to indicate the format of the http request
  • --header "Authorization:xxxxxxxxxxx" – used to authenticate the request. Authentication is done against the –rpc-user and –rpc-password the Gateway started with

 
The following is an example for a Gateway reply:

<<< "{\"jsonrpc\": \"2.0\", \"id\": \"c85c96c2-587f-4be0-a58a-ac9b91716312\", \"result\": {\"tx_hash\": \"Sha256Hash\", \"quota_type\": \"paid_daily_quota\", \"synchronous\": \"True\"}}"