BankContract { mapping(address => mapping(address => uint256)) public tokenBalances; function deposit(address _token, uint256 _value) public { ERC20 token = ERC20(_token); token.transferFrom(msg.sender, address(this), _value); //※ ここは厳密には動かないかも。 tokenBalances[_token][msg.sender] = tokenBalances[_token][msg.sender].add(_value); } function exit(address _token) public { // 条件を満たしたら引き出せる処理 require(tokenBalances[_token][msg.sender] > 0); ERC20 token = ERC20(_token); uint256 volume = tokenBalances[_token][msg.sender]; tokenBalances[_token][msg.sender] = 0; token.transfer(msg.sender, volume); } }