0

I came across the Micropayments channel example in the solidity docs (here: https://solidity.readthedocs.io/en/v0.6.6/solidity-by-example.html#micropayment-channel). There are two cases presented with two contracts: SimplePaymentsChannel and ReceiverPays. I am trying to reconcile how one is different from the other, given that they both seem to accomplish the same thing. The steps outlined for each contract are below, verbatim:

ReceiverPays

  1. Alice deploys the ReceiverPays contract, attaching enough Ether to cover the payments that will be made.

  2. Alice authorises a payment by signing a message with their private key.

  3. Alice sends the cryptographically signed message to Bob. The message does not need to be kept secret (explained later), and the mechanism for sending it does not matter.

  4. Bob claims their payment by presenting the signed message to the smart contract, it verifies the authenticity of the message and then releases the funds.

Micropayments Channel

  1. Alice funds a smart contract with Ether. This “opens” the payment channel.

  2. Alice signs messages that specify how much of that Ether is owed to the recipient. This step is repeated for each payment.

  3. Bob “closes” the payment channel, withdrawing their portion of the Ether and sending the remainder back to the sender.

Other than some minor differences like contract expiration and usage of nonce, what is the need to have two contracts that achieve essentially the same thing? Thank you.

1 Answer 1

1

In the first case, Alice make several small payments that Bob can claim at any time. There is no need for expiration. This makes Bob topay for the transaction fees every time he claims one payment.

In the payment channel, Alice sends an updated payment message every time, that is, if she first wants to send 1 ether to Bob, she sends a signed message saying "pay 1 ether to Bob", if later she wants to pay 0.1 more she sends a new signed message for 1.1 ether. This is because Bob can claim the payment (close the channel) only once and is in his best interest to claim the latest message.

Hope this helps

2
  • Thank you for that. As an additional clarification, does this mean that Alice needs to deploy the contract with a specific amount of ether, or does Bob deploy the contract and then sign it? But how is ether then attached to the contract?
    – Alejandro
    Commented Apr 18, 2020 at 14:09
  • 1
    Alice deploys the contract and put the ether in it and Bob can use a function in the contract to obtain the payment. Bon uses the signed messages given to him by Alice in order to get the payment.
    – Jaime
    Commented Apr 18, 2020 at 20:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.