Is there an OpenZeppelin library contract that helps in implementing payment channels (I checked github repo. Could not find) or is there a smart contract that shows how channels can be implemented. I can see in the internet that all articles are about the theory of how a payment channel could work. I was wondering if there was an example of the same.
We don’t have anything payment-channel specific at the moment, no. What sort of primitives would you like to see to help you build something of this sort?
Could you please explain more about
I am having a situation where the state of a smart contract is being updated frequently by the users. I am now exploring a solution where the state updates since the channel creation is done between the parties of channel where one party will share the signed hash of the updated state as well the change he/she made to the other party. They validate the change off-channel. The other party will do the same to make more updates. Finally when one of them wants to close the channel, they can sent the update they received from the opposite party as well as a state change they want to make to the contract. The contract uses
ecrecover to check if the previous state’s hash was signed by the non-sender party as well as checks the validity of the state update the sender is trying to make. I want to know if this is the optimal way. If there is any better alternative?
There are many ways to implement this sort of thing, with multiple trade-offs. At a glance, what you describe seems to make sense, but your specific requirements may dictate different solutions.
Regarding signature checking, you’ll probably want to use our
Thank you. will check out.