Warning! Contract bytecode has been changed and doesn't match the verified one. Therefore, interaction with this smart contract may be risky.
- Contract name:
- ReferralTracker
- Optimization enabled
- true
- Compiler version
- v0.8.18+commit.87f61d96
- Optimization runs
- 200
- EVM Version
- default
- Verified at
- 2024-09-26T15:33:52.542506Z
Contract source code
// SPDX-License-Identifier: No License (None) pragma solidity 0.8.18; interface IERC223 { function balanceOf(address who) external view returns (uint); function transfer(address to, uint value) external returns (bool success); /** * @dev Transfers `value` tokens from `msg.sender` to `to` address with `data` parameter * and returns `true` on success. */ function transfer(address to, uint value, bytes memory data) external returns (bool success); function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); function approve(address spender, uint256 amount) external returns (bool); } abstract contract Ownable { address internal _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ /* will use initialize instead constructor () { _owner = msg.sender; emit OwnershipTransferred(address(0), msg.sender); } */ /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Transfers control of the contract to a newOwner. * @param newOwner The address to transfer ownership to. */ function transferOwnership(address newOwner) public onlyOwner { require(newOwner != address(0),"Zero address not allowed"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == msg.sender, "Ownable: caller is not the owner"); _; } } contract ReferralTracker is Ownable { address public constant BURN_ADDRESS = 0x000000000000000000000000000000000000dEaD; address public constant SOY_ADDRESS = 0x9FaE2529863bD691B4A7171bDfCf33C7ebB10a65; string public constant name = "Soy Referrals SBT"; string public constant symbol = "RefSBT"; uint256 public total; uint256 public totalReferralFee; address public system; mapping(uint256 _tokenId => address) public ownerOf; mapping(address _owner => uint256) public balanceOf; mapping(address => address) public referrals; // user => referral event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); modifier onlySystem() { require(system == msg.sender, "Only system"); _; } function initialize(address newOwner, address newSystem) external { require(_owner == address(0)); require(newOwner != address(0) && newSystem != address(0)); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; totalReferralFee = 500; // 5% IERC223(SOY_ADDRESS).approve(address(this), type(uint256).max); system = newSystem; } // set referral address for user "to", if it was not set before function mint(address to, address from_ref) external onlySystem { if(referrals[to] == address(0)) { uint256 tokenId = total++; ownerOf[tokenId] = to; balanceOf[to] = 1; referrals[to] = from_ref; emit Transfer(address(0), to, tokenId); } } // returns fee percentage with 2 decimals for particular user function userFee(address user) external view returns(uint256) { return totalReferralFee; } function tokenReceived(address, uint256 _amount, bytes memory _data) external { require(msg.sender == SOY_ADDRESS, "Wrong token"); require(_data.length == 32, "wrong parameter"); address user = abi.decode(_data, (address)); require(user != address(0), "wrong address"); _processRef(user, _amount); } function _processRef(address user, uint256 amount) internal { address ref = referrals[user]; if(ref == address(0)) ref = BURN_ADDRESS; // if no referral then burn IERC223(SOY_ADDRESS).transferFrom(address(this), ref, amount); // use transferFrom to avoid revert by evil user } // set referral fee in percentage with 2 decimals (i.e. 500 = 5%) function setReferralFee(uint256 fee) external onlyOwner { require(fee < 5000); totalReferralFee = fee; } // set system address function setSystem(address _system) external onlyOwner { require(_system != address(0)); system = _system; } }
Contract ABI
[{"type":"event","name":"OwnershipTransferred","inputs":[{"type":"address","name":"previousOwner","internalType":"address","indexed":true},{"type":"address","name":"newOwner","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"Transfer","inputs":[{"type":"address","name":"from","internalType":"address","indexed":true},{"type":"address","name":"to","internalType":"address","indexed":true},{"type":"uint256","name":"tokenId","internalType":"uint256","indexed":true}],"anonymous":false},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"BURN_ADDRESS","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"SOY_ADDRESS","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"balanceOf","inputs":[{"type":"address","name":"_owner","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"initialize","inputs":[{"type":"address","name":"newOwner","internalType":"address"},{"type":"address","name":"newSystem","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"mint","inputs":[{"type":"address","name":"to","internalType":"address"},{"type":"address","name":"from_ref","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"string","name":"","internalType":"string"}],"name":"name","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"owner","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"ownerOf","inputs":[{"type":"uint256","name":"_tokenId","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"referrals","inputs":[{"type":"address","name":"","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setReferralFee","inputs":[{"type":"uint256","name":"fee","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setSystem","inputs":[{"type":"address","name":"_system","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"string","name":"","internalType":"string"}],"name":"symbol","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"system","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"tokenReceived","inputs":[{"type":"address","name":"","internalType":"address"},{"type":"uint256","name":"_amount","internalType":"uint256"},{"type":"bytes","name":"_data","internalType":"bytes"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"total","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"totalReferralFee","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"transferOwnership","inputs":[{"type":"address","name":"newOwner","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"userFee","inputs":[{"type":"address","name":"user","internalType":"address"}]}]
Contract Creation Code
0x608060405234801561001057600080fd5b50610b2e806100206000396000f3fe608060405234801561001057600080fd5b50600436106101165760003560e01c80638da5cb5b116100a2578063a970429411610071578063a9704294146102ae578063ab9344ed146102b7578063ee1fe2ad146102d2578063f2fde38b146102e5578063fccc2813146102f857600080fd5b80638da5cb5b1461023c57806395bf75fd1461024d57806395d89b41146102605780639ca423b31461028557600080fd5b806356c5f349116100e957806356c5f349146101a05780636352211e146101b557806370a08231146101f6578063713494d7146102165780638943ec021461022957600080fd5b806306fdde031461011b5780632ddbd13a14610161578063485cc95514610178578063558377571461018d575b600080fd5b61014b6040518060400160405280601181526020017014dbde48149959995c9c985b1cc814d095607a1b81525081565b604051610158919061089e565b60405180910390f35b61016a60015481565b604051908152602001610158565b61018b610186366004610904565b610301565b005b61018b61019b36600461093d565b61043b565b61016a6101ae36600461093d565b5060025490565b6101de6101c3366004610961565b6004602052600090815260409020546001600160a01b031681565b6040516001600160a01b039091168152602001610158565b61016a61020436600461093d565b60056020526000908152604090205481565b61018b610224366004610961565b6104b2565b61018b610237366004610990565b6104fe565b6000546001600160a01b03166101de565b6003546101de906001600160a01b031681565b61014b6040518060400160405280600681526020016514995994d09560d21b81525081565b6101de61029336600461093d565b6006602052600090815260409020546001600160a01b031681565b61016a60025481565b6101de739fae2529863bd691b4a7171bdfcf33c7ebb10a6581565b61018b6102e0366004610904565b610600565b61018b6102f336600461093d565b610704565b6101de61dead81565b6000546001600160a01b03161561031757600080fd5b6001600160a01b0382161580159061033757506001600160a01b03811615155b61034057600080fd5b600080546040516001600160a01b03808616939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0384161790556101f460025560405163095ea7b360e01b81523060048201526000196024820152739fae2529863bd691b4a7171bdfcf33c7ebb10a659063095ea7b3906044016020604051808303816000875af11580156103f3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104179190610a5d565b50600380546001600160a01b0319166001600160a01b039290921691909117905550565b3361044e6000546001600160a01b031690565b6001600160a01b03161461047d5760405162461bcd60e51b815260040161047490610a7f565b60405180910390fd5b6001600160a01b03811661049057600080fd5b600380546001600160a01b0319166001600160a01b0392909216919091179055565b336104c56000546001600160a01b031690565b6001600160a01b0316146104eb5760405162461bcd60e51b815260040161047490610a7f565b61138881106104f957600080fd5b600255565b33739fae2529863bd691b4a7171bdfcf33c7ebb10a651461054f5760405162461bcd60e51b815260206004820152600b60248201526a2bb937b733903a37b5b2b760a91b6044820152606401610474565b80516020146105925760405162461bcd60e51b815260206004820152600f60248201526e3bb937b733903830b930b6b2ba32b960891b6044820152606401610474565b6000818060200190518101906105a89190610ab4565b90506001600160a01b0381166105f05760405162461bcd60e51b815260206004820152600d60248201526c77726f6e67206164647265737360981b6044820152606401610474565b6105fa81846107ee565b50505050565b6003546001600160a01b031633146106485760405162461bcd60e51b815260206004820152600b60248201526a4f6e6c792073797374656d60a81b6044820152606401610474565b6001600160a01b038281166000908152600660205260409020541661070057600180546000918261067883610ad1565b90915550600081815260046020908152604080832080546001600160a01b03199081166001600160a01b038a81169182179093558086526005855283862060019055600690945282852080549091169188169190911790555192935083929091907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a4505b5050565b336107176000546001600160a01b031690565b6001600160a01b03161461073d5760405162461bcd60e51b815260040161047490610a7f565b6001600160a01b0381166107935760405162461bcd60e51b815260206004820152601860248201527f5a65726f2061646472657373206e6f7420616c6c6f77656400000000000000006044820152606401610474565b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b6001600160a01b038083166000908152600660205260409020541680610813575061dead5b6040516323b872dd60e01b81523060048201526001600160a01b038216602482015260448101839052739fae2529863bd691b4a7171bdfcf33c7ebb10a65906323b872dd906064016020604051808303816000875af115801561087a573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105fa9190610a5d565b600060208083528351808285015260005b818110156108cb578581018301518582016040015282016108af565b506000604082860101526040601f19601f8301168501019250505092915050565b6001600160a01b038116811461090157600080fd5b50565b6000806040838503121561091757600080fd5b8235610922816108ec565b91506020830135610932816108ec565b809150509250929050565b60006020828403121561094f57600080fd5b813561095a816108ec565b9392505050565b60006020828403121561097357600080fd5b5035919050565b634e487b7160e01b600052604160045260246000fd5b6000806000606084860312156109a557600080fd5b83356109b0816108ec565b925060208401359150604084013567ffffffffffffffff808211156109d457600080fd5b818601915086601f8301126109e857600080fd5b8135818111156109fa576109fa61097a565b604051601f8201601f19908116603f01168101908382118183101715610a2257610a2261097a565b81604052828152896020848701011115610a3b57600080fd5b8260208601602083013760006020848301015280955050505050509250925092565b600060208284031215610a6f57600080fd5b8151801515811461095a57600080fd5b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b600060208284031215610ac657600080fd5b815161095a816108ec565b600060018201610af157634e487b7160e01b600052601160045260246000fd5b506001019056fea264697066735822122029ebc0ad7ceeda6e936d2afe357179e709adc88fcc223fefae03f87d7f946c9164736f6c63430008120033
Deployed ByteCode
0x608060405234801561001057600080fd5b50600436106101165760003560e01c80638da5cb5b116100a2578063a970429411610071578063a9704294146102ae578063ab9344ed146102b7578063ee1fe2ad146102d2578063f2fde38b146102e5578063fccc2813146102f857600080fd5b80638da5cb5b1461023c57806395bf75fd1461024d57806395d89b41146102605780639ca423b31461028557600080fd5b806356c5f349116100e957806356c5f349146101a05780636352211e146101b557806370a08231146101f6578063713494d7146102165780638943ec021461022957600080fd5b806306fdde031461011b5780632ddbd13a14610161578063485cc95514610178578063558377571461018d575b600080fd5b61014b6040518060400160405280601181526020017014dbde48149959995c9c985b1cc814d095607a1b81525081565b604051610158919061089e565b60405180910390f35b61016a60015481565b604051908152602001610158565b61018b610186366004610904565b610301565b005b61018b61019b36600461093d565b61043b565b61016a6101ae36600461093d565b5060025490565b6101de6101c3366004610961565b6004602052600090815260409020546001600160a01b031681565b6040516001600160a01b039091168152602001610158565b61016a61020436600461093d565b60056020526000908152604090205481565b61018b610224366004610961565b6104b2565b61018b610237366004610990565b6104fe565b6000546001600160a01b03166101de565b6003546101de906001600160a01b031681565b61014b6040518060400160405280600681526020016514995994d09560d21b81525081565b6101de61029336600461093d565b6006602052600090815260409020546001600160a01b031681565b61016a60025481565b6101de739fae2529863bd691b4a7171bdfcf33c7ebb10a6581565b61018b6102e0366004610904565b610600565b61018b6102f336600461093d565b610704565b6101de61dead81565b6000546001600160a01b03161561031757600080fd5b6001600160a01b0382161580159061033757506001600160a01b03811615155b61034057600080fd5b600080546040516001600160a01b03808616939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0384161790556101f460025560405163095ea7b360e01b81523060048201526000196024820152739fae2529863bd691b4a7171bdfcf33c7ebb10a659063095ea7b3906044016020604051808303816000875af11580156103f3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104179190610a5d565b50600380546001600160a01b0319166001600160a01b039290921691909117905550565b3361044e6000546001600160a01b031690565b6001600160a01b03161461047d5760405162461bcd60e51b815260040161047490610a7f565b60405180910390fd5b6001600160a01b03811661049057600080fd5b600380546001600160a01b0319166001600160a01b0392909216919091179055565b336104c56000546001600160a01b031690565b6001600160a01b0316146104eb5760405162461bcd60e51b815260040161047490610a7f565b61138881106104f957600080fd5b600255565b33739fae2529863bd691b4a7171bdfcf33c7ebb10a651461054f5760405162461bcd60e51b815260206004820152600b60248201526a2bb937b733903a37b5b2b760a91b6044820152606401610474565b80516020146105925760405162461bcd60e51b815260206004820152600f60248201526e3bb937b733903830b930b6b2ba32b960891b6044820152606401610474565b6000818060200190518101906105a89190610ab4565b90506001600160a01b0381166105f05760405162461bcd60e51b815260206004820152600d60248201526c77726f6e67206164647265737360981b6044820152606401610474565b6105fa81846107ee565b50505050565b6003546001600160a01b031633146106485760405162461bcd60e51b815260206004820152600b60248201526a4f6e6c792073797374656d60a81b6044820152606401610474565b6001600160a01b038281166000908152600660205260409020541661070057600180546000918261067883610ad1565b90915550600081815260046020908152604080832080546001600160a01b03199081166001600160a01b038a81169182179093558086526005855283862060019055600690945282852080549091169188169190911790555192935083929091907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a4505b5050565b336107176000546001600160a01b031690565b6001600160a01b03161461073d5760405162461bcd60e51b815260040161047490610a7f565b6001600160a01b0381166107935760405162461bcd60e51b815260206004820152601860248201527f5a65726f2061646472657373206e6f7420616c6c6f77656400000000000000006044820152606401610474565b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b6001600160a01b038083166000908152600660205260409020541680610813575061dead5b6040516323b872dd60e01b81523060048201526001600160a01b038216602482015260448101839052739fae2529863bd691b4a7171bdfcf33c7ebb10a65906323b872dd906064016020604051808303816000875af115801561087a573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105fa9190610a5d565b600060208083528351808285015260005b818110156108cb578581018301518582016040015282016108af565b506000604082860101526040601f19601f8301168501019250505092915050565b6001600160a01b038116811461090157600080fd5b50565b6000806040838503121561091757600080fd5b8235610922816108ec565b91506020830135610932816108ec565b809150509250929050565b60006020828403121561094f57600080fd5b813561095a816108ec565b9392505050565b60006020828403121561097357600080fd5b5035919050565b634e487b7160e01b600052604160045260246000fd5b6000806000606084860312156109a557600080fd5b83356109b0816108ec565b925060208401359150604084013567ffffffffffffffff808211156109d457600080fd5b818601915086601f8301126109e857600080fd5b8135818111156109fa576109fa61097a565b604051601f8201601f19908116603f01168101908382118183101715610a2257610a2261097a565b81604052828152896020848701011115610a3b57600080fd5b8260208601602083013760006020848301015280955050505050509250925092565b600060208284031215610a6f57600080fd5b8151801515811461095a57600080fd5b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b600060208284031215610ac657600080fd5b815161095a816108ec565b600060018201610af157634e487b7160e01b600052601160045260246000fd5b506001019056fea264697066735822122029ebc0ad7ceeda6e936d2afe357179e709adc88fcc223fefae03f87d7f946c9164736f6c63430008120033