# AbstractUpgraderHelper.sol

> AbstractUpgraderHelperコントラクトは、V2以降のアップグレーダーヘルパーコントラクトがProxyコントラクトの内部状態を読み取れるように共通の機能を提供する抽象コントラクトです。

- URL: https://cardene.dev/books/usdc/9ad2dd
- 本: USDC (https://cardene.dev/books/usdc.md)
- 章: 4 / 13
- 前の章: https://cardene.dev/books/usdc/1635af.md
- 次の章: https://cardene.dev/books/usdc/97f188.md
- 公開日: 2025-07-08
- 更新日: 2025-07-08
- トピック: Blockchain
- タグ: ブロックチェーン, solidity, ethereum, smartcontract

## 概要

**AbstractUpgraderHelper**コントラクトは、V2以降のアップグレーダーヘルパーコントラクトがProxyコントラクトの内部状態を読み取れるように共通の機能を提供する抽象コントラクトです。

## コード

https://github.com/circlefin/stablecoin-evm/blob/master/contracts/v2/upgrader/helpers/AbstractUpgraderHelper.sol

```sol
/**
 * Copyright 2023 Circle Internet Group, Inc. All rights reserved.
 *
 * SPDX-License-Identifier: Apache-2.0
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
pragma solidity 0.6.12;

import { Ownable } from "../../../v1/Ownable.sol";

/**
 * @dev An abstract contract to encapsulate any common logic for any V2+ Upgrader Helper contracts.
 * The helper enables the upgrader to read some contract state before it renounces the
 * proxy admin role (Proxy admins cannot call delegated methods).
 */
abstract contract AbstractUpgraderHelper is Ownable {
    address internal _proxy;

    /**
     * @notice Constructor
     * @param fiatTokenProxy    Address of the FiatTokenProxy contract
     */
    constructor(address fiatTokenProxy) public Ownable() {
        _proxy = fiatTokenProxy;
    }

    /**
     * @notice The address of the FiatTokenProxy contract
     * @return Contract address
     */
    function proxy() external view returns (address) {
        return _proxy;
    }

    /**
     * @notice Tear down the contract (self-destruct)
     */
    function tearDown() external onlyOwner {
        selfdestruct(msg.sender);
    }
}
```

## 変数

```solidity
address internal _proxy
```

**FiatTokenProxy**コントラクトのアドレス。

## 関数

### `proxy`

```solidity
function proxy() external view returns (address) {
    return _proxy;
}
```

プロキシコントラクトのアドレスを取得する関数。

**戻り値**

* `address`
    * 保存されているProxyコントラクトのアドレス

### `tearDown`

```solidity
function tearDown() external onlyOwner {
    selfdestruct(msg.sender);
}
```

コントラクトを自己破壊（selfdestruct）して、コントラクト内のETHをオーナーに送付する関数。
* `onlyOwner` 修飾子により、オーナーのみが実行できます。
* `selfdestruct` は EVM の命令で、コントラクトのコードとストレージを削除し、コントラクト内の Ether を指定アドレス（ここでは `msg.sender`＝オーナー）にまとめて送金します。
* アップグレード完了後、このヘルパーコントラクトをクリーンに取り除きたいときに用います。
