State channel WebSocket API
Last updated
Was this helpful?
Last updated
Was this helpful?
Messages on the WebSocket API have to follow JSON-RPC specification version 2.0. See:
The WebSocket API provides the following actions:
Roles:
Sender
Acknowledger
method: channels.update.new
params:
from
string
Participant's account to take coins from
Yes
to
string
Participant's account to add coins to
Yes
amount
integer
Amount of coins to transfer
Yes
block_hash
string
The on-chain block hash to pin the off-chain environment
No
meta
array of strings
Meta information about the update
No
method: channels.sign.update
params:
signed_tx
string
channel_offchain_tx
transaction wrapped in a signed_tx
with no authentication
Yes
updates
list
off-chain updates
Yes
method: channels.update
params:
signed_tx
string
solo-authenticated channel_offchain_tx
transaction
Yes
method: channels.sign.update_ack
params:
signed_tx
string
solo-authenticated channel_offchain_tx
transaction
Yes
updates
list
off-chain updates
Yes
method: channels.update_ack
params:
signed_tx
string
co-authenticated channel_offchain_tx
transaction
Yes
method: channels.conflict
params:
channel_id
string
channel id
Yes
data
object
description of the last mutually authenticated state
Yes
data:
channel_id
string
channel id
Yes
round
object
the round of the last mutually authenticated state
Yes
error:
message
string
error message
Yes
code
integer
error code
Yes
data
json
error description
Yes
request
json
the failed request
Yes
data:
message
string
JSON-RPC error message
Yes
code
integer
JSON-RPC error code
Yes
Roles:
Depositor
Acknowledger
method: channels.deposit
params:
amount
integer
Amount of coins to deposit in the channel
Yes
block_hash
string
The on-chain block hash to pin the off-chain environment
No
fee
integer
The on-chain transaction fee to be used. If not provided the FSM picks a value for the client
No
gas_price
integer
the gas_price to be used for the fee computation
No
nonce
integer
the nonce to be used in the transaction
No
meta
array of strings
Meta information about the update
No
method: channels.sign.deposit_tx
params:
channel_id
string
channel ID
Yes
data
object
deposit data
Yes
data:
signed_tx
string
channel_deposit_tx
transaction wrapped in a signed_tx
with no authentication
Yes
updates
list
off-chain updates
Yes
method: channels.deposit_tx
params:
signed_tx
string
solo-authenticated channel_deposit_tx
transaction
Yes
method: channels.sign.deposit_ack
params:
channel_id
string
channel ID
Yes
data
object
deposit data
Yes
data:
signed_tx
string
solo-authenticated channel_deposit_tx
transaction
Yes
updates
list
off-chain updates
Yes
method: channels.deposit_ack
params:
signed_tx
string
co-authenticated channel_deposit_tx
transaction
Yes
Roles:
Withdrawer
Acknowledger
method: channels.withdraw
params:
amount
integer
Amount of coins to withdraw form the channel
Yes
block_hash
string
The on-chain block hash to pin the off-chain environment
No
fee
integer
The on-chain transaction fee to be used. If not provided the FSM picks a value for the client
No
gas_price
integer
the gas_price to be used for the fee computation
No
nonce
integer
the nonce to be used in the transaction
No
meta
array of strings
Meta information about the update
No
method: channels.sign.withdraw_tx
payload:
channel_id
string
channel ID
Yes
data
object
withdrawal data
Yes
data:
signed_tx
string
channel_withdraw_tx
transaction wrapped in a signed_tx
with no authentication
Yes
updates
list
off-chain updates
Yes
method: channels.withdraw_tx
params:
signed_tx
string
co-authenticated channel_withdraw_tx
transaction
Yes
method: channels.sign.withdraw_ack
params:
channel_id
string
channel ID
Yes
data
object
withdrawal data
Yes
data:
signed_tx
string
solo-authenticated channel_withdraw_tx
transaction
Yes
updates
list
off-chain updates
Yes
method: channels.withdraw_ack
params:
signed_tx
string
co-authenticated channel_withdraw_tx
transaction
Yes
method: channels.assume_minimum_depth
params:
tx_hash
string
The on-chain hash of related transaction
yes
method: channels.update.new_contract
params:
code
contract code
contract code
Yes
call_data
call data
call data for contract creation
Yes
vm_version
integer
contract virtual machine version (vm for which code was compiled)
Yes
abi_version
integer
contract virtual machine abi version
Yes
deposit
integer
contract creation deposit
Yes
block_hash
string
The on-chain block hash to pin the off-chain environment
No
meta
array of strings
Meta information about the update
No
method: channels.update.call_contract
params:
contract_id
contract id
contract to call
Yes
call_data
call data
call data
Yes
abi_version
integer
call abi version
Yes
amount
integer
amount of coins to transfer to contract
Yes
block_hash
string
The on-chain block hash to pin the off-chain environment
No
meta
array of strings
Meta information about the update
No
Roles:
Sender
Receiver
method: channels.message
params:
to
string
Receiver's address
Yes
info
string
Message body
Yes
method: channels.message
params:
channel_id
string
channel id
Yes
data
object
data field that contains the message
Yes
data:
message
object
the message itself
Yes
message:
channel_id
string
channel id
Yes
from
string
Sender's address
Yes
to
string
Receiver's address
Yes
info
string
Message body
Yes
Roles:
Closer
Acknowledger
method: channels.shutdown
params:
block_hash
string
The on-chain block hash to pin the off-chain environment
No
fee
integer
The on-chain transaction fee to be used. If not provided the FSM picks a value for the client
No
gas_price
integer
the gas_price to be used for the fee computation
No
nonce
integer
the nonce to be used in the transaction
No
method: channels.sign.shutdown_sign
params:
channel_id
string
channel ID
Yes
data
object
closing data
Yes
data:
signed_tx
string
channel_close_mutual_tx
transaction wrapped in a signed_tx
with no authentication
Yes
updates
list
off-chain updates
Yes
method: channels.shutdown_sign
params:
signed_tx
string
solo-authenticated channel_close_mutual_tx
transaction
Yes
method: channels.sign.shutdown_sign_ack
params:
channel_id
string
channel ID
Yes
data
object
closing data
Yes
data:
signed_tx
string
solo-authenticated channel_close_mutual_tx
transaction
Yes
updates
list
off-chain updates
Yes
method: channels.shutdown_sign_ack
params:
signed_tx
string
co-authenticated channel_close_mutual_tx
transaction
Yes
Roles:
Snapshotter
method: channels.on_chain_tx
params:
info
string
"can_snapshot"
Yes
tx
string
the last on-chain transaction that could be disputed by a snapshot
Yes
method: channels.snapshot_solo
params:
fee
integer
The on-chain transaction fee to be used. If not provided the FSM picks a value for the client
No
gas_price
integer
the gas_price to be used for the fee computation
No
nonce
integer
the nonce to be used in the transaction
No
method: channels.sign.snapshot_solo_tx
params:
channel_id
string
channel ID
Yes
data
object
closing data
Yes
data:
signed_tx
string
channel_snapshot_solo_tx
transaction wrapped in a signed_tx
with no authentication
Yes
updates
list
empty list
Yes
method: channels.snapshot_solo_sign
params:
signed_tx
string
solo-authenticated channel_snapshot_solo_tx
transaction
Yes
Roles:
Forcer
method: channels.force_progress
params:
contract_id
contract id
contract to call
Yes
call_data
call data
call data
Yes
abi_version
integer
call abi version
Yes
amount
integer
amount of coins to transfer to contract
Yes
gas_price
integer
the gas_price to be used for the fee computation and the update execution
Yes
gas
integer
gas limit, if not provided 1000000
is the default value
No
nonce
integer
the nonce to be used in the transaction
No
method: channels.sign.force_progress_tx
params:
channel_id
string
channel ID
Yes
data
object
closing data
Yes
data:
signed_tx
string
channel_force_progress_tx
transaction wrapped in a signed_tx
with no authentication
Yes
updates
list
a list of a single update
Yes
update
amount
integer
the coins amount given to the off-chain contract
Yes
abi_version
integer
abi version
Yes
call_data
integer
contract execution call data
Yes
call_stack
list
contract execution call stack
Yes
caller_id
string
ID of the caller
Yes
contract_id
string
contract ID to be executed
Yes
gas
integer
gas limit
Yes
gas_price
integer
gas price
Yes
op
string
"OffChainCallContract"
Yes
method: channels.force_progress_sign
params:
signed_tx
string
solo-authenticated channel_snapshot_solo_tx
transaction
Yes
method: channels.dry_run.call_contract
params:
contract_id
contract id
contract to call
Yes
call_data
call data
call data
Yes
abi_version
integer
call abi version
Yes
amount
integer
amount of coins to transfer to contract
Yes
block_hash
string
The on-chain block hash to pin the off-chain environment
No
meta
array of strings
Meta information about the update
No
method: channels.on_chain_tx
params:
channel_id
string
channel ID
Yes
data
object
closing data
Yes
data:
info
string
specific type of event
Yes
signed_tx
string
a mutually authenticated transaction that is posted on-chain
Yes
type
transaction type
Yes
The info
values could be:
"funding_signed"
- reported by the initiator
, indicating that a channel_create_tx
has been
singly authenticated by the initiator
client, and sent to the responder
for co-signing.
"funding_created"
- reported by the responder
, indicating that a channel_create_tx
has been
co-authenticated, and will be pushed to the mempool.
"deposit_signed"
- reported by the depositor
, indicating that a channel_deposit_tx
has been
singly authenticated by the depositor
client, and sent to the acknowledger
for co-signing.
"deposit_created"
- reported by the acknowledger
, indicating that a channel_deposit_tx
has been
co-authenticated, and will be pushed to the mempool.
"withdraw_signed"
- reported by the withdrawer
, indicating that a channel_withdraw_tx
has been
singly authenticated by the withdrawer
client, and sent to the acknowledger
for co-signing.
"withdraw_created"
- reported by the acknowledger
, indicating that a channel_withdraw_tx
has been
co-authenticated, and will be pushed to the mempool.
"channel_changed"
- reported by both parties, indicating that the fsm has detected a channel-related
transaction on-chain. Note that this will be reported also for the channel_create_tx
, once it
appears on-chain. This means that each client will get two on_chain_tx
reports for the
create, deposit, withdraw and close_mutual transactions.
"close_mutual"
- reported by both parties, indicating that a channel_close_mutual_tx
has been
co-authenticated, and will be pushed to the mempool.
"channel_closed"
- reported by both parties, when the on-chain channel state is detected to transition
to a closed
state.
"solo_closing"
- reported by both parties, when the on-chain channel state is detected to transition
to a proper solo_closing
state - that is, with the latest known state.
"can_slash"
or "can_snapshot"
- reported by both parties, when the
on-chain channel state is seen to transition into an improper state -
that is, when there exists a later mutually authenticated state than the
one reported by either party on-chain. If the channel is not yet closing -
that could be a malicious channel_force_progress_tx
and the reportedinfo
value is "can_snapshot"
. If the malicious on-chain transaction ischannel_close_solo_tx
or the channel is already closing and achannel_force_progress_tx
is received - then the info
is "can_slash"
.
Other transactions with an older round
than the latest off-chain are not
considered harmful.
Roles:
Closer
method: channels.close_solo
params:
fee
integer
The on-chain transaction fee to be used. If not provided the FSM picks a value for the client
No
gas_price
integer
the gas_price to be used for the fee computation
No
nonce
integer
the nonce to be used in the transaction
No
method: channels.sign.close_solo_sign
params:
channel_id
string
channel ID
Yes
data
object
closing data
Yes
data:
signed_tx
string
channel_close_solo_tx
transaction wrapped in a signed_tx
with no authentication
Yes
updates
list
off-chain updates
Yes
method: channels.close_solo_sign
params:
signed_tx
string
solo-authenticated channel_close_solo_tx
transaction
Yes
Roles:
Slasher
method: `channels.slash
params:
fee
integer
The on-chain transaction fee to be used. If not provided the FSM picks a value for the client
No
gas_price
integer
the gas_price to be used for the fee computation
No
nonce
integer
the nonce to be used in the transaction
No
method: channels.sign.slash_tx
params:
channel_id
string
channel ID
Yes
data
object
closing data
Yes
data:
signed_tx
string
channel_slash_tx
transaction wrapped in a signed_tx
with no authentication
Yes
updates
list
off-chain updates
Yes
method: `channels.slash_sign
params:
signed_tx
string
solo-authenticated channel_slash_tx
transaction
Yes
Roles:
Slasher
method: channels.on_chain_tx
params:
info
string
"can_slash"
Yes
tx
string
the last on-chain transaction that could be slashed
Yes