Source Code
Overview
ETH Balance
0 ETH
Token Holdings
More Info
ContractCreator
Multi Chain
Multichain Addresses
N/ALatest 1 from a total of 1 transactions
Transaction Hash |
Method
|
Block
|
From
|
To
|
Value | ||||
---|---|---|---|---|---|---|---|---|---|
0x60806040 | 7247707 | 508 days 7 hrs ago | IN | Contract Creation | 0 ETH | 0.00106171 |
Latest 10 internal transactions
Advanced mode:
Parent Txn Hash | Block | From | To | Value | ||
---|---|---|---|---|---|---|
7249081 | 508 days 1 hr ago | 0 ETH | ||||
7249081 | 508 days 1 hr ago | 0 ETH | ||||
7249081 | 508 days 1 hr ago | 0 ETH | ||||
7249068 | 508 days 1 hr ago | 0 ETH | ||||
7249068 | 508 days 1 hr ago | 0 ETH | ||||
7249068 | 508 days 1 hr ago | 0 ETH | ||||
7248864 | 508 days 2 hrs ago | 0 ETH | ||||
7248427 | 508 days 4 hrs ago | 0 ETH | ||||
7248117 | 508 days 5 hrs ago | 0 ETH | ||||
7248039 | 508 days 6 hrs ago | 0 ETH |
Loading...
Loading
Similar Match Source Code This contract matches the deployed Bytecode of the Source Code for Contract 0x94F80d...c61f746C The constructor portion of the code might be different and could alter the actual behaviour of the contract
Contract Name:
CarFactory
Compiler Version
v0.8.1+commit.df193b15
Optimization Enabled:
No with 200 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.7.0 <0.9.0; import "./interfaces/ICarMarket.sol"; import "./interfaces/ICarToken.sol"; /** * @title CarFactory * @author Jelo * @notice This is a contract that handles crucial changes in the car company. * It also gives out flashloans to existing customers of the car company. */ contract CarFactory { // -- States -- address private _owner; address private carFactory; ICarToken private carToken; ICarMarket public carMarket; /** * @notice Sets the car Market and car token during deployment. * @param _carMarket The exchange where car trades take place. * @param _carToken The token used to purchase cars. */ constructor(address _carMarket, address _carToken) { carToken = ICarToken(_carToken); carMarket = ICarMarket(_carMarket); } /** * @notice Gives out flashLoan to an existing customer. * @param _amount The amount to be borrowed. */ function flashLoan(uint256 _amount) external { //checks if the address has purchased a car previously. require(carMarket.isExistingCustomer(msg.sender), "Not existing customer"); //fetches the balance of the carFactory before loaning out. uint balanceBefore = carToken.balanceOf(carFactory); //check if there is enough amount in the contract to borrow. require(balanceBefore >= _amount, "Amount not available"); //transfers the amount to be borrowed to the borrower carToken.transfer(msg.sender, _amount); (bool success, ) = msg.sender.call(abi.encodeWithSignature("receivedCarToken(address)", address(this))); require(success, "Call to target failed"); //fetches the balance of the carFactory after loaning out. uint balanceAfter = carToken.balanceOf(carFactory); //ensures that the Loan has been paid require(balanceAfter >= balanceBefore, "Loan not paid in full"); } /** * @dev Returns the car market */ function getCarMarket() external view returns(ICarMarket){ return carMarket; } /** * @dev Returns the car token */ function getCarToken() external view returns(ICarToken){ return carToken; } }
// SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.7.0 <0.9.0; /** * @title CarMarket Interface * @author Jelo * @notice Contains the functions required to purchase a car and withdraw funds from the contract. */ interface ICarMarket { /** * @dev Enables a user to purchase a car * @param _color The color of the car to be purchased * @param _model The model of the car to be purchased * @param _plateNumber The plateNumber of the car to be purchased */ function purchaseCar(string memory _color, string memory _model, string memory _plateNumber) external payable; /** * @dev Enables the owner of the contract to withdraw funds gotten from the purcahse of a car. */ function withdrawFunds() external; function isExistingCustomer(address _customer) external view returns(bool); }
// SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.7.0 <0.9.0; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; /** * @title EthernautToken contract * @dev This is the implementation of the CarToken contract * @notice There is an uncapped amount of supply * A user can only mint once */ interface ICarToken is IERC20 { function mint() external; }
// SPDX-License-Identifier: MIT // 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); }
{ "optimizer": { "enabled": false, "runs": 200 }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "libraries": {} }
[{"inputs":[{"internalType":"address","name":"_carMarket","type":"address"},{"internalType":"address","name":"_carToken","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"carMarket","outputs":[{"internalType":"contract ICarMarket","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"flashLoan","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getCarMarket","outputs":[{"internalType":"contract ICarMarket","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getCarToken","outputs":[{"internalType":"contract ICarToken","name":"","type":"address"}],"stateMutability":"view","type":"function"}]
Deployed Bytecode
0x608060405234801561001057600080fd5b506004361061004c5760003560e01c8063747f8a88146100515780639ab603b91461006f578063d93e8a951461008b578063e74e6a39146100a9575b600080fd5b6100596100c7565b6040516100669190610851565b60405180910390f35b610089600480360381019061008491906106ab565b6100f1565b005b6100936105f3565b6040516100a0919061086c565b60405180910390f35b6100b161061d565b6040516100be9190610851565b60405180910390f35b6000600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166396eef7d8336040518263ffffffff1660e01b815260040161014c919061080d565b60206040518083038186803b15801561016457600080fd5b505afa158015610178573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061019c9190610682565b6101db576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016101d2906108a7565b60405180910390fd5b6000600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166040518263ffffffff1660e01b815260040161025a919061080d565b60206040518083038186803b15801561027257600080fd5b505afa158015610286573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102aa91906106d4565b9050818110156102ef576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016102e6906108e7565b60405180910390fd5b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9059cbb33846040518363ffffffff1660e01b815260040161034c929190610828565b602060405180830381600087803b15801561036657600080fd5b505af115801561037a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061039e9190610682565b5060003373ffffffffffffffffffffffffffffffffffffffff16306040516024016103c9919061080d565b6040516020818303038152906040527fffb0f593000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff838183161783525050505060405161045391906107f6565b6000604051808303816000865af19150503d8060008114610490576040519150601f19603f3d011682016040523d82523d6000602084013e610495565b606091505b50509050806104d9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016104d090610887565b60405180910390fd5b6000600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166040518263ffffffff1660e01b8152600401610558919061080d565b60206040518083038186803b15801561057057600080fd5b505afa158015610584573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105a891906106d4565b9050828110156105ed576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016105e4906108c7565b60405180910390fd5b50505050565b6000600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008151905061065281610a95565b92915050565b60008135905061066781610aac565b92915050565b60008151905061067c81610aac565b92915050565b60006020828403121561069457600080fd5b60006106a284828501610643565b91505092915050565b6000602082840312156106bd57600080fd5b60006106cb84828501610658565b91505092915050565b6000602082840312156106e657600080fd5b60006106f48482850161066d565b91505092915050565b6107068161092e565b82525050565b600061071782610907565b6107218185610912565b93506107318185602086016109be565b80840191505092915050565b61074681610976565b82525050565b6107558161099a565b82525050565b600061076860158361091d565b9150610773826109f1565b602082019050919050565b600061078b60158361091d565b915061079682610a1a565b602082019050919050565b60006107ae60158361091d565b91506107b982610a43565b602082019050919050565b60006107d160148361091d565b91506107dc82610a6c565b602082019050919050565b6107f08161096c565b82525050565b6000610802828461070c565b915081905092915050565b600060208201905061082260008301846106fd565b92915050565b600060408201905061083d60008301856106fd565b61084a60208301846107e7565b9392505050565b6000602082019050610866600083018461073d565b92915050565b6000602082019050610881600083018461074c565b92915050565b600060208201905081810360008301526108a08161075b565b9050919050565b600060208201905081810360008301526108c08161077e565b9050919050565b600060208201905081810360008301526108e0816107a1565b9050919050565b60006020820190508181036000830152610900816107c4565b9050919050565b600081519050919050565b600081905092915050565b600082825260208201905092915050565b60006109398261094c565b9050919050565b60008115159050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600061098182610988565b9050919050565b60006109938261094c565b9050919050565b60006109a5826109ac565b9050919050565b60006109b78261094c565b9050919050565b60005b838110156109dc5780820151818401526020810190506109c1565b838111156109eb576000848401525b50505050565b7f43616c6c20746f20746172676574206661696c65640000000000000000000000600082015250565b7f4e6f74206578697374696e6720637573746f6d65720000000000000000000000600082015250565b7f4c6f616e206e6f74207061696420696e2066756c6c0000000000000000000000600082015250565b7f416d6f756e74206e6f7420617661696c61626c65000000000000000000000000600082015250565b610a9e81610940565b8114610aa957600080fd5b50565b610ab58161096c565b8114610ac057600080fd5b5056fea2646970667358221220c1eb1793449323f15941c7eeb2e6d3c2ebea6c79538605a8ec1d2fe3c160d07f64736f6c63430008010033
Loading...
Loading
[ Download: CSV Export ]
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.