Skip to content

Instantly share code, notes, and snippets.

@ianhe8x
Last active April 13, 2022 07:13
Show Gist options
  • Save ianhe8x/2fbcfdd895f243c8cc1b5a00cc66206f to your computer and use it in GitHub Desktop.
Save ianhe8x/2fbcfdd895f243c8cc1b5a00cc66206f to your computer and use it in GitHub Desktop.
StateChannel challenge

State Channel Sample Project

Background:

• Use any existing demo project from Celer or Connext or create your own • Run locally, start both state channel participants

Demo how it works and answer the following questions

  • What data are submitted on chain?
  • What data are stored locally? Explain the struct of this data.
  • How does dispute work? Explain the dispute resolvement flow in sense of cryptography.
@Jadedvi104
Copy link

Jadedvi104 commented Apr 12, 2022

Ref: https://github.com/connext/chaindata/blob/main/AnyswapV5ERC20.sol

function changeVault(address newVault) external onlyVault returns (bool) {
        require(newVault != address(0), "AnyswapV3ERC20: address(0x0)");
        pendingVault = newVault;
        delayVault = block.timestamp + delay;
        emit LogChangeVault(vault, pendingVault, delayVault);
        return true;
    }
Answer: Logs are part of the transaction receipts. They are generated by the clients when executing transactions and stored alongside the blockchain to allow retrieving them. But Logs are not part of the blockchain itself.

bytes32 public constant PERMIT_TYPEHASH = keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)");

Answer: this data contains bytes32 type which has been hashed by keccak256 algorithm and it will return somthing like this 0x6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9.

function _mint(address account, uint256 amount) internal {
        require(account != address(0), "ERC20: mint to the zero address");

        _totalSupply += amount;
        balanceOf[account] += amount;
        emit Transfer(address(0), account, amount);
    }

Explaination::
address(0) is the address that has no owner therefore we do not want to transfer tokens to this address.

1. Recevier must not be equal to address(0) then function will be reverted. 

@ianhe8x
Copy link
Author

ianhe8x commented Apr 13, 2022

@Jadedvi104 Can you point me the source file you commented on?

@Jadedvi104
Copy link

@Jadedvi104 Can you point me the source file you commented on?

Hello I have updated my comments, please recheck.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment