Skip to content

Commit

Permalink
Create ChannelManager.sol
Browse files Browse the repository at this point in the history
  • Loading branch information
KOSASIH authored Oct 20, 2024
1 parent 498f718 commit b938990
Showing 1 changed file with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "./StateChannel.sol";

contract ChannelManager {
mapping(address => mapping(address => StateChannel)) public channels;
event ChannelCreated(address indexed participantA, address indexed participantB, address channelAddress);

function createChannel(address _participantB) external {
require(_participantB != msg.sender, "Cannot create channel with self");
StateChannel channel = new StateChannel(msg.sender, _participantB, address(this));
channels[msg.sender][_participantB] = channel;
emit ChannelCreated(msg.sender, _participantB, address(channel));
}

function getChannel(address _participantA, address _participantB) external view returns (StateChannel) {
return channels[_participantA][_participantB];
}
}

0 comments on commit b938990

Please sign in to comment.