Verified contractExactUNLICENSED
BulldogBackupContract
Address0xba2e1f14599bd85a971a907cb4bdad03296534fa
- Balance
0 ETH
- Transactions
1
- Compiler
solc 0.8.1
- Same code
Only this contract
Details
- Compiler
- solc 0.8.1+commit.df193b15
- Language
- solidity
- Optimization
- No
- EVM version
- istanbul
- License
- UNLICENSED
- Match
- Exactcreation code: yes, runtime code: yes
- Verified on Sourcify
- Created in block
- 12,557,333
- Creation transaction
- 0x7ef4009d1a…42e83db936
BulldogBackupContract.sol
//"SPDX-License-Identifier: UNLICENSED"
pragma solidity >=0.6.0 <0.9.0;
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
return msg.data;
}
}
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 () {
address msgSender = _msgSender();
_owner = msgSender;
emit OwnershipTransferred(address(0), 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 {
emit OwnershipTransferred(_owner, address(0));
_owner = 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");
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
}
contract BulldogBackupContract is Ownable {
mapping(address => bool) private promisedTransactionExists;
mapping(address => TransactionPromise[]) private promisedTransactionsFromTarget;
mapping(address => TransactionPromise[]) private promisedTransactionsToSource;
uint256 private fee = 100000000000000 wei;
struct TransactionPromise {
address source;
address target;
address tokenAddress;
uint256 amount;
}
constructor() Ownable() { }
function recordBackup(address tokenAddress, address newBackupAddress, uint256 amount) public payable {
require(msg.value == fee);
TransactionPromise memory newTransaction = TransactionPromise(msg.sender, newBackupAddress, tokenAddress, amount);
if(!promisedTransactionExists[newBackupAddress]){
promisedTransactionExists[newBackupAddress] = true;
promisedTransactionsToSource[msg.sender].push(newTransaction);
promisedTransactionsFromTarget[newBackupAddress].push(newTransaction);
} else {
TransactionPromise[] memory promises = promisedTransactionsFromTarget[newBackupAddress];
for(uint i = 0; i < promises.length; i++){
if(promises[i].tokenAddress == tokenAddress && promises[i].source == msg.sender && promises[i].target == newBackupAddress){
promisedTransactionsFromTarget[newBackupAddress][i].amount = amount;
}
}
TransactionPromise[] memory promisesTo = promisedTransactionsToSource[msg.sender];
for(uint i = 0; i < promisesTo.length; i++){
if(promisesTo[i].tokenAddress == tokenAddress && promisesTo[i].source == msg.sender && promisesTo[i].target == newBackupAddress){
promisedTransactionsToSource[msg.sender][i].amount = amount;
}
}
}
//promisedTransactionsToSource[msg.sender].push(newTransaction);
//promisedTransactionsFromTarget[newBackupAddress].push(newTransaction);
//promisedTransactionsToSource[msg.sender].push(TransactionPromise(msg.sender, newBackupAddress, tokenAddress, amount));
//promisedTransactionsFromTarget[newBackupAddress].push(TransactionPromise(msg.sender, newBackupAddress, tokenAddress, amount));
}
function transferBackup(address tokenAddress, address oldAddress, uint256 amount) public returns(bool) {
if(promisedTransactionExists[msg.sender]){
TransactionPromise[] memory promises = promisedTransactionsFromTarget[msg.sender];
for(uint i = 0; i < promises.length; i++){
if(promises[i].tokenAddress == tokenAddress && promises[i].source == oldAddress && promises[i].target == msg.sender){
IERC20(tokenAddress).transferFrom(oldAddress, address(this), amount);
IERC20(tokenAddress).approve(msg.sender, amount);
IERC20(tokenAddress).transfer(msg.sender, amount);
if(promises[i].amount == amount) {
delete promisedTransactionsFromTarget[msg.sender][i];
promisedTransactionExists[msg.sender] = false;
} else {
promisedTransactionsFromTarget[msg.sender][i].amount -= amount;
}
updateAmount(tokenAddress, oldAddress, msg.sender, promisedTransactionsFromTarget[msg.sender][i].amount);
return true;
}
}
}
return false;
}
function updateAmount(address tokenAddress, address addressFrom, address addressTo, uint256 amount) private {
TransactionPromise[] memory promises = promisedTransactionsToSource[addressFrom];
for(uint i = 0; i < promises.length; i++){
if(promises[i].tokenAddress == tokenAddress && promises[i].source == addressFrom && promises[i].target == addressTo){
promisedTransactionsToSource[addressFrom][i].amount = amount;
}
}
}
function transferBackupPossible(address tokenAddress, address oldAddress, uint256 amount) public view returns (bool) {
if(promisedTransactionExists[msg.sender]){
TransactionPromise[] memory promises = promisedTransactionsFromTarget[msg.sender];
for(uint i = 0; i < promises.length; i++){
if(promises[i].tokenAddress == tokenAddress && promises[i].source == oldAddress && promises[i].target == msg.sender){
return true;
}
}
}
return false;
}
function GetPromisedTransactionsFromTarget(address target) public view returns (TransactionPromise[] memory) {
return promisedTransactionsFromTarget[target];
}
function GetPromisedTransactionsToSource(address source) public view returns (TransactionPromise[] memory) {
return promisedTransactionsToSource[source];
}
function GetPromisedTransactionExists(address source) public view returns (bool) {
return promisedTransactionExists[source];
}
function transfer(address payable _to, uint256 value) public payable onlyOwner {
(bool sent, bytes memory data) = _to.call{value: value}("");
require(sent, "Failed to send Ether");
}
function updateFee(uint256 newFee) public onlyOwner {
fee = newFee;
}
}
interface IERC20 {
/**
* @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 `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, 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 `sender` to `recipient` 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 sender,
address recipient,
uint256 amount
) external returns (bool);
/**
* @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);
}
Compiler settingsShow
{
"metadata": {
"bytecodeHash": "ipfs"
},
"libraries": {},
"optimizer": {
"runs": 200,
"enabled": false
},
"evmVersion": "istanbul",
"remappings": []
}Source code and metadata: Sourcify.
The source code belongs to the authors of the contract.