Description:
Multi-signature wallet contract requiring multiple confirmations for transaction execution.
Blockchain: Ethereum
Source Code: View Code On The Blockchain
Solidity Source Code:
{{
"language": "Solidity",
"sources": {
"@openzeppelin/contracts/access/Ownable.sol": {
"content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)
pragma solidity ^0.8.20;
import {Context} from "../utils/Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* The initial owner is set to the address provided by the deployer. This can
* later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
/**
* @dev The caller account is not authorized to perform an operation.
*/
error OwnableUnauthorizedAccount(address account);
/**
* @dev The owner is not a valid owner account. (eg. `address(0)`)
*/
error OwnableInvalidOwner(address owner);
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the address provided by the deployer as the initial owner.
*/
constructor(address initialOwner) {
if (initialOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(initialOwner);
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
_checkOwner();
_;
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if the sender is not the owner.
*/
function _checkOwner() internal view virtual {
if (owner() != _msgSender()) {
revert OwnableUnauthorizedAccount(_msgSender());
}
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby disabling any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(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 {
if (newOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
"
},
"@openzeppelin/contracts/utils/Context.sol": {
"content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)
pragma solidity ^0.8.20;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
function _contextSuffixLength() internal view virtual returns (uint256) {
return 0;
}
}
"
},
"contracts/OptimizedABIDeployer.sol": {
"content": "// SPDX-License-Identifier: MIT\r
pragma solidity ^0.8.28;\r
\r
import "@openzeppelin/contracts/access/Ownable.sol";\r
\r
/**\r
* @title OptimizedABIDeployer\r
* @notice Deploy tokens using exact TokenRegistry ABI parameters\r
* @dev Only deploys ONE token type per deployment, optimized for size\r
*/\r
contract OptimizedABIDeployer is Ownable {\r
\r
// =====================================================\r
// CONSTRUCTOR\r
// =====================================================\r
\r
constructor() Ownable(msg.sender) {}\r
\r
// =====================================================\r
// ENUMS (matching TokenRegistry ABI exactly)\r
// =====================================================\r
\r
enum TokenType { ERC20, ERC721, ERC1155, ERC3643 }\r
enum RegulatoryType { REGULATED, UNREGULATED }\r
enum AssetClass { BOND, EQUITY, REAL_ESTATE, FUND, COMMODITY, CRYPTO, DERIVATIVE, IP_RIGHT, COLLECTIBLE }\r
\r
// =====================================================\r
// EVENTS\r
// =====================================================\r
\r
event TokenDeployed(\r
address indexed tokenAddress,\r
uint8 tokenType,\r
uint8 regulatoryType,\r
uint8 assetClass,\r
address indexed deployer,\r
uint256 timestamp\r
);\r
\r
// =====================================================\r
// MAIN DEPLOYMENT FUNCTION (exact ABI match)\r
// =====================================================\r
\r
/**\r
* @notice Deploy token using exact TokenRegistry ABI parameters\r
* @param name Token name\r
* @param symbol Token symbol\r
* @param decimals Token decimals\r
* @param tokenType Token type (0=ERC20, 1=ERC721, 2=ERC1155, 3=ERC3643)\r
* @param regulatoryType Regulatory type (0=REGULATED, 1=UNREGULATED)\r
* @param assetClass Asset class (0-8)\r
* @param safeWallet Safe wallet address\r
* @param kycRequired KYC requirement\r
* @param whitelistOnly Whitelist requirement\r
* @param assetData Asset-specific data\r
* @return tokenAddress Address of deployed token\r
*/\r
function deployToken(\r
bytes32 /* tokenId */,\r
string memory name,\r
string memory symbol,\r
uint8 decimals,\r
uint8 tokenType,\r
uint8 regulatoryType,\r
uint8 assetClass,\r
address safeWallet,\r
uint32 /* transferFeeBps */,\r
bool kycRequired,\r
bool whitelistOnly,\r
bytes memory assetData\r
) external returns (address tokenAddress) {\r
// =====================================================\r
// CHECKS (Input validations - ANTI-REENTRANCY)\r
// =====================================================\r
require(tokenType <= 3, "Invalid token type");\r
require(regulatoryType <= 1, "Invalid regulatory type");\r
require(assetClass <= 8, "Invalid asset class");\r
require(bytes(name).length > 0, "Name cannot be empty");\r
require(bytes(symbol).length > 0, "Symbol cannot be empty");\r
require(safeWallet != address(0), "Invalid safe wallet");\r
\r
// Specific validation for ERC3643\r
if (tokenType == 3) {\r
require(regulatoryType == 0, "ERC3643 must be regulated");\r
}\r
\r
// =====================================================\r
// EFFECTS (Internal state preparation - ANTI-REENTRANCY)\r
// =====================================================\r
// No internal state effects in this function\r
// All validations are completed before any external interaction\r
\r
// =====================================================\r
// INTERACTIONS (External calls - deployment - ANTI-REENTRANCY)\r
// =====================================================\r
// All external interactions are performed after completing all validations\r
if (tokenType == 0) {\r
// ERC20\r
tokenAddress = _deployERC20(name, symbol, decimals, safeWallet, assetData);\r
} else if (tokenType == 1) {\r
// ERC721\r
tokenAddress = _deployERC721(name, symbol, assetData);\r
} else if (tokenType == 2) {\r
// ERC1155\r
tokenAddress = _deployERC1155(string(assetData), assetData);\r
} else if (tokenType == 3) {\r
// ERC3643 (Regulated)\r
tokenAddress = _deployERC3643(name, symbol, decimals, safeWallet, kycRequired, whitelistOnly, assetData);\r
}\r
\r
// =====================================================\r
// EVENTS (Emitted after all interactions - ANTI-REENTRANCY)\r
// =====================================================\r
// Events are emitted at the end, after completing all external interactions\r
emit TokenDeployed(tokenAddress, tokenType, regulatoryType, assetClass, msg.sender, block.timestamp);\r
}\r
\r
// =====================================================\r
// INTERNAL DEPLOYMENT FUNCTIONS\r
// =====================================================\r
\r
function _deployERC20(\r
string memory name,\r
string memory symbol,\r
uint8 decimals,\r
address tokenOwner,\r
bytes memory assetData\r
) internal returns (address tokenAddress) {\r
ERC20Token token = new ERC20Token(name, symbol);\r
token.initialize(name, symbol, decimals, tokenOwner, assetData);\r
tokenAddress = address(token);\r
}\r
\r
function _deployERC721(\r
string memory name,\r
string memory symbol,\r
bytes memory assetData\r
) internal returns (address tokenAddress) {\r
ERC721Token token = new ERC721Token(name, symbol);\r
token.initialize(name, symbol, assetData);\r
tokenAddress = address(token);\r
}\r
\r
function _deployERC1155(\r
string memory uri,\r
bytes memory assetData\r
) internal returns (address tokenAddress) {\r
ERC1155Token token = new ERC1155Token();\r
token.initialize(uri, assetData);\r
tokenAddress = address(token);\r
}\r
\r
function _deployERC3643(\r
string memory name,\r
string memory symbol,\r
uint8 decimals,\r
address tokenOwner,\r
bool kycRequired,\r
bool whitelistOnly,\r
bytes memory assetData\r
) internal returns (address tokenAddress) {\r
ERC3643Token token = new ERC3643Token(name, symbol);\r
token.initialize(name, symbol, decimals, tokenOwner, kycRequired, whitelistOnly, assetData);\r
tokenAddress = address(token);\r
}\r
\r
// =====================================================\r
// HELPER FUNCTIONS\r
// =====================================================\r
\r
function getSupportedCombinations() external pure returns (\r
uint8[] memory tokenTypes,\r
uint8[] memory regulatoryTypes,\r
uint8[] memory assetClasses\r
) {\r
tokenTypes = new uint8[](4);\r
tokenTypes[0] = 0; // ERC20\r
tokenTypes[1] = 1; // ERC721\r
tokenTypes[2] = 2; // ERC1155\r
tokenTypes[3] = 3; // ERC3643\r
\r
regulatoryTypes = new uint8[](2);\r
regulatoryTypes[0] = 0; // REGULATED\r
regulatoryTypes[1] = 1; // UNREGULATED\r
\r
assetClasses = new uint8[](9);\r
for (uint8 i = 0; i < 9; i++) {\r
assetClasses[i] = i;\r
}\r
}\r
}\r
\r
// =====================================================\r
// INDIVIDUAL TOKEN CONTRACTS\r
// =====================================================\r
\r
/**\r
* @title ERC20Token\r
* @notice Basic ERC20 implementation\r
*/\r
contract ERC20Token is Ownable {\r
string public name;\r
string public symbol;\r
uint8 public decimals;\r
uint256 public totalSupply;\r
bytes public assetData;\r
bool private _initialized;\r
\r
mapping(address => uint256) public balanceOf;\r
mapping(address => mapping(address => uint256)) public allowance;\r
\r
event Transfer(address indexed from, address indexed to, uint256 value);\r
event Approval(address indexed owner, address indexed spender, uint256 value);\r
\r
constructor(string memory _name, string memory _symbol) Ownable(msg.sender) {\r
name = _name;\r
symbol = _symbol;\r
}\r
\r
function initialize(\r
string memory tokenName,\r
string memory tokenSymbol,\r
uint8 tokenDecimals,\r
address tokenOwner,\r
bytes memory tokenAssetData\r
) external {\r
require(!_initialized, "Already initialized");\r
_transferOwnership(tokenOwner);\r
name = tokenName;\r
symbol = tokenSymbol;\r
decimals = tokenDecimals;\r
assetData = tokenAssetData;\r
_initialized = true;\r
}\r
\r
function mint(address to, uint256 amount) external onlyOwner {\r
require(to != address(0), "Mint to zero address");\r
totalSupply += amount;\r
balanceOf[to] += amount;\r
emit Transfer(address(0), to, amount);\r
}\r
\r
function burn(uint256 amount) external {\r
require(balanceOf[msg.sender] >= amount, "Insufficient balance");\r
balanceOf[msg.sender] -= amount;\r
totalSupply -= amount;\r
emit Transfer(msg.sender, address(0), amount);\r
}\r
\r
function transfer(address to, uint256 amount) external returns (bool) {\r
require(to != address(0), "Transfer to zero address");\r
require(balanceOf[msg.sender] >= amount, "Insufficient balance");\r
\r
balanceOf[msg.sender] -= amount;\r
balanceOf[to] += amount;\r
emit Transfer(msg.sender, to, amount);\r
return true;\r
}\r
\r
function approve(address spender, uint256 amount) external returns (bool) {\r
allowance[msg.sender][spender] = amount;\r
emit Approval(msg.sender, spender, amount);\r
return true;\r
}\r
\r
function transferFrom(address from, address to, uint256 amount) external returns (bool) {\r
require(to != address(0), "Transfer to zero address");\r
require(balanceOf[from] >= amount, "Insufficient balance");\r
require(allowance[from][msg.sender] >= amount, "Insufficient allowance");\r
\r
balanceOf[from] -= amount;\r
balanceOf[to] += amount;\r
allowance[from][msg.sender] -= amount;\r
emit Transfer(from, to, amount);\r
return true;\r
}\r
}\r
\r
/**\r
* @title ERC721Token\r
* @notice Basic ERC721 implementation\r
*/\r
contract ERC721Token is Ownable {\r
string public name;\r
string public symbol;\r
bytes public assetData;\r
bool private _initialized;\r
\r
mapping(uint256 => address) public ownerOf;\r
mapping(address => uint256) public balanceOf;\r
mapping(uint256 => address) public getApproved;\r
mapping(address => mapping(address => bool)) public isApprovedForAll;\r
\r
event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);\r
event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);\r
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);\r
\r
constructor(string memory _name, string memory _symbol) Ownable(msg.sender) {\r
name = _name;\r
symbol = _symbol;\r
}\r
\r
function initialize(\r
string memory tokenName,\r
string memory tokenSymbol,\r
bytes memory tokenAssetData\r
) external {\r
require(!_initialized, "Already initialized");\r
name = tokenName;\r
symbol = tokenSymbol;\r
assetData = tokenAssetData;\r
_initialized = true;\r
}\r
\r
function mint(address to, uint256 tokenId) external onlyOwner {\r
require(to != address(0), "Mint to zero address");\r
require(ownerOf[tokenId] == address(0), "Token already exists");\r
\r
ownerOf[tokenId] = to;\r
balanceOf[to]++;\r
emit Transfer(address(0), to, tokenId);\r
}\r
\r
function burn(uint256 tokenId) external {\r
require(ownerOf[tokenId] == msg.sender, "Not token owner");\r
\r
address tokenOwner = ownerOf[tokenId];\r
ownerOf[tokenId] = address(0);\r
balanceOf[tokenOwner]--;\r
emit Transfer(tokenOwner, address(0), tokenId);\r
}\r
\r
function approve(address to, uint256 tokenId) external {\r
address tokenOwner = ownerOf[tokenId];\r
require(tokenOwner == msg.sender || isApprovedForAll[tokenOwner][msg.sender], "Not authorized");\r
getApproved[tokenId] = to;\r
emit Approval(tokenOwner, to, tokenId);\r
}\r
\r
function setApprovalForAll(address operator, bool approved) external {\r
isApprovedForAll[msg.sender][operator] = approved;\r
emit ApprovalForAll(msg.sender, operator, approved);\r
}\r
\r
function transferFrom(address from, address to, uint256 tokenId) external {\r
require(ownerOf[tokenId] == from, "Not token owner");\r
require(to != address(0), "Transfer to zero address");\r
require(\r
msg.sender == from || \r
getApproved[tokenId] == msg.sender || \r
isApprovedForAll[from][msg.sender], \r
"Not authorized"\r
);\r
\r
ownerOf[tokenId] = to;\r
balanceOf[from]--;\r
balanceOf[to]++;\r
getApproved[tokenId] = address(0);\r
emit Transfer(from, to, tokenId);\r
}\r
}\r
\r
/**\r
* @title ERC1155Token\r
* @notice Basic ERC1155 implementation\r
*/\r
contract ERC1155Token is Ownable {\r
string public uri;\r
bytes public assetData;\r
bool private _initialized;\r
\r
mapping(uint256 => mapping(address => uint256)) public balanceOf;\r
mapping(address => mapping(address => bool)) public isApprovedForAll;\r
\r
event TransferSingle(\r
address indexed operator,\r
address indexed from,\r
address indexed to,\r
uint256 id,\r
uint256 value\r
);\r
event TransferBatch(\r
address indexed operator,\r
address indexed from,\r
address indexed to,\r
uint256[] ids,\r
uint256[] values\r
);\r
event ApprovalForAll(address indexed account, address indexed operator, bool approved);\r
event URI(string value, uint256 indexed id);\r
\r
constructor() Ownable(msg.sender) {}\r
\r
function initialize(\r
string memory tokenUri,\r
bytes memory tokenAssetData\r
) external {\r
require(!_initialized, "Already initialized");\r
uri = tokenUri;\r
assetData = tokenAssetData;\r
_initialized = true;\r
}\r
\r
function mint(\r
address to,\r
uint256 id,\r
uint256 amount,\r
bytes memory /* data */\r
) external onlyOwner {\r
require(to != address(0), "Mint to zero address");\r
balanceOf[id][to] += amount;\r
emit TransferSingle(msg.sender, address(0), to, id, amount);\r
}\r
\r
function mintBatch(\r
address to,\r
uint256[] memory ids,\r
uint256[] memory amounts,\r
bytes memory /* data */\r
) external onlyOwner {\r
require(to != address(0), "Mint to zero address");\r
require(ids.length == amounts.length, "Arrays length mismatch");\r
\r
for (uint256 i = 0; i < ids.length; i++) {\r
balanceOf[ids[i]][to] += amounts[i];\r
}\r
emit TransferBatch(msg.sender, address(0), to, ids, amounts);\r
}\r
\r
function setApprovalForAll(address operator, bool approved) external {\r
isApprovedForAll[msg.sender][operator] = approved;\r
emit ApprovalForAll(msg.sender, operator, approved);\r
}\r
\r
function safeTransferFrom(\r
address from,\r
address to,\r
uint256 id,\r
uint256 amount,\r
bytes memory /* data */\r
) external {\r
require(to != address(0), "Transfer to zero address");\r
require(\r
from == msg.sender || isApprovedForAll[from][msg.sender],\r
"Not authorized"\r
);\r
\r
balanceOf[id][from] -= amount;\r
balanceOf[id][to] += amount;\r
emit TransferSingle(msg.sender, from, to, id, amount);\r
}\r
}\r
\r
/**\r
* @title ERC3643Token\r
* @notice Basic ERC3643 implementation for regulated tokens\r
*/\r
contract ERC3643Token is Ownable {\r
string public name;\r
string public symbol;\r
uint8 public decimals;\r
uint256 public totalSupply;\r
bool public kycRequired;\r
bool public whitelistOnly;\r
bytes public assetData;\r
bool private _initialized;\r
\r
mapping(address => uint256) public balanceOf;\r
mapping(address => mapping(address => uint256)) public allowance;\r
mapping(address => bool) public whitelisted;\r
mapping(address => bool) public kycVerified;\r
\r
event Transfer(address indexed from, address indexed to, uint256 value);\r
event Approval(address indexed owner, address indexed spender, uint256 value);\r
\r
constructor(string memory _name, string memory _symbol) Ownable(msg.sender) {\r
name = _name;\r
symbol = _symbol;\r
}\r
\r
function initialize(\r
string memory tokenName,\r
string memory tokenSymbol,\r
uint8 tokenDecimals,\r
address tokenOwner,\r
bool tokenKycRequired,\r
bool tokenWhitelistOnly,\r
bytes memory tokenAssetData\r
) external {\r
require(!_initialized, "Already initialized");\r
_transferOwnership(tokenOwner);\r
name = tokenName;\r
symbol = tokenSymbol;\r
decimals = tokenDecimals;\r
kycRequired = tokenKycRequired;\r
whitelistOnly = tokenWhitelistOnly;\r
assetData = tokenAssetData;\r
_initialized = true;\r
}\r
\r
function mint(address to, uint256 amount) external onlyOwner {\r
require(to != address(0), "Mint to zero address");\r
require(_canTransfer(to), "Transfer not allowed");\r
totalSupply += amount;\r
balanceOf[to] += amount;\r
emit Transfer(address(0), to, amount);\r
}\r
\r
function burn(uint256 amount) external {\r
require(balanceOf[msg.sender] >= amount, "Insufficient balance");\r
balanceOf[msg.sender] -= amount;\r
totalSupply -= amount;\r
emit Transfer(msg.sender, address(0), amount);\r
}\r
\r
function transfer(address to, uint256 amount) external returns (bool) {\r
require(to != address(0), "Transfer to zero address");\r
require(balanceOf[msg.sender] >= amount, "Insufficient balance");\r
require(_canTransfer(msg.sender), "Transfer not allowed");\r
require(_canTransfer(to), "Transfer not allowed");\r
\r
balanceOf[msg.sender] -= amount;\r
balanceOf[to] += amount;\r
emit Transfer(msg.sender, to, amount);\r
return true;\r
}\r
\r
function approve(address spender, uint256 amount) external returns (bool) {\r
allowance[msg.sender][spender] = amount;\r
emit Approval(msg.sender, spender, amount);\r
return true;\r
}\r
\r
function transferFrom(address from, address to, uint256 amount) external returns (bool) {\r
require(to != address(0), "Transfer to zero address");\r
require(balanceOf[from] >= amount, "Insufficient balance");\r
require(allowance[from][msg.sender] >= amount, "Insufficient allowance");\r
require(_canTransfer(from), "Transfer not allowed");\r
require(_canTransfer(to), "Transfer not allowed");\r
\r
balanceOf[from] -= amount;\r
balanceOf[to] += amount;\r
allowance[from][msg.sender] -= amount;\r
emit Transfer(from, to, amount);\r
return true;\r
}\r
\r
function _canTransfer(address account) internal view returns (bool) {\r
if (kycRequired && !kycVerified[account]) return false;\r
if (whitelistOnly && !whitelisted[account]) return false;\r
return true;\r
}\r
\r
function setKYC(address account, bool verified) external onlyOwner {\r
kycVerified[account] = verified;\r
}\r
\r
function setWhitelist(address account, bool allowed) external onlyOwner {\r
whitelisted[account] = allowed;\r
}\r
}\r
"
}
},
"settings": {
"optimizer": {
"enabled": true,
"runs": 200
},
"viaIR": true,
"evmVersion": "paris",
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
}
}
}}
Submitted on: 2025-10-16 14:43:37
Comments
Log in to comment.
No comments yet.