Address Contract Partially Verified
Address
0xef4c77c2898D9F0229BFd0890F77e0DC56e9948c
Balance
0 ETH
Nonce
1
Code Size
2295 bytes
Creator
0x79b8d5c4...C9Ff at tx 0x8a57780c...d6ccb6
Indexed Transactions
0
Contract Bytecode
2295 bytes
0x60806040526004361061007e5760003560e01c80633ba0b9a91161004e5780633ba0b9a91461011e5780638da5cb5b14610142578063b14b993314610162578063db068e0e1461018257600080fd5b8062ae3bf81461008a5780630fed3e1c146100ac57806320969d07146100e95780632cb77547146100fe57600080fd5b3661008557005b600080fd5b34801561009657600080fd5b506100aa6100a5366004610812565b6101a2565b005b3480156100b857600080fd5b506001546100cc906001600160a01b031681565b6040516001600160a01b0390911681526020015b60405180910390f35b3480156100f557600080fd5b506100aa61033f565b34801561010a57600080fd5b506002546100cc906001600160a01b031681565b34801561012a57600080fd5b5061013460035481565b6040519081526020016100e0565b34801561014e57600080fd5b506004546100cc906001600160a01b031681565b34801561016e57600080fd5b506100aa61017d366004610842565b610425565b34801561018e57600080fd5b506100aa61019d366004610842565b61075a565b6004546001600160a01b031633146102015760405162461bcd60e51b815260206004820152601760248201527f43616c6c6572206973206e6f7420746865206f776e657200000000000000000060448201526064015b60405180910390fd5b6040516370a0823160e01b815230600482015281906000906001600160a01b038316906370a0823190602401602060405180830381865afa15801561024a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061026e919061085b565b9050600081116102c05760405162461bcd60e51b815260206004820152601360248201527f4e6f20746f6b656e7320746f207265736375650000000000000000000000000060448201526064016101f8565b6004805460405163a9059cbb60e01b81526001600160a01b03918216928101929092526024820183905283169063a9059cbb906044016020604051808303816000875af1158015610315573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103399190610874565b50505050565b6004546001600160a01b031633146103995760405162461bcd60e51b815260206004820152601760248201527f43616c6c6572206973206e6f7420746865206f776e657200000000000000000060448201526064016101f8565b47806103e75760405162461bcd60e51b815260206004820152601260248201527f4e6f20457468657220746f20726573637565000000000000000000000000000060448201526064016101f8565b6004546040516001600160a01b039091169082156108fc029083906000818181858888f19350505050158015610421573d6000803e3d6000fd5b5050565b61042d6107b9565b600061043d82633b9aca00610896565b600154604051636eb1769f60e11b815233600482015230602482015291925082916001600160a01b039091169063dd62ed3e90604401602060405180830381865afa158015610490573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104b4919061085b565b10156105285760405162461bcd60e51b815260206004820152602560248201527f436f6e7472616374206e6565647320616c6c6f77616e636520746f206275726e60448201527f206d47454d00000000000000000000000000000000000000000000000000000060648201526084016101f8565b6003546105359082610896565b6002546040516370a0823160e01b81523060048201526001600160a01b03909116906370a0823190602401602060405180830381865afa15801561057d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105a1919061085b565b10156106155760405162461bcd60e51b815260206004820152602760248201527f496e73756666696369656e74204d616e646f782062616c616e636520696e206360448201527f6f6e74726163740000000000000000000000000000000000000000000000000060648201526084016101f8565b60015460405163079cc67960e41b8152336004820152602481018390526001600160a01b03909116906379cc679090604401600060405180830381600087803b15801561066157600080fd5b505af1158015610675573d6000803e3d6000fd5b505050506000600354826106899190610896565b60025460405163a9059cbb60e01b8152336004820152602481018390529192506001600160a01b03169063a9059cbb906044016020604051808303816000875af11580156106db573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106ff9190610874565b61074b5760405162461bcd60e51b815260206004820152601960248201527f5472616e73666572206f66204d616e646f78206661696c65640000000000000060448201526064016101f8565b50506107576001600055565b50565b6004546001600160a01b031633146107b45760405162461bcd60e51b815260206004820152601760248201527f43616c6c6572206973206e6f7420746865206f776e657200000000000000000060448201526064016101f8565b600355565b60026000540361080b5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016101f8565b6002600055565b60006020828403121561082457600080fd5b81356001600160a01b038116811461083b57600080fd5b9392505050565b60006020828403121561085457600080fd5b5035919050565b60006020828403121561086d57600080fd5b5051919050565b60006020828403121561088657600080fd5b8151801515811461083b57600080fd5b80820281158282048414176108bb57634e487b7160e01b600052601160045260246000fd5b9291505056fea26469706673582212204b766f50e221bc0bae7e3cf723fc1b2e34ac58748aaf476fcab00e5050beffa464736f6c63430008120033
Verified Source Code Partial Match
Compiler: v0.8.18+commit.87f61d96
EVM: paris
Optimization: Yes (800 runs)
GemSwaps.sol 158 lines
// File: @openzeppelin/contracts/security/ReentrancyGuard.sol
// OpenZeppelin Contracts (last updated v4.9.0) (security/ReentrancyGuard.sol)
pragma solidity ^0.8.0;
/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
* available, which can be applied to functions to make sure there are no nested
* (reentrant) calls to them.
*
* Note that because there is a single `nonReentrant` guard, functions marked as
* `nonReentrant` may not call one another. This can be worked around by making
* those functions `private`, and then adding `external` `nonReentrant` entry
* points to them.
*
* TIP: If you would like to learn more about reentrancy and alternative ways
* to protect against it, check out our blog post
* https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
*/
abstract contract ReentrancyGuard {
// Booleans are more expensive than uint256 or any type that takes up a full
// word because each write operation emits an extra SLOAD to first read the
// slot's contents, replace the bits taken up by the boolean, and then write
// back. This is the compiler's defense against contract upgrades and
// pointer aliasing, and it cannot be disabled.
// The values being non-zero value makes deployment a bit more expensive,
// but in exchange the refund on every call to nonReentrant will be lower in
// amount. Since refunds are capped to a percentage of the total
// transaction's gas, it is best to keep them low in cases like this one, to
// increase the likelihood of the full refund coming into effect.
uint256 private constant _NOT_ENTERED = 1;
uint256 private constant _ENTERED = 2;
uint256 private _status;
constructor() {
_status = _NOT_ENTERED;
}
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant`
* function is not supported. It is possible to prevent this from happening
* by making the `nonReentrant` function external, and making it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
_nonReentrantBefore();
_;
_nonReentrantAfter();
}
function _nonReentrantBefore() private {
// On the first call to nonReentrant, _status will be _NOT_ENTERED
require(_status != _ENTERED, "ReentrancyGuard: reentrant call");
// Any calls to nonReentrant after this point will fail
_status = _ENTERED;
}
function _nonReentrantAfter() private {
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
_status = _NOT_ENTERED;
}
/**
* @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a
* `nonReentrant` function in the call stack.
*/
function _reentrancyGuardEntered() internal view returns (bool) {
return _status == _ENTERED;
}
}
// File: swappingGem.sol
pragma solidity ^0.8.0;
interface IERC20 {
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
function transfer(address recipient, uint256 amount) external returns (bool);
function balanceOf(address account) external view returns (uint256);
function allowance(address owner, address spender) external view returns (uint256);
function approve(address spender, uint256 amount) external returns (bool);
}
interface IERC20Burnable {
function burnFrom(address account, uint256 amount) external;
}
contract GemSwaps is ReentrancyGuard {
IERC20 public mGem;
IERC20 public Mandox;
uint256 public exchangeRate;
address public owner;
constructor(address _mGem, address _Mandox, uint256 _exchangeRate) {
mGem = IERC20(_mGem);
Mandox = IERC20(_Mandox);
exchangeRate = _exchangeRate;
owner = msg.sender;
}
modifier onlyOwner() {
require(msg.sender == owner, "Caller is not the owner");
_;
}
function setExchangeRate(uint256 _newRate) external onlyOwner {
exchangeRate = _newRate;
}
function exchangemGemForMandox(uint256 _amountOfmGem) external nonReentrant {
// Convert the amount from whole tokens to the smallest unit
uint256 mGemAmount = _amountOfmGem * 10**9;
require(mGem.allowance(msg.sender, address(this)) >= mGemAmount, "Contract needs allowance to burn mGEM");
require(Mandox.balanceOf(address(this)) >= mGemAmount * exchangeRate, "Insufficient Mandox balance in contract");
// Burn mGem
IERC20Burnable(address(mGem)).burnFrom(msg.sender, mGemAmount);
// Calculate the Mandox transfer amount
uint256 mandoxTransferAmount = mGemAmount * exchangeRate;
// Transfer Mandox to the user
require(Mandox.transfer(msg.sender, mandoxTransferAmount), "Transfer of Mandox failed");
}
// Function to withdraw ERC-20 tokens
function rescueTokens(address _tokenAddr) external onlyOwner {
IERC20 token = IERC20(_tokenAddr);
uint256 tokenBalance = token.balanceOf(address(this));
require(tokenBalance > 0, "No tokens to rescue");
token.transfer(owner, tokenBalance);
}
// Function to withdraw Ether
function rescueEther() external onlyOwner {
uint256 etherBalance = address(this).balance;
require(etherBalance > 0, "No Ether to rescue");
payable(owner).transfer(etherBalance);
}
// Fallback function
receive() external payable {}
}
Read Contract
Mandox 0x2cb77547 → address
exchangeRate 0x3ba0b9a9 → uint256
mGem 0x0fed3e1c → address
owner 0x8da5cb5b → address
Write Contract 4 functions
These functions modify contract state and require a wallet transaction to execute.
exchangemGemForMandox 0xb14b9933
uint256 _amountOfmGem
rescueEther 0x20969d07
No parameters
rescueTokens 0x00ae3bf8
address _tokenAddr
setExchangeRate 0xdb068e0e
uint256 _newRate
Recent Transactions
No transactions found for this address