Cryo Explorer Ethereum Mainnet

Address Contract Verified

Address 0xFffb32244f3FDBF35d9Dfc7237591FbdA61f18e0
Balance 0 ETH
Nonce 9
Code Size 5935 bytes
Indexed Transactions 0
External Etherscan · Sourcify

Contract Bytecode

5935 bytes
0x608060405234801561001057600080fd5b50600436106101215760003560e01c8063549fb40d116100ad578063a8b364a111610071578063a8b364a114610282578063b99f8e9314610295578063ba92ddbc146102c8578063c626c52e146102ef578063f2fde38b1461031b57600080fd5b8063549fb40d1461020957806359659e901461022f5780636acf662114610256578063715018a6146102695780638da5cb5b1461027157600080fd5b80633b184577116100f45780633b184577146101aa5780633d8ce817146101bd57806341915118146101d05780634c42d151146101e357806353bfca0a146101f657600080fd5b806318d3ce9614610126578063193d61b4146101445780632ccf476c1461016f5780632d6b3a6b14610184575b600080fd5b61012e61032e565b60405161013b9190610c1f565b60405180910390f35b610157610152366004610c87565b610390565b6040516001600160a01b03909116815260200161013b565b61018261017d366004610cd2565b610668565b005b7f0000000000000000000000009445e49f82c945e305db9945f4ddef9c74481d18610157565b6101826101b8366004610d6b565b610713565b6101826101cb366004610cd2565b6107cc565b6101826101de366004610e12565b61086d565b6101826101f1366004610ecd565b61090c565b610182610204366004610f0f565b6109a7565b7f000000000000000000000000f792bb4b8e5c0fd469acc2cfb8481898920aac12610157565b6101577f0000000000000000000000009445e49f82c945e305db9945f4ddef9c74481d1881565b610182610264366004610f5c565b610a55565b610182610b0c565b6000546001600160a01b0316610157565b610157610290366004610fb3565b610b20565b6102b86102a3366004610fcc565b60026020526000908152604090205460ff1681565b604051901515815260200161013b565b6101577f000000000000000000000000f792bb4b8e5c0fd469acc2cfb8481898920aac1281565b6102b86102fd366004610fcc565b6001600160a01b031660009081526002602052604090205460ff1690565b610182610329366004610fcc565b610b4a565b6060600180548060200260200160405190810160405280929190818152602001828054801561038657602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311610368575b5050505050905090565b60006001600160a01b0384166103ed5760405162461bcd60e51b815260206004820152600f60248201527f496e76616c69642077616c6c657441000000000000000000000000000000000060448201526064015b60405180910390fd5b61271083111561042d5760405162461bcd60e51b815260206004820152600b60248201526a092dcecc2d8d2c840e8c2f60ab1b60448201526064016103e4565b60007fff9935cb000000000000000000000000000000000000000000000000000000003386866104656000546001600160a01b031690565b6040516001600160a01b03948516602482015292841660448401526064830191909152821660848201527f000000000000000000000000f792bb4b8e5c0fd469acc2cfb8481898920aac1290911660a48201523060c482015260e401604051602081830303815290604052906001600160e01b0319166020820180516001600160e01b038381831617835250505050905060007f0000000000000000000000009445e49f82c945e305db9945f4ddef9c74481d188260405161052690610c12565b610531929190610fee565b604051809103906000f08015801561054d573d6000803e3d6000fd5b506001805480820182557fb10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf60180546001600160a01b0384811673ffffffffffffffffffffffffffffffffffffffff1990921682179092556000818152600260209081526040808320805460ff19169096179095559054845190841681529081018a90527f000000000000000000000000f792bb4b8e5c0fd469acc2cfb8481898920aac128316818501527f0000000000000000000000009445e49f82c945e305db9945f4ddef9c74481d18831660608201526080810189905292519396508694509089169233927f56ee9777990a83897f0f4111386ecaff6ea158f654ddda5724f166200a59c438919081900360a00190a450509392505050565b3360009081526002602052604090205460ff166106bd5760405162461bcd60e51b81526020600482015260136024820152724e6f7420612076657269666965642067616d6560681b60448201526064016103e4565b60405167ffffffffffffffff8216815282906001600160a01b0380861691908716907f3c6b6f6712826b51c6e385376ad2a7d8ca1a8a592ea85b84802c2f62b314dc2a906020015b60405180910390a450505050565b3360009081526002602052604090205460ff166107685760405162461bcd60e51b81526020600482015260136024820152724e6f7420612076657269666965642067616d6560681b60448201526064016103e4565b846001600160a01b0316866001600160a01b0316886001600160a01b03167fcd5098cd899a3fb5fa2bfce822c3a41a14f12c3eab26e8595106b444150d64a1878787876040516107bb9493929190611097565b60405180910390a450505050505050565b3360009081526002602052604090205460ff166108215760405162461bcd60e51b81526020600482015260136024820152724e6f7420612076657269666965642067616d6560681b60448201526064016103e4565b60405167ffffffffffffffff8216815282906001600160a01b0380861691908716907fcea23912a163e583c13d507adc63bb5476ef4a14c7f2e933fc52271c13436cc790602001610705565b3360009081526002602052604090205460ff166108c25760405162461bcd60e51b81526020600482015260136024820152724e6f7420612076657269666965642067616d6560681b60448201526064016103e4565b82866001600160a01b0316886001600160a01b03167f30cfc38864c0226c5c2f5221ecead8dcfc161dba3b1f12feff3ff4e063d9378b888887876040516107bb94939291906110c9565b3360009081526002602052604090205460ff166109615760405162461bcd60e51b81526020600482015260136024820152724e6f7420612076657269666965642067616d6560681b60448201526064016103e4565b81836001600160a01b0316856001600160a01b03167fb15d00904bfe06b34aed332b8d3485168115cc6cd5c5603bda5d46912bbf42538460405161070591815260200190565b3360009081526002602052604090205460ff166109fc5760405162461bcd60e51b81526020600482015260136024820152724e6f7420612076657269666965642067616d6560681b60448201526064016103e4565b60408051848152602081018490529081018290526001600160a01b0380861691908716907f0e7cbf06f97731324a132bc503b59a17bf565ae4683fbc9449e2c06ec3fdb9af906060015b60405180910390a35050505050565b3360009081526002602052604090205460ff16610aaa5760405162461bcd60e51b81526020600482015260136024820152724e6f7420612076657269666965642067616d6560681b60448201526064016103e4565b836001600160a01b0316856001600160a01b03167f67e042b302a904856e184898fd27680f22aed4df32c14af1e32cf6665332926f858585604051610a4693929190928352602083019190915267ffffffffffffffff16604082015260600190565b610b14610b88565b610b1e6000610bb5565b565b60018181548110610b3057600080fd5b6000918252602090912001546001600160a01b0316905081565b610b52610b88565b6001600160a01b038116610b7c57604051631e4fbdf760e01b8152600060048201526024016103e4565b610b8581610bb5565b50565b6000546001600160a01b03163314610b1e5760405163118cdaa760e01b81523360048201526024016103e4565b600080546001600160a01b0383811673ffffffffffffffffffffffffffffffffffffffff19831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6105ea8061111083390190565b602080825282518282018190526000918401906040840190835b81811015610c605783516001600160a01b0316835260209384019390920191600101610c39565b509095945050505050565b80356001600160a01b0381168114610c8257600080fd5b919050565b600080600060608486031215610c9c57600080fd5b610ca584610c6b565b95602085013595506040909401359392505050565b803567ffffffffffffffff81168114610c8257600080fd5b60008060008060808587031215610ce857600080fd5b610cf185610c6b565b9350610cff60208601610c6b565b925060408501359150610d1460608601610cba565b905092959194509250565b60008083601f840112610d3157600080fd5b50813567ffffffffffffffff811115610d4957600080fd5b6020830191508360208260051b8501011115610d6457600080fd5b9250929050565b600080600080600080600060a0888a031215610d8657600080fd5b610d8f88610c6b565b9650610d9d60208901610c6b565b9550610dab60408901610c6b565b9450606088013567ffffffffffffffff811115610dc757600080fd5b610dd38a828b01610d1f565b909550935050608088013567ffffffffffffffff811115610df357600080fd5b610dff8a828b01610d1f565b989b979a50959850939692959293505050565b600080600080600080600060c0888a031215610e2d57600080fd5b610e3688610c6b565b9650610e4460208901610c6b565b9550610e5260408901610c6b565b9450606088013593506080880135925060a088013567ffffffffffffffff811115610e7c57600080fd5b8801601f81018a13610e8d57600080fd5b803567ffffffffffffffff811115610ea457600080fd5b8a6020828401011115610eb657600080fd5b602082019350809250505092959891949750929550565b60008060008060808587031215610ee357600080fd5b610eec85610c6b565b9350610efa60208601610c6b565b93969395505050506040820135916060013590565b600080600080600060a08688031215610f2757600080fd5b610f3086610c6b565b9450610f3e60208701610c6b565b94979496505050506040830135926060810135926080909101359150565b600080600080600060a08688031215610f7457600080fd5b610f7d86610c6b565b9450610f8b60208701610c6b565b93506040860135925060608601359150610fa760808701610cba565b90509295509295909350565b600060208284031215610fc557600080fd5b5035919050565b600060208284031215610fde57600080fd5b610fe782610c6b565b9392505050565b6001600160a01b0383168152604060208201526000825180604084015260005b8181101561102b576020818601810151606086840101520161100e565b506000606082850101526060601f19601f8301168401019150509392505050565b81835260007f07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff83111561107e57600080fd5b8260051b80836020870137939093016020019392505050565b6040815260006110ab60408301868861104c565b82810360208401526110be81858761104c565b979650505050505050565b6001600160a01b038516815283602082015260606040820152816060820152818360808301376000818301608090810191909152601f909201601f19160101939250505056fe60a06040526040516105ea3803806105ea83398101604081905261002291610386565b61002c828261003e565b506001600160a01b0316608052610483565b610047826100fe565b6040516001600160a01b038316907f1cf3b03a6cf19fa2baba4df148e9dcabedea7f8a5c07840e207e5c089be95d3e90600090a28051156100f2576100ed826001600160a01b0316635c60da1b6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156100c3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906100e7919061044c565b82610211565b505050565b6100fa610288565b5050565b806001600160a01b03163b60000361013957604051631933b43b60e21b81526001600160a01b03821660048201526024015b60405180910390fd5b807fa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d5080546001600160a01b0319166001600160a01b0392831617905560408051635c60da1b60e01b81529051600092841691635c60da1b9160048083019260209291908290030181865afa1580156101b5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101d9919061044c565b9050806001600160a01b03163b6000036100fa57604051634c9c8ce360e01b81526001600160a01b0382166004820152602401610130565b6060600080846001600160a01b03168460405161022e9190610467565b600060405180830381855af49150503d8060008114610269576040519150601f19603f3d011682016040523d82523d6000602084013e61026e565b606091505b50909250905061027f8583836102a9565b95945050505050565b34156102a75760405163b398979f60e01b815260040160405180910390fd5b565b6060826102be576102b982610308565b610301565b81511580156102d557506001600160a01b0384163b155b156102fe57604051639996b31560e01b81526001600160a01b0385166004820152602401610130565b50805b9392505050565b80511561031757805160208201fd5b60405163d6bda27560e01b815260040160405180910390fd5b80516001600160a01b038116811461034757600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b60005b8381101561037d578181015183820152602001610365565b50506000910152565b6000806040838503121561039957600080fd5b6103a283610330565b60208401519092506001600160401b038111156103be57600080fd5b8301601f810185136103cf57600080fd5b80516001600160401b038111156103e8576103e861034c565b604051601f8201601f19908116603f011681016001600160401b03811182821017156104165761041661034c565b60405281815282820160200187101561042e57600080fd5b61043f826020830160208601610362565b8093505050509250929050565b60006020828403121561045e57600080fd5b61030182610330565b60008251610479818460208701610362565b9190910192915050565b60805161014d61049d60003960006024015261014d6000f3fe608060405261000c61000e565b005b61001e610019610020565b6100b6565b565b60007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16635c60da1b6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561008d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906100b191906100da565b905090565b3660008037600080366000845af43d6000803e8080156100d5573d6000f35b3d6000fd5b6000602082840312156100ec57600080fd5b815173ffffffffffffffffffffffffffffffffffffffff8116811461011057600080fd5b939250505056fea2646970667358221220352b5d14f6e9462c8e5ce7fc21aa92f04c904910d7baf22d912ea0b1e62cbb4e64736f6c634300081e0033a26469706673582212204029fcb7b78535e872790ea20db6e2bfa1377817dab37cde1367d3ea2d6075cf64736f6c634300081e0033

Verified Source Code Full Match

Compiler: v0.8.30+commit.73712a01 EVM: paris Optimization: Yes (500 runs)
evmPaymentFactory.sol 241 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

// ─────────────────────────────────────────────
// Imports (OpenZeppelin 5.x)
// ─────────────────────────────────────────────
import "@openzeppelin/contracts/proxy/beacon/BeaconProxy.sol";
import "@openzeppelin/contracts/access/Ownable.sol";

// ─────────────────────────────────────────────
// Interfaces
// ─────────────────────────────────────────────
interface IEthereumPaymentUpgradeable {
    function initialize(
        address publisherOwner,
        address _walletA,
        uint256 _taxBps,
        address _platformAdmin,
        address _signer,
        address registry_
    ) external;
}

// ─────────────────────────────────────────────
// Beacon Factory = Central Registry + Event Hub
// ─────────────────────────────────────────────
contract EthereumPaymentFactoryBeacon is Ownable {
    // ──────────────── Config ────────────────
    address public immutable beacon;
    address public immutable platformSigner;
    address[] public deployedPayments;
    mapping(address => bool) public isDeployedPayment; // verification map

    // ──────────────── Events ────────────────
    event PaymentContractCreated(
        address indexed proxyAddress,
        address indexed publisher,
        address indexed walletA,
        address walletB,
        uint256 taxBps,
        address signer,
        address beacon,
        bytes32 gameGuid             
    );


    // 🔹 Unified central events (Alchemy listens to these)
    event CentralPayment(
        address indexed game,
        address indexed buyer,
        address paymentToken,
        uint256 amount,
        bytes32 indexed paymentGuidHash,
        string userId
    );

    event CentralMint(
        address indexed game,
        address indexed to,
        uint256 tokenId,
        uint256 quantity,
        bytes32 itemId
    );

    event CentralSubscribe(
        address indexed game,
        address indexed user,
        bytes32 indexed paymentGuidHash,
        uint64 expiry
    );

    event CentralRenew(
        address indexed game,
        address indexed user,
        bytes32 indexed paymentGuidHash,
        uint64 newExpiry
    );

    event CentralUpgrade(
        address indexed game,
        address indexed user,
        bytes32 oldGuid,
        bytes32 newGuid,
        uint64 newExpiry
    );

    event CentralBurn(
        address indexed game,
        address indexed user,
        uint256 indexed tokenId,
        uint256 amount
    );

    event CentralTransfer(
        address indexed game,
        address indexed from,
        address indexed to,
        uint256[] ids,
        uint256[] amounts
    );


    // ──────────────── Constructor ────────────────
    constructor(address _beacon, address _platformSigner)
        Ownable(msg.sender)
    {
        require(_beacon != address(0), "Invalid beacon");
        require(_platformSigner != address(0), "Invalid signer");
        beacon = _beacon;
        platformSigner = _platformSigner;
    }

    // ──────────────── Deploy new publisher/game contract ────────────────
    function createPaymentContract(address walletA, uint256 taxBps, bytes32 gameGuid)
        external
        returns (address proxyAddr)
    {
        require(walletA != address(0), "Invalid walletA");
        require(taxBps <= 10_000, "Invalid tax");

        bytes memory initData = abi.encodeWithSelector(
            IEthereumPaymentUpgradeable.initialize.selector,
            msg.sender,        // publisher owner
            walletA,           // publisher payout wallet
            taxBps,
            owner(),           // platform admin (factory owner)
            platformSigner,    // backend signer
            address(this)      // registry = factory
        );

        // Deploy BeaconProxy pointing to shared beacon
        BeaconProxy proxy = new BeaconProxy(beacon, initData);
        proxyAddr = address(proxy);
        deployedPayments.push(proxyAddr);
        isDeployedPayment[proxyAddr] = true;

        emit PaymentContractCreated(
            proxyAddr,
            msg.sender,
            walletA,
            owner(),
            taxBps,
            platformSigner,
            beacon,
            gameGuid
        );

    }

    // ──────────────── Restrict to verified game contracts ────────────────
    modifier onlyPaymentContract() {
        require(isDeployedPayment[msg.sender], "Not a verified game");
        _;
    }

    // ──────────────── Central relay sinks ────────────────
    function emitCentralPayment(
        address game,
        address buyer,
        address paymentToken,
        uint256 amount,
        bytes32 paymentGuidHash,
        string calldata userId
    ) external onlyPaymentContract {
        emit CentralPayment(game, buyer, paymentToken, amount, paymentGuidHash, userId);
    }

    function emitCentralMint(
        address game,
        address to,
        uint256 tokenId,
        uint256 quantity,
        bytes32 itemId
    ) external onlyPaymentContract {
        emit CentralMint(game, to, tokenId, quantity, itemId);
    }

    function emitCentralSubscribe(
        address game,
        address user,
        bytes32 paymentGuidHash,
        uint64 expiry
    ) external onlyPaymentContract {
        emit CentralSubscribe(game, user, paymentGuidHash, expiry);
    }

    function emitCentralRenew(
        address game,
        address user,
        bytes32 paymentGuidHash,
        uint64 newExpiry
    ) external onlyPaymentContract {
        emit CentralRenew(game, user, paymentGuidHash, newExpiry);
    }

    function emitCentralUpgrade(
        address game,
        address user,
        bytes32 oldGuid,
        bytes32 newGuid,
        uint64 newExpiry
    ) external onlyPaymentContract {
        emit CentralUpgrade(game, user, oldGuid, newGuid, newExpiry);
    }

    function emitCentralBurn(
        address game,
        address user,
        uint256 tokenId,
        uint256 amount
    ) external onlyPaymentContract {
        emit CentralBurn(game, user, tokenId, amount);
    }
    function emitCentralTransfer(
        address game,
        address from,
        address to,
        uint256[] calldata ids,
        uint256[] calldata amounts
    ) external onlyPaymentContract {
        emit CentralTransfer(game, from, to, ids, amounts);
    }


    // ──────────────── Helpers ────────────────
    function getAllContracts() external view returns (address[] memory) {
        return deployedPayments;
    }

    function getBeacon() external view returns (address) {
        return beacon;
    }

    function getPlatformSigner() external view returns (address) {
        return platformSigner;
    }

    function isGame(address gameAddr) external view returns (bool) {
        return isDeployedPayment[gameAddr];
    }
}
Ownable.sol 100 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)

pragma solidity ^0.8.20;

import {Context} from "../utils/Context.sol";

/**
 * @dev Contract module which provides a basic access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 *
 * The initial owner is set to the address provided by the deployer. This can
 * later be changed with {transferOwnership}.
 *
 * This module is used through inheritance. It will make available the modifier
 * `onlyOwner`, which can be applied to your functions to restrict their use to
 * the owner.
 */
abstract contract Ownable is Context {
    address private _owner;

    /**
     * @dev The caller account is not authorized to perform an operation.
     */
    error OwnableUnauthorizedAccount(address account);

    /**
     * @dev The owner is not a valid owner account. (eg. `address(0)`)
     */
    error OwnableInvalidOwner(address owner);

    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

    /**
     * @dev Initializes the contract setting the address provided by the deployer as the initial owner.
     */
    constructor(address initialOwner) {
        if (initialOwner == address(0)) {
            revert OwnableInvalidOwner(address(0));
        }
        _transferOwnership(initialOwner);
    }

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        _checkOwner();
        _;
    }

    /**
     * @dev Returns the address of the current owner.
     */
    function owner() public view virtual returns (address) {
        return _owner;
    }

    /**
     * @dev Throws if the sender is not the owner.
     */
    function _checkOwner() internal view virtual {
        if (owner() != _msgSender()) {
            revert OwnableUnauthorizedAccount(_msgSender());
        }
    }

    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby disabling any functionality that is only available to the owner.
     */
    function renounceOwnership() public virtual onlyOwner {
        _transferOwnership(address(0));
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public virtual onlyOwner {
        if (newOwner == address(0)) {
            revert OwnableInvalidOwner(address(0));
        }
        _transferOwnership(newOwner);
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Internal function without access restriction.
     */
    function _transferOwnership(address newOwner) internal virtual {
        address oldOwner = _owner;
        _owner = newOwner;
        emit OwnershipTransferred(oldOwner, newOwner);
    }
}
BeaconProxy.sol 57 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.2.0) (proxy/beacon/BeaconProxy.sol)

pragma solidity ^0.8.22;

import {IBeacon} from "./IBeacon.sol";
import {Proxy} from "../Proxy.sol";
import {ERC1967Utils} from "../ERC1967/ERC1967Utils.sol";

/**
 * @dev This contract implements a proxy that gets the implementation address for each call from an {UpgradeableBeacon}.
 *
 * The beacon address can only be set once during construction, and cannot be changed afterwards. It is stored in an
 * immutable variable to avoid unnecessary storage reads, and also in the beacon storage slot specified by
 * https://eips.ethereum.org/EIPS/eip-1967[ERC-1967] so that it can be accessed externally.
 *
 * CAUTION: Since the beacon address can never be changed, you must ensure that you either control the beacon, or trust
 * the beacon to not upgrade the implementation maliciously.
 *
 * IMPORTANT: Do not use the implementation logic to modify the beacon storage slot. Doing so would leave the proxy in
 * an inconsistent state where the beacon storage slot does not match the beacon address.
 */
contract BeaconProxy is Proxy {
    // An immutable address for the beacon to avoid unnecessary SLOADs before each delegate call.
    address private immutable _beacon;

    /**
     * @dev Initializes the proxy with `beacon`.
     *
     * If `data` is nonempty, it's used as data in a delegate call to the implementation returned by the beacon. This
     * will typically be an encoded function call, and allows initializing the storage of the proxy like a Solidity
     * constructor.
     *
     * Requirements:
     *
     * - `beacon` must be a contract with the interface {IBeacon}.
     * - If `data` is empty, `msg.value` must be zero.
     */
    constructor(address beacon, bytes memory data) payable {
        ERC1967Utils.upgradeBeaconToAndCall(beacon, data);
        _beacon = beacon;
    }

    /**
     * @dev Returns the current implementation address of the associated beacon.
     */
    function _implementation() internal view virtual override returns (address) {
        return IBeacon(_getBeacon()).implementation();
    }

    /**
     * @dev Returns the beacon.
     */
    function _getBeacon() internal view virtual returns (address) {
        return _beacon;
    }
}
ERC1967Utils.sol 177 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (proxy/ERC1967/ERC1967Utils.sol)

pragma solidity ^0.8.21;

import {IBeacon} from "../beacon/IBeacon.sol";
import {IERC1967} from "../../interfaces/IERC1967.sol";
import {Address} from "../../utils/Address.sol";
import {StorageSlot} from "../../utils/StorageSlot.sol";

/**
 * @dev This library provides getters and event emitting update functions for
 * https://eips.ethereum.org/EIPS/eip-1967[ERC-1967] slots.
 */
library ERC1967Utils {
    /**
     * @dev Storage slot with the address of the current implementation.
     * This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1.
     */
    // solhint-disable-next-line private-vars-leading-underscore
    bytes32 internal constant IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;

    /**
     * @dev The `implementation` of the proxy is invalid.
     */
    error ERC1967InvalidImplementation(address implementation);

    /**
     * @dev The `admin` of the proxy is invalid.
     */
    error ERC1967InvalidAdmin(address admin);

    /**
     * @dev The `beacon` of the proxy is invalid.
     */
    error ERC1967InvalidBeacon(address beacon);

    /**
     * @dev An upgrade function sees `msg.value > 0` that may be lost.
     */
    error ERC1967NonPayable();

    /**
     * @dev Returns the current implementation address.
     */
    function getImplementation() internal view returns (address) {
        return StorageSlot.getAddressSlot(IMPLEMENTATION_SLOT).value;
    }

    /**
     * @dev Stores a new address in the ERC-1967 implementation slot.
     */
    function _setImplementation(address newImplementation) private {
        if (newImplementation.code.length == 0) {
            revert ERC1967InvalidImplementation(newImplementation);
        }
        StorageSlot.getAddressSlot(IMPLEMENTATION_SLOT).value = newImplementation;
    }

    /**
     * @dev Performs implementation upgrade with additional setup call if data is nonempty.
     * This function is payable only if the setup call is performed, otherwise `msg.value` is rejected
     * to avoid stuck value in the contract.
     *
     * Emits an {IERC1967-Upgraded} event.
     */
    function upgradeToAndCall(address newImplementation, bytes memory data) internal {
        _setImplementation(newImplementation);
        emit IERC1967.Upgraded(newImplementation);

        if (data.length > 0) {
            Address.functionDelegateCall(newImplementation, data);
        } else {
            _checkNonPayable();
        }
    }

    /**
     * @dev Storage slot with the admin of the contract.
     * This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1.
     */
    // solhint-disable-next-line private-vars-leading-underscore
    bytes32 internal constant ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;

    /**
     * @dev Returns the current admin.
     *
     * TIP: To get this value clients can read directly from the storage slot shown below (specified by ERC-1967) using
     * the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.
     * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`
     */
    function getAdmin() internal view returns (address) {
        return StorageSlot.getAddressSlot(ADMIN_SLOT).value;
    }

    /**
     * @dev Stores a new address in the ERC-1967 admin slot.
     */
    function _setAdmin(address newAdmin) private {
        if (newAdmin == address(0)) {
            revert ERC1967InvalidAdmin(address(0));
        }
        StorageSlot.getAddressSlot(ADMIN_SLOT).value = newAdmin;
    }

    /**
     * @dev Changes the admin of the proxy.
     *
     * Emits an {IERC1967-AdminChanged} event.
     */
    function changeAdmin(address newAdmin) internal {
        emit IERC1967.AdminChanged(getAdmin(), newAdmin);
        _setAdmin(newAdmin);
    }

    /**
     * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.
     * This is the keccak-256 hash of "eip1967.proxy.beacon" subtracted by 1.
     */
    // solhint-disable-next-line private-vars-leading-underscore
    bytes32 internal constant BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;

    /**
     * @dev Returns the current beacon.
     */
    function getBeacon() internal view returns (address) {
        return StorageSlot.getAddressSlot(BEACON_SLOT).value;
    }

    /**
     * @dev Stores a new beacon in the ERC-1967 beacon slot.
     */
    function _setBeacon(address newBeacon) private {
        if (newBeacon.code.length == 0) {
            revert ERC1967InvalidBeacon(newBeacon);
        }

        StorageSlot.getAddressSlot(BEACON_SLOT).value = newBeacon;

        address beaconImplementation = IBeacon(newBeacon).implementation();
        if (beaconImplementation.code.length == 0) {
            revert ERC1967InvalidImplementation(beaconImplementation);
        }
    }

    /**
     * @dev Change the beacon and trigger a setup call if data is nonempty.
     * This function is payable only if the setup call is performed, otherwise `msg.value` is rejected
     * to avoid stuck value in the contract.
     *
     * Emits an {IERC1967-BeaconUpgraded} event.
     *
     * CAUTION: Invoking this function has no effect on an instance of {BeaconProxy} since v5, since
     * it uses an immutable beacon without looking at the value of the ERC-1967 beacon slot for
     * efficiency.
     */
    function upgradeBeaconToAndCall(address newBeacon, bytes memory data) internal {
        _setBeacon(newBeacon);
        emit IERC1967.BeaconUpgraded(newBeacon);

        if (data.length > 0) {
            Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);
        } else {
            _checkNonPayable();
        }
    }

    /**
     * @dev Reverts if `msg.value` is not zero. It can be used to avoid `msg.value` stuck in the contract
     * if an upgrade doesn't perform an initialization call.
     */
    function _checkNonPayable() private {
        if (msg.value > 0) {
            revert ERC1967NonPayable();
        }
    }
}
Proxy.sol 69 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (proxy/Proxy.sol)

pragma solidity ^0.8.20;

/**
 * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM
 * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to
 * be specified by overriding the virtual {_implementation} function.
 *
 * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a
 * different contract through the {_delegate} function.
 *
 * The success and return data of the delegated call will be returned back to the caller of the proxy.
 */
abstract contract Proxy {
    /**
     * @dev Delegates the current call to `implementation`.
     *
     * This function does not return to its internal call site, it will return directly to the external caller.
     */
    function _delegate(address implementation) internal virtual {
        assembly {
            // Copy msg.data. We take full control of memory in this inline assembly
            // block because it will not return to Solidity code. We overwrite the
            // Solidity scratch pad at memory position 0.
            calldatacopy(0, 0, calldatasize())

            // Call the implementation.
            // out and outsize are 0 because we don't know the size yet.
            let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)

            // Copy the returned data.
            returndatacopy(0, 0, returndatasize())

            switch result
            // delegatecall returns 0 on error.
            case 0 {
                revert(0, returndatasize())
            }
            default {
                return(0, returndatasize())
            }
        }
    }

    /**
     * @dev This is a virtual function that should be overridden so it returns the address to which the fallback
     * function and {_fallback} should delegate.
     */
    function _implementation() internal view virtual returns (address);

    /**
     * @dev Delegates the current call to the address returned by `_implementation()`.
     *
     * This function does not return to its internal call site, it will return directly to the external caller.
     */
    function _fallback() internal virtual {
        _delegate(_implementation());
    }

    /**
     * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other
     * function in the contract matches the call data.
     */
    fallback() external payable virtual {
        _fallback();
    }
}
IBeacon.sol 16 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (proxy/beacon/IBeacon.sol)

pragma solidity >=0.4.16;

/**
 * @dev This is the interface that {BeaconProxy} expects of its beacon.
 */
interface IBeacon {
    /**
     * @dev Must return an address that can be used as a delegate call target.
     *
     * {UpgradeableBeacon} will check that this address is a contract.
     */
    function implementation() external view returns (address);
}
Context.sol 28 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)

pragma solidity ^0.8.20;

/**
 * @dev Provides information about the current execution context, including the
 * sender of the transaction and its data. While these are generally available
 * via msg.sender and msg.data, they should not be accessed in such a direct
 * manner, since when dealing with meta-transactions the account sending and
 * paying for execution may not be the actual sender (as far as an application
 * is concerned).
 *
 * This contract is only required for intermediate, library-like contracts.
 */
abstract contract Context {
    function _msgSender() internal view virtual returns (address) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes calldata) {
        return msg.data;
    }

    function _contextSuffixLength() internal view virtual returns (uint256) {
        return 0;
    }
}
StorageSlot.sol 143 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/StorageSlot.sol)
// This file was procedurally generated from scripts/generate/templates/StorageSlot.js.

pragma solidity ^0.8.20;

/**
 * @dev Library for reading and writing primitive types to specific storage slots.
 *
 * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.
 * This library helps with reading and writing to such slots without the need for inline assembly.
 *
 * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.
 *
 * Example usage to set ERC-1967 implementation slot:
 * ```solidity
 * contract ERC1967 {
 *     // Define the slot. Alternatively, use the SlotDerivation library to derive the slot.
 *     bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
 *
 *     function _getImplementation() internal view returns (address) {
 *         return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
 *     }
 *
 *     function _setImplementation(address newImplementation) internal {
 *         require(newImplementation.code.length > 0);
 *         StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
 *     }
 * }
 * ```
 *
 * TIP: Consider using this library along with {SlotDerivation}.
 */
library StorageSlot {
    struct AddressSlot {
        address value;
    }

    struct BooleanSlot {
        bool value;
    }

    struct Bytes32Slot {
        bytes32 value;
    }

    struct Uint256Slot {
        uint256 value;
    }

    struct Int256Slot {
        int256 value;
    }

    struct StringSlot {
        string value;
    }

    struct BytesSlot {
        bytes value;
    }

    /**
     * @dev Returns an `AddressSlot` with member `value` located at `slot`.
     */
    function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {
        assembly ("memory-safe") {
            r.slot := slot
        }
    }

    /**
     * @dev Returns a `BooleanSlot` with member `value` located at `slot`.
     */
    function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {
        assembly ("memory-safe") {
            r.slot := slot
        }
    }

    /**
     * @dev Returns a `Bytes32Slot` with member `value` located at `slot`.
     */
    function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {
        assembly ("memory-safe") {
            r.slot := slot
        }
    }

    /**
     * @dev Returns a `Uint256Slot` with member `value` located at `slot`.
     */
    function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {
        assembly ("memory-safe") {
            r.slot := slot
        }
    }

    /**
     * @dev Returns a `Int256Slot` with member `value` located at `slot`.
     */
    function getInt256Slot(bytes32 slot) internal pure returns (Int256Slot storage r) {
        assembly ("memory-safe") {
            r.slot := slot
        }
    }

    /**
     * @dev Returns a `StringSlot` with member `value` located at `slot`.
     */
    function getStringSlot(bytes32 slot) internal pure returns (StringSlot storage r) {
        assembly ("memory-safe") {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `StringSlot` representation of the string storage pointer `store`.
     */
    function getStringSlot(string storage store) internal pure returns (StringSlot storage r) {
        assembly ("memory-safe") {
            r.slot := store.slot
        }
    }

    /**
     * @dev Returns a `BytesSlot` with member `value` located at `slot`.
     */
    function getBytesSlot(bytes32 slot) internal pure returns (BytesSlot storage r) {
        assembly ("memory-safe") {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `BytesSlot` representation of the bytes storage pointer `store`.
     */
    function getBytesSlot(bytes storage store) internal pure returns (BytesSlot storage r) {
        assembly ("memory-safe") {
            r.slot := store.slot
        }
    }
}
Address.sol 149 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (utils/Address.sol)

pragma solidity ^0.8.20;

import {Errors} from "./Errors.sol";

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev There's no code at `target` (it is not a contract).
     */
    error AddressEmptyCode(address target);

    /**
     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
     * `recipient`, forwarding all available gas and reverting on errors.
     *
     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
     * of certain opcodes, possibly making contracts go over the 2300 gas limit
     * imposed by `transfer`, making them unable to receive funds via
     * `transfer`. {sendValue} removes this limitation.
     *
     * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].
     *
     * IMPORTANT: because control is transferred to `recipient`, care must be
     * taken to not create reentrancy vulnerabilities. Consider using
     * {ReentrancyGuard} or the
     * https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
     */
    function sendValue(address payable recipient, uint256 amount) internal {
        if (address(this).balance < amount) {
            revert Errors.InsufficientBalance(address(this).balance, amount);
        }

        (bool success, bytes memory returndata) = recipient.call{value: amount}("");
        if (!success) {
            _revert(returndata);
        }
    }

    /**
     * @dev Performs a Solidity function call using a low level `call`. A
     * plain `call` is an unsafe replacement for a function call: use this
     * function instead.
     *
     * If `target` reverts with a revert reason or custom error, it is bubbled
     * up by this function (like regular Solidity function calls). However, if
     * the call reverted with no returned reason, this function reverts with a
     * {Errors.FailedCall} error.
     *
     * Returns the raw returned data. To convert to the expected return value,
     * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
     *
     * Requirements:
     *
     * - `target` must be a contract.
     * - calling `target` with `data` must not revert.
     */
    function functionCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but also transferring `value` wei to `target`.
     *
     * Requirements:
     *
     * - the calling contract must have an ETH balance of at least `value`.
     * - the called Solidity function must be `payable`.
     */
    function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
        if (address(this).balance < value) {
            revert Errors.InsufficientBalance(address(this).balance, value);
        }
        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResultFromTarget(target, success, returndata);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a static call.
     */
    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResultFromTarget(target, success, returndata);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a delegate call.
     */
    function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
        (bool success, bytes memory returndata) = target.delegatecall(data);
        return verifyCallResultFromTarget(target, success, returndata);
    }

    /**
     * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target
     * was not a contract or bubbling up the revert reason (falling back to {Errors.FailedCall}) in case
     * of an unsuccessful call.
     */
    function verifyCallResultFromTarget(
        address target,
        bool success,
        bytes memory returndata
    ) internal view returns (bytes memory) {
        if (!success) {
            _revert(returndata);
        } else {
            // only check if target is a contract if the call was successful and the return data is empty
            // otherwise we already know that it was a contract
            if (returndata.length == 0 && target.code.length == 0) {
                revert AddressEmptyCode(target);
            }
            return returndata;
        }
    }

    /**
     * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the
     * revert reason or with a default {Errors.FailedCall} error.
     */
    function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {
        if (!success) {
            _revert(returndata);
        } else {
            return returndata;
        }
    }

    /**
     * @dev Reverts with returndata if present. Otherwise reverts with {Errors.FailedCall}.
     */
    function _revert(bytes memory returndata) private pure {
        // Look for revert reason and bubble it up if present
        if (returndata.length > 0) {
            // The easiest way to bubble the revert reason is using memory via assembly
            assembly ("memory-safe") {
                revert(add(returndata, 0x20), mload(returndata))
            }
        } else {
            revert Errors.FailedCall();
        }
    }
}
IERC1967.sol 24 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (interfaces/IERC1967.sol)

pragma solidity >=0.4.11;

/**
 * @dev ERC-1967: Proxy Storage Slots. This interface contains the events defined in the ERC.
 */
interface IERC1967 {
    /**
     * @dev Emitted when the implementation is upgraded.
     */
    event Upgraded(address indexed implementation);

    /**
     * @dev Emitted when the admin account has changed.
     */
    event AdminChanged(address previousAdmin, address newAdmin);

    /**
     * @dev Emitted when the beacon is changed.
     */
    event BeaconUpgraded(address indexed beacon);
}
Errors.sol 34 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/Errors.sol)

pragma solidity ^0.8.20;

/**
 * @dev Collection of common custom errors used in multiple contracts
 *
 * IMPORTANT: Backwards compatibility is not guaranteed in future versions of the library.
 * It is recommended to avoid relying on the error API for critical functionality.
 *
 * _Available since v5.1._
 */
library Errors {
    /**
     * @dev The ETH balance of the account is not enough to perform the operation.
     */
    error InsufficientBalance(uint256 balance, uint256 needed);

    /**
     * @dev A call to an address target failed. The target may have reverted.
     */
    error FailedCall();

    /**
     * @dev The deployment failed.
     */
    error FailedDeployment();

    /**
     * @dev A necessary precompile is missing.
     */
    error MissingPrecompile(address);
}

Read Contract

beacon 0x59659e90 → address
deployedPayments 0xa8b364a1 → address
getAllContracts 0x18d3ce96 → address[]
getBeacon 0x2d6b3a6b → address
getPlatformSigner 0x549fb40d → address
isDeployedPayment 0xb99f8e93 → bool
isGame 0xc626c52e → bool
owner 0x8da5cb5b → address
platformSigner 0xba92ddbc → address

Write Contract 10 functions

These functions modify contract state and require a wallet transaction to execute.

createPaymentContract 0x193d61b4
address walletA
uint256 taxBps
bytes32 gameGuid
returns: address
emitCentralBurn 0x4c42d151
address game
address user
uint256 tokenId
uint256 amount
emitCentralMint 0x53bfca0a
address game
address to
uint256 tokenId
uint256 quantity
bytes32 itemId
emitCentralPayment 0x41915118
address game
address buyer
address paymentToken
uint256 amount
bytes32 paymentGuidHash
string userId
emitCentralRenew 0x3d8ce817
address game
address user
bytes32 paymentGuidHash
uint64 newExpiry
emitCentralSubscribe 0x2ccf476c
address game
address user
bytes32 paymentGuidHash
uint64 expiry
emitCentralTransfer 0x3b184577
address game
address from
address to
uint256[] ids
uint256[] amounts
emitCentralUpgrade 0x6acf6621
address game
address user
bytes32 oldGuid
bytes32 newGuid
uint64 newExpiry
renounceOwnership 0x715018a6
No parameters
transferOwnership 0xf2fde38b
address newOwner

Recent Transactions

No transactions found for this address