This topic describes how to use WebSocket to receive events that occurred on a blockchain network.
|URL path parameter||Description|
|network||The name of the channel.|
|access_token||The access token used to access the REST API.|
|source||The subscribed event type. The options include Tx, Config, Contract, and Block. If you subscribe to multiple types of events, separate the types with commas (,). “*“ indicates that all types of events are subscribed.|
|id||String||The ID of an event, which is unique in the channel.|
|name||String||The name of an event.|
|type||EventType||The type of an event. The options include Tx, Config, Contract, and Block.
Tx: transaction generation
Config: system configuration changes of a blockchain
Contract: smart contract setting events in transactions
Block: block generation
|network||String||The name of the channel.|
|instance_id||String||The instance ID of the subscribed event, which is unique in an organization.|
|content||Object||When EventType is set to Tx or Config, the value is in Transaction structure.
When EventType is set to Contract, the value is of String type, and the event content is Base64-coded.
When EventType is set to Block, the value is in Block structure.
|id||String||The ID of a transaction. The value is empty when EventType is set to Config.|
|state||String||The state of a transaction. “VALID” indicates that the transaction is legal. Other values indicate that the transaction is illegal.|
|from||String||The transaction initiator, which is in the format of <Organization MSP>. <Username.>|
|to||String||The target chaincode called by the transaction. The value is empty when EventType is set to Config.|
|input||String||The chaincode calling parameter after JSON coding. When EventType is set to Config, the value is JSON-coded common.ConfigUpdate.|
|events||List<Event>||The blockchain event list generated by the transaction.|
|data||Object||Detailed content of the transaction. The data structure is common.Payload.|
|number||Integer||Height of a block.|
|hash||String||The hash value of the current block after Hex coding.|
|previous_hash||String||The hash value of the last block after Hex coding.|
|create_time||Integer||The creation time of the current block, which is a UNIX timestamp representing the number of milliseconds that have elapsed since the epoch time January 1, 1970, 00:00:00 UTC.|
|transactions||List<String>||The transaction ID list of the current block.|
wscat -c "ws://your.gateway.endpoint/api/v1/networks/channel3/events/subscribe?access_token=<Your URL Encoded Access Token>&source=%2A"
Sample of normal message pushing
For more information, see Error codes.