JSON RPC Specification

Background

State channel clients need to run in trusted execution environments because they contain functionality to automatically sign on behalf of an end user. Decentralized applications then need to be able to make hooked calls to a user’s client similarly to how existing hooked Ethereum rpc calls occur.

In other words, state channel clients need to behave similarly to web3. They should be able to be instantiated both within the wallet by passing in signer functionality or instantiated within decentralized applications using a ChannelProvider.

The goal of this doc is to specify a set of RPC methods for channels which can be implemented in a standardized way by wallets.

Resources

This spec uses:

Provider Specification

In general, we should piggyback on the existing EIP 1193 standard with one minor change:

Constructor

channel.constructor.name;
> 'ChannelProvider'

JSON RPC Methods


Definition (state). The state of an application is a tuple of the following properties:
  • The list of participants
  • The application identifier
  • The turn number
  • The nonce
  • The bytes application data
  • The signature on this state
  • Whether or not it is final
  • Any metadata helpful in computing whether or not it is a valid transition
  • This is the specific bullet point Tom and Liam are discussing

On-Chain Methods


chan_deposit

Deposits into the channel. Comprised of generating a channel state and then executing an onchain transaction with eth_sendTransaction

English Parameters
  • Into which channel is a deposit being made.
  • What is the type of the deposit being made? e.g., ETH or ERC20
  • What is some data that can be interpreted as the deposit “amount”.
  • e.g., uint256 for Wei, uint256 for ERC20 token, bytes for general transaction

Parameters
QUANTITY- uint256 (wei units) balance to be deposited
DATA, 20 Bytes -  Hex string address of token contract. 0x0 if Ether
DATA, 20 Bytes -  Hex string address of channel

Returns
DATA, 32 Bytes - Transaction receipt of onchain transaction.


chan_withdraw