The most successful and well-known blockchain-based smart contract platform, Ethereum, is a stateful one. What this means is that within each block on the Ethereum blockchain, there is information regarding the entire state of it. This information includes all account balances, contract storage, contract code, etc. This contrasts with the UTXO model found in Bitcoin.
However, this information takes up space meaning that nodes are forced to store large amounts of data. This state information is often not relevant to the final outcome of the blockchain, for example:
If person A and B have a business relation, they can often times send each other tokens. Lets say that personA has 100 Ethers and person B has 50 Ethers. Now, within a month, personA sent personB 10 transactions of 5 ETH each and personB sent personA 2 transactions of 10 ETH each. The final outcome after a month will be that personA will have sent 30 ETH to the personB, which means personA will now have 70 ETH and personB will have 80 ETH.
In a stateful network, these transactions will each count as an individual transaction (15 in total), taking up space on the blockchain. However, thanks to state channels, only the final outcome needs to be included in the form of one single transaction.
What are State Channels
State channels are basically two-way pathways opened between two users that want to communicate with each other in the form of transactions. Each participant in the channel signs these transactions with his private key to ensure that they are undeniably true and authorized.
These channels are off-chain and private, known only to its participants, which means they allow for instant and anonymous transactions within them. These channels also have a limited lifespan which is predetermined based on time or amount of transactions carried out. Participants can also close their channel by providing the last updated state of transactions to the blockchain.
Once a channel closes, the transaction history within it can be uploaded into the blockchain in order for the final outcome to become official. In the personA/personB example above, the final outcome would be that personA sent 30 ETH to the personB, which means personA will now have 70 ETH and personB will have 80 ETH. This information is uploaded onto the blockchain, sparing it the back and forward transactions in the channel that led to the final outcome.
Participants can also close their channel by providing the last updated state of transactions to the blockchain. If the other participant agrees that the state provided is indeed the final one, he lets the channel close. If not, he can upload his version of the most recent state and since all transactions are signed and timestamped, the dispute will always be won by the honest party.
Other than keeping the information nodes need to store much smaller, state channels also provide additional advantages like private and instant transactions with lower fees.
However, they are not ideal for every case. For example, a smart contract that need to be aware of the state of multiple people at all times can not be run through state channels. An example of such smart contract is a DAO.
Currently, there are projects that are building on top of this technology to provide a more scalable and efficient smart contract platform that performs better on certain use cases, including the Æternity project.