Skip to content

Instantly share code, notes, and snippets.

@korrio
Created June 30, 2021 08:00
Show Gist options
  • Save korrio/ebb25d38ed9bbda3de748579debb931a to your computer and use it in GitHub Desktop.
Save korrio/ebb25d38ed9bbda3de748579debb931a to your computer and use it in GitHub Desktop.
BulkSender.sol
// File: contracts/EternalStorage.sol
// Initial code from Roman Storm Multi Sender
// To Use this Dapp: https://bulktokensending.github.io/bulktokensending
pragma solidity ^0.6.6;
import 'VonderToken.sol';
/**
* @title EternalStorage
* @dev This contract holds all the necessary state variables to carry out the storage of any contract.
*/
contract EternalStorage {
mapping(bytes32 => uint256) internal uintStorage;
mapping(bytes32 => string) internal stringStorage;
mapping(bytes32 => address) internal addressStorage;
mapping(bytes32 => bytes) internal bytesStorage;
mapping(bytes32 => bool) internal boolStorage;
mapping(bytes32 => int256) internal intStorage;
}
// File: contracts/UpgradeabilityStorage.sol
// Initial code from Roman Storm Multi Sender
// To Use this Dapp: https://bulktokensending.github.io/bulktokensending
//pragma solidity 0.4.23;
/**
* @title UpgradeabilityStorage
* @dev This contract holds all the necessary state variables to support the upgrade functionality
*/
contract UpgradeabilityStorage {
// Version name of the current implementation
string internal _version;
// Address of the current implementation
address internal _implementation;
/**
* @dev Tells the version name of the current implementation
* @return string representing the name of the current version
*/
function version() public view returns (string memory) {
return _version;
}
/**
* @dev Tells the address of the current implementation
* @return address of the current implementation
*/
function implementation() public view returns (address) {
return _implementation;
}
}
// File: contracts/UpgradeabilityOwnerStorage.sol
// Initial code from Roman Storm Multi Sender
// To Use this Dapp: https://bulktokensending.github.io/bulktokensending
// pragma solidity 0.4.23;
/**
* @title UpgradeabilityOwnerStorage
* @dev This contract keeps track of the upgradeability owner
*/
contract UpgradeabilityOwnerStorage {
// Owner of the contract
address private _upgradeabilityOwner;
/**
* @dev Tells the address of the owner
* @return the address of the owner
*/
function upgradeabilityOwner() public view returns (address) {
return _upgradeabilityOwner;
}
/**
* @dev Sets the address of the owner
*/
function setUpgradeabilityOwner(address newUpgradeabilityOwner) internal {
_upgradeabilityOwner = newUpgradeabilityOwner;
}
}
// File: contracts/OwnedUpgradeabilityStorage.sol
// Initial code from Roman Storm Multi Sender
// To Use this Dapp: https://bulktokensending.github.io/bulktokensending
// pragma solidity 0.4.23;
/**
* @title OwnedUpgradeabilityStorage
* @dev This is the storage necessary to perform upgradeable contracts.
* This means, required state variables for upgradeability purpose and eternal storage per se.
*/
contract OwnedUpgradeabilityStorage is UpgradeabilityOwnerStorage, UpgradeabilityStorage, EternalStorage {}
// File: contracts/bulktokensending/Ownable.sol
// Initial code from Roman Storm Multi Sender
// To Use this Dapp: https://bulktokensending.github.io/bulktokensending
// pragma solidity 0.4.23;
// File: contracts/bulktokensending/Claimable.sol
// Initial code from Roman Storm Multi Sender
// To Use this Dapp: https://bulktokensending.github.io/bulktokensending
// pragma solidity 0.4.23;
/**
* @title Claimable
* @dev Extension for the Ownable contract, where the ownership needs to be claimed.
* This allows the new owner to accept the transfer.
*/
contract Claimable is EternalStorage, Ownable {
function pendingOwner() public view returns (address) {
return addressStorage[keccak256("pendingOwner")];
}
/**
* @dev Modifier throws if called by any account other than the pendingOwner.
*/
modifier onlyPendingOwner() {
require(msg.sender == pendingOwner());
_;
}
/**
* @dev Allows the current owner to set the pendingOwner address.
* @param newOwner The address to transfer ownership to.
*/
function transferOwnership(address newOwner) public onlyOwner override {
require(newOwner != address(0));
addressStorage[keccak256("pendingOwner")] = newOwner;
}
/**
* @dev Allows the pendingOwner address to finalize the transfer.
*/
function claimOwnership() public onlyPendingOwner {
emit OwnershipTransferred(owner(), pendingOwner());
addressStorage[keccak256("owner")] = addressStorage[keccak256("pendingOwner")];
addressStorage[keccak256("pendingOwner")] = address(0);
}
}
// File: contracts/SafeMath.sol
// Initial code from Roman Storm Multi Sender
// To Use this Dapp: https://bulktokensending.github.io/bulktokensending
// pragma solidity 0.4.23;
contract UpgradebleSender is OwnedUpgradeabilityStorage, Claimable {
using SafeMath for uint256;
VonderToken public von;
event BulkSending(uint256 total, VonderToken tokenAddress);
event ClaimedTokens(address token, address owner, uint256 balance);
// modifier hasFee() {
// if (currentFee(msg.sender) > 0) {
// require(msg.value >= currentFee(msg.sender));
// }
// _;
// }
// function() public payable {}
function initialize(address _owner) public {
require(!initialized());
// setOwner(_owner);
setArrayLimit(200);
setDiscountStep(0.00001 ether);
setFee(0.01 ether);
boolStorage[keccak256("rs_bulktokensending_initialized")] = true;
}
function initialized() public view returns (bool) {
return boolStorage[keccak256("rs_bulktokensending_initialized")];
}
// function txCount(address customer) public view returns(uint256) {
// return uintStorage[keccak256("txCount", customer)];
// }
function arrayLimit() public view returns(uint256) {
return uintStorage[keccak256("arrayLimit")];
}
function setArrayLimit(uint256 _newLimit) public onlyOwner {
require(_newLimit != 0);
uintStorage[keccak256("arrayLimit")] = _newLimit;
}
function discountStep() public view returns(uint256) {
return uintStorage[keccak256("discountStep")];
}
function setDiscountStep(uint256 _newStep) public onlyOwner {
require(_newStep != 0);
uintStorage[keccak256("discountStep")] = _newStep;
}
function fee() public view returns(uint256) {
return uintStorage[keccak256("fee")];
}
// function currentFee(address _customer) public view returns(uint256) {
// if(boolStorage[keccak256("vip", _customer)] == true) {
// return 0;
// }
// if (fee() > discountRate(msg.sender)) {
// return fee().sub(discountRate(_customer));
// } else {
// return 0;
// }
// }
function setFee(uint256 _newStep) public onlyOwner {
require(_newStep != 0);
uintStorage[keccak256("fee")] = _newStep;
}
// function discountRate(address _customer) public view returns(uint256) {
// uint256 count = txCount(_customer);
// return count.mul(discountStep());
// }
function multisendToken(VonderToken token, address[] memory _contributors, uint256[] memory _balances) public payable {
// if (token == 0x000000000000000000000000000000000000bEEF){
// multisendEther(_contributors, _balances);
// } else {
uint256 total = 0;
require(_contributors.length <= arrayLimit());
von = token;
uint8 i = 0;
for (i; i < _contributors.length; i++) {
von.transferFrom(msg.sender, _contributors[i], _balances[i]);
total += _balances[i];
}
// setTxCount(msg.sender, txCount(msg.sender).add(1));
emit BulkSending(total, token);
// }
}
// function multisendEther(address[] memory _contributors, uint256[] memory _balances) public payable {
// uint256 total = msg.value;
// uint256 _fee = 0;
// require(total >= _fee);
// require(_contributors.length <= arrayLimit());
// total = total.sub(_fee);
// uint256 i = 0;
// for (i; i < _contributors.length; i++) {
// require(total >= _balances[i]);
// total = total.sub(_balances[i]);
// _contributors[i].transfer(_balances[i]);
// }
// setTxCount(msg.sender, txCount(msg.sender).add(1));
// emit BulkSending(msg.value, 0x000000000000000000000000000000000000bEEF);
// }
// function claimTokens(VonderToken _token) public onlyOwner {
// // if (_token == 0x0) {
// // owner().transfer(address(this).balance);
// // return;
// // }
// von = _token;
// uint256 balance = von.balanceOf(this);
// von.transfer(owner(), balance);
// emit ClaimedTokens(_token, owner(), balance);
// }
// function addVipCustomer(address customer) public onlyOwner {
// boolStorage[keccak256("vip", customer)] = true;
// }
// function removeVipCustomer(address customer) public onlyOwner {
// boolStorage[keccak256("vip", customer)] = false;
// }
// function setTxCount(address customer, uint256 _txCount) private {
// uintStorage[customer] = _txCount;
// }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment