Address Contract Verified
Address
0xFDaEA9A17dbEbdE16796F825B0839F5Fcf491807
Balance
0 ETH
Nonce
1
Code Size
7491 bytes
Creator
0x2f6696C2...8326 at tx 0xb57dd20b...d698d0
Indexed Transactions
0
Contract Bytecode
7491 bytes
0x6080604052600436106100e0575f3560e01c8063664983c81161007e5780638da5cb5b116100585780638da5cb5b146102e6578063df9d58ff14610310578063eb13554f14610338578063f2fde38b1461036257610117565b8063664983c81461027c578063715018a6146102a65780638d01513c146102bc57610117565b8063350c377b116100ba578063350c377b146101c75780633adfbf55146101ef578063425e774e1461022c57806343c2caf81461025457610117565b8063126082cf146101495780631f922e5f1461017357806322dcd13e1461019d57610117565b36610117576040517f3733483400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517f3733483400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b348015610154575f80fd5b5061015d61038a565b60405161016a9190611322565b60405180910390f35b34801561017e575f80fd5b50610187610390565b6040516101949190611322565b60405180910390f35b3480156101a8575f80fd5b506101b1610398565b6040516101be9190611361565b60405180910390f35b3480156101d2575f80fd5b506101ed60048036038101906101e891906113dc565b6103b6565b005b3480156101fa575f80fd5b5061021560048036038101906102109190611431565b6105db565b604051610223929190611476565b60405180910390f35b348015610237575f80fd5b50610252600480360381019061024d91906114c7565b610607565b005b34801561025f575f80fd5b5061027a600480360381019061027591906115a8565b6107c3565b005b348015610287575f80fd5b50610290610aed565b60405161029d91906116b3565b60405180910390f35b3480156102b1575f80fd5b506102ba610b11565b005b3480156102c7575f80fd5b506102d0610b98565b6040516102dd9190611322565b60405180910390f35b3480156102f1575f80fd5b506102fa610b9e565b60405161030791906116db565b60405180910390f35b34801561031b575f80fd5b50610336600480360381019061033191906116f4565b610bc5565b005b348015610343575f80fd5b5061034c610da4565b60405161035991906116db565b60405180910390f35b34801561036d575f80fd5b50610388600480360381019061038391906113dc565b610dc9565b005b61271081565b633b9aca0081565b600260149054906101000a90046bffffffffffffffffffffffff1681565b6103be610ebf565b73ffffffffffffffffffffffffffffffffffffffff166103dc610b9e565b73ffffffffffffffffffffffffffffffffffffffff1614610432576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016104299061178c565b60405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff165f73ffffffffffffffffffffffffffffffffffffffff1603610497576040517fd92e233d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff1660025f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff160361051d576040517f4559ff5c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff1660025f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167faf04973bb8004e313cfd09017b963bee1e6f6ffb9be88c07a0c5ce5fafe9340360405160405180910390a38060025f6101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6001602052805f5260405f205f91509050805f015490806001015f9054906101000a900460ff16905082565b61060f610ebf565b73ffffffffffffffffffffffffffffffffffffffff1661062d610b9e565b73ffffffffffffffffffffffffffffffffffffffff1614610683576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161067a9061178c565b60405180910390fd5b806bffffffffffffffffffffffff16600260149054906101000a90046bffffffffffffffffffffffff166bffffffffffffffffffffffff16036106f2576040517f4559ff5c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6107d0816bffffffffffffffffffffffff16111561073c576040517fedfe957200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7ffeeddf72b7ee4210b769104cb8b071e5706232ac7f671fb292af429ffd58b587600260149054906101000a90046bffffffffffffffffffffffff16826040516107879291906117aa565b60405180910390a180600260146101000a8154816bffffffffffffffffffffffff02191690836bffffffffffffffffffffffff16021790555050565b6107cb610ebf565b73ffffffffffffffffffffffffffffffffffffffff166107e9610b9e565b73ffffffffffffffffffffffffffffffffffffffff161461083f576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016108369061178c565b60405180910390fd5b5f868690509050848490508114158061085b5750828290508114155b15610892576040517fa24a13a600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f5b81811015610ae3575f8888838181106108b0576108af6117d1565b5b9050602002013590505f8787848181106108cd576108cc6117d1565b5b90506020020160208101906108e291906113dc565b90505f8686858181106108f8576108f76117d1565b5b9050602002013590505f810361093a576040517faf458c0700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8173ffffffffffffffffffffffffffffffffffffffff165f73ffffffffffffffffffffffffffffffffffffffff160361099f576040517fd92e233d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60015f8481526020019081526020015f206001015f9054906101000a900460ff16156109f7576040517fd70a0e3000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001805f8581526020019081526020015f206001015f6101000a81548160ff021916908315150217905550610a6d82827f000000000000000000000000ff284f2e8cce4cd2f4537d8a9369482b545908fb73ffffffffffffffffffffffffffffffffffffffff16610ec69092919063ffffffff16565b828273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fd9532dc0677ec40b928c21e329e8c129a41c4a79aa449e68063ba9a7b5fef72484604051610acb9190611322565b60405180910390a45050508080600101915050610894565b5050505050505050565b7f000000000000000000000000ff284f2e8cce4cd2f4537d8a9369482b545908fb81565b610b19610ebf565b73ffffffffffffffffffffffffffffffffffffffff16610b37610b9e565b73ffffffffffffffffffffffffffffffffffffffff1614610b8d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b849061178c565b60405180910390fd5b610b965f610f4c565b565b6107d081565b5f805f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b633b9aca00811015610c0e57806040517f83c22e8d000000000000000000000000000000000000000000000000000000008152600401610c059190611322565b60405180910390fd5b5f612710600260149054906101000a90046bffffffffffffffffffffffff166bffffffffffffffffffffffff1683610c46919061182b565b610c509190611899565b90505f8183610c5f91906118c9565b90508060015f8681526020019081526020015f205f015f828254610c8391906118fc565b92505081905550610cd73330857f000000000000000000000000ff284f2e8cce4cd2f4537d8a9369482b545908fb73ffffffffffffffffffffffffffffffffffffffff1661100d909392919063ffffffff16565b5f821115610d4c57610d4b60025f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff16837f000000000000000000000000ff284f2e8cce4cd2f4537d8a9369482b545908fb73ffffffffffffffffffffffffffffffffffffffff16610ec69092919063ffffffff16565b5b82843373ffffffffffffffffffffffffffffffffffffffff167ff2c7c61aab9019a0417876fee95ea2ce79b2da32f8f2b41271429475b2cf4c238486604051610d9692919061192f565b60405180910390a450505050565b60025f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b610dd1610ebf565b73ffffffffffffffffffffffffffffffffffffffff16610def610b9e565b73ffffffffffffffffffffffffffffffffffffffff1614610e45576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e3c9061178c565b60405180910390fd5b5f73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1603610eb3576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610eaa906119c6565b60405180910390fd5b610ebc81610f4c565b50565b5f33905090565b610f478363a9059cbb60e01b8484604051602401610ee59291906119e4565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050611096565b505050565b5f805f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050815f806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b611090846323b872dd60e01b85858560405160240161102e93929190611a0b565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050611096565b50505050565b5f6110f7826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff1661115b9092919063ffffffff16565b90505f8151111561115657808060200190518101906111169190611a6a565b611155576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161114c90611b05565b60405180910390fd5b5b505050565b606061116984845f85611172565b90509392505050565b6060824710156111b7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016111ae90611b93565b60405180910390fd5b6111c085611282565b6111ff576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016111f690611bfb565b60405180910390fd5b5f808673ffffffffffffffffffffffffffffffffffffffff1685876040516112279190611c85565b5f6040518083038185875af1925050503d805f8114611261576040519150601f19603f3d011682016040523d82523d5f602084013e611266565b606091505b50915091506112768282866112a4565b92505050949350505050565b5f808273ffffffffffffffffffffffffffffffffffffffff163b119050919050565b606083156112b457829050611303565b5f835111156112c65782518084602001fd5b816040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016112fa9190611ced565b60405180910390fd5b9392505050565b5f819050919050565b61131c8161130a565b82525050565b5f6020820190506113355f830184611313565b92915050565b5f6bffffffffffffffffffffffff82169050919050565b61135b8161133b565b82525050565b5f6020820190506113745f830184611352565b92915050565b5f80fd5b5f80fd5b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f6113ab82611382565b9050919050565b6113bb816113a1565b81146113c5575f80fd5b50565b5f813590506113d6816113b2565b92915050565b5f602082840312156113f1576113f061137a565b5b5f6113fe848285016113c8565b91505092915050565b6114108161130a565b811461141a575f80fd5b50565b5f8135905061142b81611407565b92915050565b5f602082840312156114465761144561137a565b5b5f6114538482850161141d565b91505092915050565b5f8115159050919050565b6114708161145c565b82525050565b5f6040820190506114895f830185611313565b6114966020830184611467565b9392505050565b6114a68161133b565b81146114b0575f80fd5b50565b5f813590506114c18161149d565b92915050565b5f602082840312156114dc576114db61137a565b5b5f6114e9848285016114b3565b91505092915050565b5f80fd5b5f80fd5b5f80fd5b5f8083601f840112611513576115126114f2565b5b8235905067ffffffffffffffff8111156115305761152f6114f6565b5b60208301915083602082028301111561154c5761154b6114fa565b5b9250929050565b5f8083601f840112611568576115676114f2565b5b8235905067ffffffffffffffff811115611585576115846114f6565b5b6020830191508360208202830111156115a1576115a06114fa565b5b9250929050565b5f805f805f80606087890312156115c2576115c161137a565b5b5f87013567ffffffffffffffff8111156115df576115de61137e565b5b6115eb89828a016114fe565b9650965050602087013567ffffffffffffffff81111561160e5761160d61137e565b5b61161a89828a01611553565b9450945050604087013567ffffffffffffffff81111561163d5761163c61137e565b5b61164989828a016114fe565b92509250509295509295509295565b5f819050919050565b5f61167b61167661167184611382565b611658565b611382565b9050919050565b5f61168c82611661565b9050919050565b5f61169d82611682565b9050919050565b6116ad81611693565b82525050565b5f6020820190506116c65f8301846116a4565b92915050565b6116d5816113a1565b82525050565b5f6020820190506116ee5f8301846116cc565b92915050565b5f806040838503121561170a5761170961137a565b5b5f6117178582860161141d565b92505060206117288582860161141d565b9150509250929050565b5f82825260208201905092915050565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65725f82015250565b5f611776602083611732565b915061178182611742565b602082019050919050565b5f6020820190508181035f8301526117a38161176a565b9050919050565b5f6040820190506117bd5f830185611352565b6117ca6020830184611352565b9392505050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52603260045260245ffd5b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b5f6118358261130a565b91506118408361130a565b925082820261184e8161130a565b91508282048414831517611865576118646117fe565b5b5092915050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601260045260245ffd5b5f6118a38261130a565b91506118ae8361130a565b9250826118be576118bd61186c565b5b828204905092915050565b5f6118d38261130a565b91506118de8361130a565b92508282039050818111156118f6576118f56117fe565b5b92915050565b5f6119068261130a565b91506119118361130a565b9250828201905080821115611929576119286117fe565b5b92915050565b5f6040820190506119425f830185611313565b61194f6020830184611313565b9392505050565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f20615f8201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b5f6119b0602683611732565b91506119bb82611956565b604082019050919050565b5f6020820190508181035f8301526119dd816119a4565b9050919050565b5f6040820190506119f75f8301856116cc565b611a046020830184611313565b9392505050565b5f606082019050611a1e5f8301866116cc565b611a2b60208301856116cc565b611a386040830184611313565b949350505050565b611a498161145c565b8114611a53575f80fd5b50565b5f81519050611a6481611a40565b92915050565b5f60208284031215611a7f57611a7e61137a565b5b5f611a8c84828501611a56565b91505092915050565b7f5361666545524332303a204552433230206f7065726174696f6e20646964206e5f8201527f6f74207375636365656400000000000000000000000000000000000000000000602082015250565b5f611aef602a83611732565b9150611afa82611a95565b604082019050919050565b5f6020820190508181035f830152611b1c81611ae3565b9050919050565b7f416464726573733a20696e73756666696369656e742062616c616e636520666f5f8201527f722063616c6c0000000000000000000000000000000000000000000000000000602082015250565b5f611b7d602683611732565b9150611b8882611b23565b604082019050919050565b5f6020820190508181035f830152611baa81611b71565b9050919050565b7f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000005f82015250565b5f611be5601d83611732565b9150611bf082611bb1565b602082019050919050565b5f6020820190508181035f830152611c1281611bd9565b9050919050565b5f81519050919050565b5f81905092915050565b5f5b83811015611c4a578082015181840152602081019050611c2f565b5f8484015250505050565b5f611c5f82611c19565b611c698185611c23565b9350611c79818560208601611c2d565b80840191505092915050565b5f611c908284611c55565b915081905092915050565b5f81519050919050565b5f601f19601f8301169050919050565b5f611cbf82611c9b565b611cc98185611732565b9350611cd9818560208601611c2d565b611ce281611ca5565b840191505092915050565b5f6020820190508181035f830152611d058184611cb5565b90509291505056fea2646970667358221220928904c47ee7a36d0df31f0cfd6b497a4cd13a30432d956dd76237a5d96844d864736f6c63430008180033
Verified Source Code Full Match
Compiler: v0.8.24+commit.e11b9ed9
EVM: shanghai
Optimization: No
NodelyAIPaymentGateway.sol 807 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @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;
}
}
pragma solidity ^0.8.0;
/**
* @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.
*
* By default, the owner account will be the one that deploys the contract. 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;
event OwnershipTransferred(
address indexed previousOwner,
address indexed newOwner
);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor() {
_transferOwnership(_msgSender());
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing 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 {
require(
newOwner != address(0),
"Ownable: new owner is the zero address"
);
_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);
}
}
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(
address indexed owner,
address indexed spender,
uint256 value
);
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(
address owner,
address spender
) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `from` to `to` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address from,
address to,
uint256 amount
) external returns (bool);
}
// OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol)
pragma solidity ^0.8.1;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*
* [IMPORTANT]
* ====
* You shouldn't rely on `isContract` to protect against flash loan attacks!
*
* Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
* like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
* constructor.
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize/address.code.length, which returns 0
// for contracts in construction, since the code is only stored at the end
// of the constructor execution.
return account.code.length > 0;
}
/**
* @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://diligence.consensys.net/posts/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.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(
address(this).balance >= amount,
"Address: insufficient balance"
);
(bool success, ) = recipient.call{value: amount}("");
require(
success,
"Address: unable to send value, recipient may have reverted"
);
}
/**
* @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, it is bubbled up by this
* function (like regular Solidity function calls).
*
* 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.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data
) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @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`.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value
) internal returns (bytes memory) {
return
functionCallWithValue(
target,
data,
value,
"Address: low-level call with value failed"
);
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(
address(this).balance >= value,
"Address: insufficient balance for call"
);
require(isContract(target), "Address: call to non-contract");
(bool success, bytes memory returndata) = target.call{value: value}(
data
);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data
) internal view returns (bytes memory) {
return
functionStaticCall(
target,
data,
"Address: low-level static call failed"
);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(
address target,
bytes memory data
) internal returns (bytes memory) {
return
functionDelegateCall(
target,
data,
"Address: low-level delegate call failed"
);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
require(isContract(target), "Address: delegate call to non-contract");
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
// 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 {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
// OpenZeppelin Contracts v4.4.1 (token/ERC20/utils/SafeERC20.sol)
pragma solidity ^0.8.0;
/**
* @title SafeERC20
* @dev Wrappers around ERC20 operations that throw on failure (when the token
* contract returns false). Tokens that return no value (and instead revert or
* throw on failure) are also supported, non-reverting calls are assumed to be
* successful.
* To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
library SafeERC20 {
using Address for address;
function safeTransfer(IERC20 token, address to, uint256 value) internal {
_callOptionalReturn(
token,
abi.encodeWithSelector(token.transfer.selector, to, value)
);
}
function safeTransferFrom(
IERC20 token,
address from,
address to,
uint256 value
) internal {
_callOptionalReturn(
token,
abi.encodeWithSelector(token.transferFrom.selector, from, to, value)
);
}
/**
* @dev Deprecated. This function has issues similar to the ones found in
* {IERC20-approve}, and its usage is discouraged.
*
* Whenever possible, use {safeIncreaseAllowance} and
* {safeDecreaseAllowance} instead.
*/
function safeApprove(
IERC20 token,
address spender,
uint256 value
) internal {
// safeApprove should only be called when setting an initial allowance,
// or when resetting it to zero. To increase and decrease it, use
// 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
require(
(value == 0) || (token.allowance(address(this), spender) == 0),
"SafeERC20: approve from non-zero to non-zero allowance"
);
_callOptionalReturn(
token,
abi.encodeWithSelector(token.approve.selector, spender, value)
);
}
function safeIncreaseAllowance(
IERC20 token,
address spender,
uint256 value
) internal {
uint256 newAllowance = token.allowance(address(this), spender) + value;
_callOptionalReturn(
token,
abi.encodeWithSelector(
token.approve.selector,
spender,
newAllowance
)
);
}
function safeDecreaseAllowance(
IERC20 token,
address spender,
uint256 value
) internal {
unchecked {
uint256 oldAllowance = token.allowance(address(this), spender);
require(
oldAllowance >= value,
"SafeERC20: decreased allowance below zero"
);
uint256 newAllowance = oldAllowance - value;
_callOptionalReturn(
token,
abi.encodeWithSelector(
token.approve.selector,
spender,
newAllowance
)
);
}
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*/
function _callOptionalReturn(IERC20 token, bytes memory data) private {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that
// the target address contains contract code and also asserts for success in the low-level call.
bytes memory returndata = address(token).functionCall(
data,
"SafeERC20: low-level call failed"
);
if (returndata.length > 0) {
// Return data is optional
require(
abi.decode(returndata, (bool)),
"SafeERC20: ERC20 operation did not succeed"
);
}
}
}
pragma solidity 0.8.24;
// Definition of custom errors
error AlreadyPaid();
error ArrayLengthMismatch();
error AmountBelowMinimum(uint256 amount);
error EtherNotAccepted();
error SameValueError();
error ExceedsMaxFeePercentage();
error ZeroAddress();
error ZeroInput();
/// @title NodelyAI Payment Gateway
/// @notice This contract facilitates payments in NodelyAI tokens for GPU rentals.
contract NodelyAIPaymentGateway is Ownable {
using SafeERC20 for IERC20;
// Address of the NodelyAI token
IERC20 public immutable nodeToken;
// Struct to track order balance and payment status.
/// @dev `netAmount` only increases when a user pays and is not adjusted when the admin pays the gpu owner.
struct OrderBalance {
uint256 netAmount; // Net amount paid by the user after deducting fees.
bool isPaid; // Indicates whether the admin has paid the GPU owner.
}
// Mapping to track the balance and payment status for each order ID.
mapping(uint256 => OrderBalance) public orderBalances;
// Address where platform fees are sent
address public platformFeeRecipient;
// Current platform fee percentage (in basis points, where 10000 = 100%)
uint96 public platformFeeBps;
// Maximum platform fee percentage (in basis points) that can be set by the admin
uint256 public constant MAX_PLATFORM_FEE_BPS = 2000; // 20%
// Precision used for percentage calculations (10000 = 100%)
uint256 public constant BASIS_POINTS_DIVISOR = 10_000;
// Minimum payment amount is 1 (1e9) NodelyAI token
uint256 public constant MIN_PAYMENT_AMOUNT = 1e9; // 1 NodelyAI token = 1e9
// Event emitted when the platform fee recipient is updated
event PlatformFeeRecipientUpdated(
address indexed oldRecipient,
address indexed newRecipient
);
// Event emitted when the platform fee percentage is updated
event PlatformFeeUpdated(uint96 oldFeeBps, uint96 newFeeBps);
// Event emitted when a payment is successfully processed
event PaymentProcessed(
address indexed payer,
uint256 indexed orderId,
uint256 indexed totalAmount,
uint256 netAmount,
uint256 feeAmount
);
// Event emitted when payment is released to the GPU owner.
event PaymentReleased(
address indexed contractOwner,
address indexed gpuOwner,
uint256 indexed orderId,
uint256 tokensPaid
);
/**
* @notice Initializes the contract with the necessary parameters.
* @dev Ensures the `_nodeToken` and `_platformFeeRecipient` are valid addresses.
* @param _nodeToken The address of the NODE token used for transactions.
* @param _platformFeeRecipient The address that will receive platform fees.
* @param _platformFeeBps The platform fee percentage in basis points (1 BPS = 0.01%).
*/
constructor(
IERC20 _nodeToken,
address _platformFeeRecipient,
uint96 _platformFeeBps
) {
// Check if the `_nodeToken` or `_platformFeeRecipient` is the zero address
if (
address(_nodeToken) == address(0) ||
_platformFeeRecipient == address(0)
) revert ZeroAddress(); // Revert if any address is a zero address
nodeToken = _nodeToken;
// Set the platform fee recipient
platformFeeRecipient = _platformFeeRecipient;
// Set the platform fee in basis points, if greater than 0
if (_platformFeeBps > 0) {
platformFeeBps = _platformFeeBps;
}
emit PlatformFeeRecipientUpdated(address(0), _platformFeeRecipient);
emit PlatformFeeUpdated(0, _platformFeeBps);
}
receive() external payable {
revert EtherNotAccepted(); // Revert if Ether is sent
}
fallback() external payable {
revert EtherNotAccepted(); // Revert if Ether is sent
}
/**
* @notice Changes the platform fee recipient address.
* @param _newPlatformFeeRecipient The address of the new fee recipient.
* @dev Only callable by the contract owner.
*/
function changePlatformFeeRecipient(
address _newPlatformFeeRecipient
) external onlyOwner {
// Ensure the new fee recipient address is not the zero address
if (address(0) == _newPlatformFeeRecipient) revert ZeroAddress();
// Ensure the new address is not the same as the current fee recipient
if (platformFeeRecipient == _newPlatformFeeRecipient)
revert SameValueError();
emit PlatformFeeRecipientUpdated(
platformFeeRecipient,
_newPlatformFeeRecipient
);
// Update the platform fee recipient address
platformFeeRecipient = _newPlatformFeeRecipient;
}
/**
* @notice Changes the platform fee percentage.
* @param _newPlatformFeeBps The new fee percentage in basis points (1 BPS = 0.01%).
* @dev Only callable by the contract owner.
*/
function changeFeePercentage(uint96 _newPlatformFeeBps) external onlyOwner {
// Ensure the new fee percentage is not the same as the current one
if (platformFeeBps == _newPlatformFeeBps) revert SameValueError();
// Ensure the new fee percentage does not exceed the maximum allowed fee percentage
if (_newPlatformFeeBps > MAX_PLATFORM_FEE_BPS)
revert ExceedsMaxFeePercentage();
emit PlatformFeeUpdated(platformFeeBps, _newPlatformFeeBps);
// Update the platform fee percentage
platformFeeBps = _newPlatformFeeBps;
}
/**
* @notice Processes the payment by transferring tokens, deducting the platform's fee, and updating the order balance.
* @param _orderId The order ID associated with the payment.
* @param _tokenAmount The total number of tokens being paid.
*/
function processPayment(uint256 _orderId, uint256 _tokenAmount) external {
// Ensures that the token amount is not less than the minimum required payment
if (_tokenAmount < MIN_PAYMENT_AMOUNT) {
revert AmountBelowMinimum(_tokenAmount); // Revert if _tokenAmount is less than 1 Nodely AI token
}
// Calculate the platform fee based on the provided fee percentage
uint256 _platformFee = (_tokenAmount * platformFeeBps) /
BASIS_POINTS_DIVISOR;
// Calculate the net amount after deducting the platform fee
uint256 _netAmount = _tokenAmount - _platformFee;
// Update the amount paid for the given ID, subtracting platform fee
orderBalances[_orderId].netAmount += _netAmount;
// Transfer the tokens from the sender to the contract
nodeToken.safeTransferFrom(msg.sender, address(this), _tokenAmount);
// Transfer the platform fee to the fee recipient, if it is greater than 0
if (_platformFee > 0) {
nodeToken.safeTransfer(platformFeeRecipient, _platformFee);
}
emit PaymentProcessed(
msg.sender,
_orderId,
_tokenAmount,
_netAmount,
_platformFee
);
}
/**
* @notice Releases payment to the GPU owner for a specific order.
* @param _orderIds The array of unique order IDs.
* @param _gpuOwners The array of GPU owners' addresses receiving the payments.
* @param _totalAmounts The array of total amounts of tokens to be paid to the GPU owners.
* @dev Only callable by the contract owner.
*/
function releasePayment(
uint256[] calldata _orderIds,
address[] calldata _gpuOwners,
uint256[] calldata _totalAmounts
) external onlyOwner {
// Ensure arrays are of the same length
uint256 length = _orderIds.length;
if (length != _gpuOwners.length || length != _totalAmounts.length) {
revert ArrayLengthMismatch();
}
// Iterate over each order and process payments
for (uint256 i = 0; i < length; i++) {
uint256 _orderId = _orderIds[i];
address _gpuOwner = _gpuOwners[i];
uint256 _totalAmount = _totalAmounts[i];
// Ensure the total amount is greater than zero
if (_totalAmount == 0) revert ZeroInput();
// Ensure GPU owner address is not the zero address
if (address(0) == _gpuOwner) revert ZeroAddress();
// Check if the payment has already been released for this order
if (orderBalances[_orderId].isPaid) revert AlreadyPaid();
// Mark the order as paid
orderBalances[_orderId].isPaid = true;
// Transfer tokens to the GPU owner
nodeToken.safeTransfer(_gpuOwner, _totalAmount);
emit PaymentReleased(msg.sender, _gpuOwner, _orderId, _totalAmount);
}
}
}
Read Contract
BASIS_POINTS_DIVISOR 0x126082cf → uint256
MAX_PLATFORM_FEE_BPS 0x8d01513c → uint256
MIN_PAYMENT_AMOUNT 0x1f922e5f → uint256
nodeToken 0x664983c8 → address
orderBalances 0x3adfbf55 → uint256, bool
owner 0x8da5cb5b → address
platformFeeBps 0x22dcd13e → uint96
platformFeeRecipient 0xeb13554f → address
Write Contract 6 functions
These functions modify contract state and require a wallet transaction to execute.
changeFeePercentage 0x425e774e
uint96 _newPlatformFeeBps
changePlatformFeeRecipient 0x350c377b
address _newPlatformFeeRecipient
processPayment 0xdf9d58ff
uint256 _orderId
uint256 _tokenAmount
releasePayment 0x43c2caf8
uint256[] _orderIds
address[] _gpuOwners
uint256[] _totalAmounts
renounceOwnership 0x715018a6
No parameters
transferOwnership 0xf2fde38b
address newOwner
Recent Transactions
No transactions found for this address