Links

txReceipts

Only available on Go Gateways.
Note: Gateway must have a node connection to both Consensus Layer and Execution Layer as well as be using the eth-ws-uristartup argument (see How to connect Go-Gateway to consensus layer).
Name: txReceipts
txReceipts is a stream of all transaction receipts in each newly mined block.
Options
i.e receipt.block_hash .
Key
Description
Values
include
Fields to include in the receipts stream
block_hash, block_number, contract_address, cumulative_gas_used, from, gas_used, logs, logs_bloom, status, to, transaction_hash, transaction_index [Default: all]

Examples - Websocket

Code Examples
wscat
Node.js
Python
Golang
wscat -c ws://127.0.0.1:28333/ws --header "Authorization: <YOUR-AUTHORIZATION-HEADER>"
> {"id": 1, "method": "subscribe", "params": ["txReceipts", {"include": []}]}
< ......
var fs = require('fs');
const WebSocket = require('ws');
const ws = new WebSocket(
"ws://127.0.0.1:28333/ws",
{
headers: {
"Authorization" : <YOUR-AUTHORIZATION-HEADER>
},
rejectUnauthorized: false,
}
);
function proceed() {
ws.send(`{"jsonrpc": "2.0", "id": 1, "method": "subscribe", "params": ["txReceipts", {"include": []}]}`);
}
function handle(nextNotification) {
console.log(nextNotification.toString()); // or process it generally
}
ws.on('open', proceed);
ws.on('message', handle);
Go Gateway
import asyncio, json, websockets
async def main():
try:
uri = "ws://127.0.0.1:28333/ws"
auth_key = "YOUR_AUTHORIZATION_HEADER"
subscription_request = {
"jsonrpc": "2.0",
"id": 1,
"method": "subscribe",
"params": [
"txReceipts",
{
"include": []
}
]
}
async with websockets.connect(
uri,
header=["Authorization:{}".format(auth_key)],
sslopt={"cert_reqs": ssl.CERT_NONE},
) as websocket:
await websocket.send(json.dumps(subscription_request))
while True:
response = await websocket.recv()
print(response) # or process it generally
except Exception as e:
print(f"Connection failed, Reason: {e}")
if __name__ == '__main__':
asyncio.run(main())
package main
import (
"crypto/tls"
"fmt"
"net/http"
"github.com/gorilla/websocket"
)
func main() {
tlsConfig := &tls.Config{
InsecureSkipVerify: true,
}
dialer := websocket.DefaultDialer
dialer.TLSClientConfig = tlsConfig
wsSubscriber, _, err := dialer.Dial("ws://127.0.0.1:28333/ws", http.Header{"Authorization": []string{<YOUR-AUTHORIZATION-HEADER>}})
if err != nil {
fmt.Println(err)
return
}
subRequest := `{"id": 1, "method": "subscribe", "params": ["txReceipts", {"include": []}]}`
err = wsSubscriber.WriteMessage(websocket.TextMessage, []byte(subRequest))
if err != nil {
fmt.Println(err)
return
}
for {
_, nextNotification, err := wsSubscriber.ReadMessage()
if err != nil {
fmt.Println(err)
}
fmt.Println(string(nextNotification)) // or process it generally
}
}
Response Example
Transaction Receipt Event
<<< {"jsonrpc": "2.0", "id": null,
"result": {"blockHash":"0x1580cb....c950122b837",
"blockNumber":"0xb128cc",
"contractAddress":null,
"cumulativeGasUsed":"0x4e1fb7",
"from":"0x80bb1...7bf44058a48a",
"gasUsed":"0x1d918",
"logs":[{"address":"0x68caa...87846652822ae4b5",
"topics":["0x3ae9ad...c40b5a","0x000000000...058a48a"],
"data":"0x0000...f3784",
"blockNumber":"0xb128cc",
"transactionHash":"0x12316c...3080bc012",
"transactionIndex":"0x4b",
"blockHash":"0x1580cb8419...22b837",
"logIndex":"0x7a",
"removed":false}],
"logsBloom":"0x00000...0000",
"status":"0x1",
"to":"0x68ca...22ae4b5",
"transactionHash":"0x12316...0bc012",
"transactionIndex":"0x4b",
"type":"0x0"}}

Examples - gRPC

Gateway
Subscribing to Gateway txReceipts Stream in Go using gRPC
package main
import (
"context"
"fmt"
pb "github.com/bloXroute-Labs/gateway/v2/protobuf"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
"time"
)
func main() {
// gRPC server default values
gatewayHostIP := "localhost"
gatewayGRPCPort := 5001
// Open gRPC connection to Gateway.
conn, _ := grpc.Dial(
fmt.Sprintf("%v:%v", gatewayHostIP, gatewayGRPCPort),
grpc.WithTransportCredentials(insecure.NewCredentials()),
)
// Use the Gateway client connection interface.
client := pb.NewGatewayClient(conn)
// create context and defer cancel of context
callContext, cancel := context.WithTimeout(context.Background(), 24*time.Hour)
defer cancel()
// Create a subscription using the stream-specific method and request.
stream, _ := client.TxReceipts(callContext, &pb.TxReceiptsRequest{AuthHeader: "<YOUR-AUTHORIZATION-HEADER>"})
for {
subscriptionNotification, err := stream.Recv()
if err == nil {
fmt.Println(subscriptionNotification) // or process it generally
}
}
}

Response (txReceipt Event)

<<< blocK_hash:"0xcbea35...dda2c9"
block_number:"0x1cec032"
cumulative_gas_used:"0xba19c1"
effective_gas_used:"0xb2d05e00"
from:"0x6c88f4...7ebdf5"
gas_used:"0x261ba"
logs: {
address:"0x9767c8...cc2c8"
data:"0x000000...bcb178"
block_number:"0x1cec032"
transaction_hash:"0x757c12...926a7b"
transaction_index:"0x81"
block_hash:"0xcbea35...dda2c9"
log_index:"0x152"
}
logs: {
address:"0x9767c8...1cc2c8"
data:"0xffffff...f1c22d"
block_number:"0x1cec032"
transaction_hash:"0x757c12...926a7b"
transaction_index:"0x81"
block_hash:"0xcbea35...dda2c9"
log_index:"0x153"
}
...
logs_bloom:"0x002000...000080"
status:"0x1"
to:"0x13f4ea...568dd4"
transaction_hash:"0x757c12...926a7b"
transaction_index:"0x81"
type:"0x0"
txs_count:"0x96"