├── OpenWeb3DaoContracts ├── OW3Dao.sol └── OW3Token.sol ├── README.md └── Templates └── Contracts ├── ManagerStarter ├── ManagedERC20.sol └── Manager&ERC721.sol ├── Standars ├── ERC20template.sol └── ERC721template.sol └── basic ├── forum.sol ├── hello_world.sol └── notary.sol /OpenWeb3DaoContracts/OW3Dao.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity >=0.7.0 <0.9.0; 4 | 5 | 6 | import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol"; 7 | 8 | 9 | interface IERC20 { 10 | /** 11 | * @dev Emitted when `value` tokens are moved from one account (`from`) to 12 | * another (`to`). 13 | * 14 | * Note that `value` may be zero. 15 | */ 16 | event Transfer(address indexed from, address indexed to, uint256 value); 17 | 18 | /** 19 | * @dev Emitted when the allowance of a `spender` for an `owner` is set by 20 | * a call to {approve}. `value` is the new allowance. 21 | */ 22 | event Approval(address indexed owner, address indexed spender, uint256 value); 23 | 24 | /** 25 | * @dev Returns the amount of tokens in existence. 26 | */ 27 | function totalSupply() external view returns (uint256); 28 | 29 | /** 30 | * @dev Returns the amount of tokens owned by `account`. 31 | */ 32 | function balanceOf(address account) external view returns (uint256); 33 | 34 | /** 35 | * @dev Moves `amount` tokens from the caller's account to `to`. 36 | * 37 | * Returns a boolean value indicating whether the operation succeeded. 38 | * 39 | * Emits a {Transfer} event. 40 | */ 41 | function transfer(address to, uint256 amount) external returns (bool); 42 | 43 | /** 44 | * @dev Returns the remaining number of tokens that `spender` will be 45 | * allowed to spend on behalf of `owner` through {transferFrom}. This is 46 | * zero by default. 47 | * 48 | * This value changes when {approve} or {transferFrom} are called. 49 | */ 50 | function allowance(address owner, address spender) external view returns (uint256); 51 | 52 | /** 53 | * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. 54 | * 55 | * Returns a boolean value indicating whether the operation succeeded. 56 | * 57 | * IMPORTANT: Beware that changing an allowance with this method brings the risk 58 | * that someone may use both the old and the new allowance by unfortunate 59 | * transaction ordering. One possible solution to mitigate this race 60 | * condition is to first reduce the spender's allowance to 0 and set the 61 | * desired value afterwards: 62 | * htOW3s://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 63 | * 64 | * Emits an {Approval} event. 65 | */ 66 | function approve(address spender, uint256 amount) external returns (bool); 67 | 68 | /** 69 | * @dev Moves `amount` tokens from `from` to `to` using the 70 | * allowance mechanism. `amount` is then deducted from the caller's 71 | * allowance. 72 | * 73 | * Returns a boolean value indicating whether the operation succeeded. 74 | * 75 | * Emits a {Transfer} event. 76 | */ 77 | function transferFrom( 78 | address from, 79 | address to, 80 | uint256 amount 81 | ) external returns (bool); 82 | function manager_mint(address receiver_,uint amount_) external; 83 | function burn(address _redeemAddress, uint256 _amount) external; 84 | } 85 | 86 | contract OW3NFTs is ERC721Enumerable { 87 | 88 | uint public totalMinted; //Cantidad total Minteada 89 | 90 | string InitName = "OW3NFTs"; 91 | string InitSymbol = "OW3"; 92 | string public licence_URI; 93 | IERC20 public ERC20Contract; 94 | IERC20 public cUSD; 95 | 96 | mapping (address => bool) public autorized; 97 | mapping (address => bool) public whitelist; 98 | mapping (uint => string) public NFTID2URI; 99 | 100 | 101 | constructor(string memory _licence_URI, address _cUSD_address) ERC721(InitName, InitSymbol) { 102 | licence_URI=_licence_URI; 103 | autorized[msg.sender]=true; 104 | cUSD = IERC20(_cUSD_address); 105 | } 106 | 107 | function autorizeAddress(address _address) public onlyAutorized{ 108 | autorized[_address]=true; 109 | } 110 | function whitelistAddress(address _address) public onlyAutorized{ 111 | whitelist[_address]=true; 112 | } 113 | 114 | modifier onlyAutorized(){ 115 | require(autorized[msg.sender],"Only autorized"); 116 | _; 117 | } 118 | modifier onlyWhitelist(address address_){ 119 | require(whitelist[address_],"Only whitelisted"); 120 | _; 121 | } 122 | 123 | function setup_OW3ERC20(address _ERC20_add) public onlyAutorized{ 124 | ERC20Contract=IERC20(_ERC20_add); 125 | } 126 | 127 | function walletOfOwner(address _owner) 128 | public 129 | view 130 | returns (uint256[] memory) 131 | { 132 | uint256 ownerTokenCount = balanceOf(_owner); 133 | uint256[] memory tokenIds = new uint256[](ownerTokenCount); 134 | for (uint256 i; i < ownerTokenCount; i++) { 135 | tokenIds[i] = tokenOfOwnerByIndex(_owner, i); 136 | } 137 | return tokenIds; 138 | } 139 | 140 | function tokenURI(uint256 token_Id) 141 | public 142 | view 143 | virtual 144 | override 145 | returns (string memory) 146 | { 147 | require( 148 | _exists(token_Id), 149 | "ERC721Metadata: URI query for nonexistent token" 150 | ); 151 | return licence_URI; 152 | } 153 | function change_licenseURI(uint256 _token_Id, string memory _newURI) public onlyAutorized{ 154 | NFTID2URI[_token_Id]=_newURI; 155 | } 156 | struct proposal{ 157 | string name; 158 | uint value; 159 | bool state; 160 | bool cUSD; 161 | address owner; 162 | } 163 | proposal[] public proposals; 164 | function new_proposal(string memory _name) public payable { 165 | proposals.push(proposal(_name,msg.value,false,false,msg.sender)); 166 | ERC20Contract.manager_mint(msg.sender,msg.value/4); 167 | } 168 | function new_proposal_cUSD(string memory _name, uint _cUSD_value) public { 169 | require(cUSD.balanceOf(_msgSender())>=_cUSD_value,"not enough cUSD"); 170 | cUSD.transfer(address(this),_cUSD_value); 171 | proposals.push(proposal(_name,_cUSD_value,false,true,msg.sender)); 172 | } 173 | function proposal_solution(uint _proposal_id, address _receiver)public { 174 | require(proposals[_proposal_id].owner==msg.sender,"only proposal creator can resolute"); 175 | require(proposals[_proposal_id].state==false,"proposal already solved"); 176 | if(proposals[_proposal_id].cUSD){ 177 | cUSD.transferFrom(address(this),_msgSender(),proposals[_proposal_id].value); 178 | } 179 | else{ 180 | ERC20Contract.manager_mint(_receiver,proposals[_proposal_id].value*3/4); 181 | } 182 | proposals[_proposal_id].state=true; 183 | } 184 | function free_code_copyright() public payable{ 185 | require(msg.value>=10 * 10 ** 18,"minimun license doantion is 100 Celo"); 186 | uint256 supply = totalSupply(); 187 | totalMinted++; 188 | _safeMint(msg.sender, supply + 1); 189 | } 190 | function get_token_price() public view returns(uint _price) { 191 | return address(this).balance/ERC20Contract.totalSupply(); 192 | } 193 | function sell_tokens(uint _amount) public { 194 | require(ERC20Contract.balanceOf(_msgSender())>=_amount,"amount to sell grater than balance"); 195 | ERC20Contract.burn(_msgSender(),_amount); 196 | payable(_msgSender()).transfer(_amount*get_token_price()); 197 | } 198 | } 199 | -------------------------------------------------------------------------------- /OpenWeb3DaoContracts/OW3Token.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/ERC20.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; 7 | import "@openzeppelin/contracts/utils/Context.sol"; 8 | 9 | contract Ownable is Context { 10 | address public _owner; 11 | address private _previousOwner; 12 | uint256 private _lockTime; 13 | 14 | 15 | event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); 16 | 17 | /** 18 | * @dev Initializes the contract setting the deployer as the initial owner. 19 | */ 20 | /** 21 | * @dev Returns the address of the current owner. 22 | */ 23 | function owner() public view returns (address) { 24 | return _owner; 25 | } 26 | 27 | /** 28 | * @dev Throws if called by any account other than the owner. 29 | */ 30 | modifier onlyOwner() { 31 | require(_owner == _msgSender(), "Ownable: caller is not the owner"); 32 | _; 33 | } 34 | 35 | /** 36 | * @dev Leaves the contract without owner. It will not be possible to call 37 | * `onlyOwner` functions anymore. Can only be called by the current owner. 38 | * 39 | * NOTE: Renouncing ownership will leave the contract without an owner, 40 | * thereby removing any functionality that is only available to the owner. 41 | */ 42 | function renounceOwnership() public virtual onlyOwner { 43 | emit OwnershipTransferred(_owner, address(0)); 44 | _owner = address(0); 45 | } 46 | 47 | /** 48 | * @dev Transfers ownership of the contract to a new account (`newOwner`). 49 | * Can only be called by the current owner. 50 | */ 51 | function transferOwnership(address newOwner) public virtual onlyOwner { 52 | require(newOwner != address(0), "Ownable: new owner is the zero address"); 53 | emit OwnershipTransferred(_owner, newOwner); 54 | _owner = newOwner; 55 | } 56 | 57 | function geUnlockTime() public view returns (uint256) { 58 | return _lockTime; 59 | } 60 | 61 | //Locks the contract for owner for the amount of time provided 62 | function lock(uint256 time) public virtual onlyOwner { 63 | _previousOwner = _owner; 64 | _owner = address(0); 65 | _lockTime = block.timestamp + time; 66 | emit OwnershipTransferred(_owner, address(0)); 67 | } 68 | 69 | //Unlocks the contract for owner when _lockTime is exceeds 70 | function unlock() public virtual { 71 | require(_previousOwner == msg.sender, "You don't have permission to unlock"); 72 | require(block.timestamp > _lockTime , "Contract is locked until 7 days"); 73 | emit OwnershipTransferred(_owner, _previousOwner); 74 | _owner = _previousOwner; 75 | } 76 | 77 | } 78 | 79 | contract OW3Token is ERC20, Ownable{ 80 | string InitName = "OW3NFTs"; //Nombre en el estandar ERC721 81 | string InitSymbol = "OW3"; //Simbolo disponible en el estandar ERC721 82 | constructor(address _manager_address) ERC20(InitName, InitSymbol){ 83 | _owner=_manager_address; 84 | } 85 | function manager_mint(address receiver_,uint amount_) public onlyOwner{ 86 | _mint(receiver_,amount_); 87 | } 88 | function burn(address _redeemAddress, uint256 _amount) public onlyOwner { 89 | _burn(_redeemAddress, _amount); 90 | } 91 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | 22 | readme 23 | -------------------------------------------------------------------------------- /Templates/Contracts/ManagerStarter/ManagedERC20.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/ERC20.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; 7 | import "@openzeppelin/contracts/utils/Context.sol"; 8 | 9 | contract Ownable is Context { 10 | address public _owner; 11 | address private _previousOwner; 12 | uint256 private _lockTime; 13 | 14 | 15 | event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); 16 | 17 | /** 18 | * @dev Initializes the contract setting the deployer as the initial owner. 19 | */ 20 | /** 21 | * @dev Returns the address of the current owner. 22 | */ 23 | function owner() public view returns (address) { 24 | return _owner; 25 | } 26 | 27 | /** 28 | * @dev Throws if called by any account other than the owner. 29 | */ 30 | modifier onlyOwner() { 31 | require(_owner == _msgSender(), "Ownable: caller is not the owner"); 32 | _; 33 | } 34 | 35 | /** 36 | * @dev Leaves the contract without owner. It will not be possible to call 37 | * `onlyOwner` functions anymore. Can only be called by the current owner. 38 | * 39 | * NOTE: Renouncing ownership will leave the contract without an owner, 40 | * thereby removing any functionality that is only available to the owner. 41 | */ 42 | function renounceOwnership() public virtual onlyOwner { 43 | emit OwnershipTransferred(_owner, address(0)); 44 | _owner = address(0); 45 | } 46 | 47 | /** 48 | * @dev Transfers ownership of the contract to a new account (`newOwner`). 49 | * Can only be called by the current owner. 50 | */ 51 | function transferOwnership(address newOwner) public virtual onlyOwner { 52 | require(newOwner != address(0), "Ownable: new owner is the zero address"); 53 | emit OwnershipTransferred(_owner, newOwner); 54 | _owner = newOwner; 55 | } 56 | 57 | function geUnlockTime() public view returns (uint256) { 58 | return _lockTime; 59 | } 60 | 61 | //Locks the contract for owner for the amount of time provided 62 | function lock(uint256 time) public virtual onlyOwner { 63 | _previousOwner = _owner; 64 | _owner = address(0); 65 | _lockTime = block.timestamp + time; 66 | emit OwnershipTransferred(_owner, address(0)); 67 | } 68 | 69 | //Unlocks the contract for owner when _lockTime is exceeds 70 | function unlock() public virtual { 71 | require(_previousOwner == msg.sender, "You don't have permission to unlock"); 72 | require(block.timestamp > _lockTime , "Contract is locked until 7 days"); 73 | emit OwnershipTransferred(_owner, _previousOwner); 74 | _owner = _previousOwner; 75 | } 76 | 77 | } 78 | 79 | contract OW3Token is ERC20, Ownable{ 80 | string InitName = "OW3NFTs"; //Nombre en el estandar ERC721 81 | string InitSymbol = "OW3"; //Simbolo disponible en el estandar ERC721 82 | constructor(address _manager_address) ERC20(InitName, InitSymbol){ 83 | _owner=_manager_address; 84 | } 85 | function manager_mint(address receiver_,uint amount_) public onlyOwner{ 86 | _mint(receiver_,amount_); 87 | } 88 | function burn(address _redeemAddress, uint256 _amount) public onlyOwner { 89 | _burn(_redeemAddress, _amount); 90 | } 91 | } -------------------------------------------------------------------------------- /Templates/Contracts/ManagerStarter/Manager&ERC721.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity >=0.7.0 <0.9.0; 4 | 5 | 6 | import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol"; 7 | 8 | 9 | interface IERC20 { 10 | /** 11 | * @dev Emitted when `value` tokens are moved from one account (`from`) to 12 | * another (`to`). 13 | * 14 | * Note that `value` may be zero. 15 | */ 16 | event Transfer(address indexed from, address indexed to, uint256 value); 17 | 18 | /** 19 | * @dev Emitted when the allowance of a `spender` for an `owner` is set by 20 | * a call to {approve}. `value` is the new allowance. 21 | */ 22 | event Approval(address indexed owner, address indexed spender, uint256 value); 23 | 24 | /** 25 | * @dev Returns the amount of tokens in existence. 26 | */ 27 | function totalSupply() external view returns (uint256); 28 | 29 | /** 30 | * @dev Returns the amount of tokens owned by `account`. 31 | */ 32 | function balanceOf(address account) external view returns (uint256); 33 | 34 | /** 35 | * @dev Moves `amount` tokens from the caller's account to `to`. 36 | * 37 | * Returns a boolean value indicating whether the operation succeeded. 38 | * 39 | * Emits a {Transfer} event. 40 | */ 41 | function transfer(address to, uint256 amount) external returns (bool); 42 | 43 | /** 44 | * @dev Returns the remaining number of tokens that `spender` will be 45 | * allowed to spend on behalf of `owner` through {transferFrom}. This is 46 | * zero by default. 47 | * 48 | * This value changes when {approve} or {transferFrom} are called. 49 | */ 50 | function allowance(address owner, address spender) external view returns (uint256); 51 | 52 | /** 53 | * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. 54 | * 55 | * Returns a boolean value indicating whether the operation succeeded. 56 | * 57 | * IMPORTANT: Beware that changing an allowance with this method brings the risk 58 | * that someone may use both the old and the new allowance by unfortunate 59 | * transaction ordering. One possible solution to mitigate this race 60 | * condition is to first reduce the spender's allowance to 0 and set the 61 | * desired value afterwards: 62 | * htOW3s://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 63 | * 64 | * Emits an {Approval} event. 65 | */ 66 | function approve(address spender, uint256 amount) external returns (bool); 67 | 68 | /** 69 | * @dev Moves `amount` tokens from `from` to `to` using the 70 | * allowance mechanism. `amount` is then deducted from the caller's 71 | * allowance. 72 | * 73 | * Returns a boolean value indicating whether the operation succeeded. 74 | * 75 | * Emits a {Transfer} event. 76 | */ 77 | function transferFrom( 78 | address from, 79 | address to, 80 | uint256 amount 81 | ) external returns (bool); 82 | function manager_mint(address receiver_,uint amount_) external; 83 | function burn(address _redeemAddress, uint256 _amount) external; 84 | } 85 | 86 | contract OW3NFTs is ERC721Enumerable { 87 | 88 | uint public totalMinted; //Cantidad total Minteada 89 | 90 | string InitName = "OW3NFTs"; 91 | string InitSymbol = "OW3"; 92 | IERC20 public ERC20Contract; 93 | mapping (address => bool) public autorized; 94 | mapping (address => bool) public whitelist; 95 | mapping (uint => string) public NFTID2URI; 96 | 97 | 98 | constructor() ERC721(InitName, InitSymbol) { 99 | autorized[msg.sender]=true; 100 | } 101 | 102 | function autorizeAddress(address _address) public onlyAutorized{ 103 | autorized[_address]=true; 104 | } 105 | function whitelistAddress(address _address) public onlyAutorized{ 106 | whitelist[_address]=true; 107 | } 108 | 109 | modifier onlyAutorized(){ 110 | require(autorized[msg.sender],"Only autorized"); 111 | _; 112 | } 113 | modifier onlyWhitelist(address address_){ 114 | require(whitelist[address_],"Only whitelisted"); 115 | _; 116 | } 117 | 118 | function setup_OW3ERC20(address _ERC20_add) public onlyAutorized{ 119 | ERC20Contract=IERC20(_ERC20_add); 120 | } 121 | function mint_OW3ERC20(address receiver_, uint amount_) public onlyAutorized onlyWhitelist(receiver_){ 122 | ERC20Contract.manager_mint(receiver_,amount_); 123 | } 124 | function mintOW3NFT(address receiver_,string memory _license_URI) public onlyAutorized onlyWhitelist(receiver_) { 125 | uint256 supply = totalSupply(); 126 | totalMinted++; 127 | NFTID2URI[supply+1]=_license_URI; 128 | _safeMint(receiver_, supply + 1); 129 | } 130 | 131 | function walletOfOwner(address _owner) 132 | public 133 | view 134 | returns (uint256[] memory) 135 | { 136 | uint256 ownerTokenCount = balanceOf(_owner); 137 | uint256[] memory tokenIds = new uint256[](ownerTokenCount); 138 | for (uint256 i; i < ownerTokenCount; i++) { 139 | tokenIds[i] = tokenOfOwnerByIndex(_owner, i); 140 | } 141 | return tokenIds; 142 | } 143 | 144 | function tokenURI(uint256 token_Id) 145 | public 146 | view 147 | virtual 148 | override 149 | returns (string memory) 150 | { 151 | require( 152 | _exists(token_Id), 153 | "ERC721Metadata: URI query for nonexistent token" 154 | ); 155 | return NFTID2URI[token_Id]; 156 | } 157 | function change_licenseURI(uint256 _token_Id, string memory _newURI) public onlyAutorized{ 158 | NFTID2URI[_token_Id]=_newURI; 159 | } 160 | 161 | } 162 | -------------------------------------------------------------------------------- /Templates/Contracts/Standars/ERC20template.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/ERC20.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; 7 | import "@openzeppelin/contracts/utils/Context.sol"; 8 | 9 | contract Ownable is Context { 10 | address public _owner; 11 | address private _previousOwner; 12 | uint256 private _lockTime; 13 | 14 | 15 | event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); 16 | 17 | /** 18 | * @dev Initializes the contract setting the deployer as the initial owner. 19 | */ 20 | /** 21 | * @dev Returns the address of the current owner. 22 | */ 23 | function owner() public view returns (address) { 24 | return _owner; 25 | } 26 | 27 | /** 28 | * @dev Throws if called by any account other than the owner. 29 | */ 30 | modifier onlyOwner() { 31 | require(_owner == _msgSender(), "Ownable: caller is not the owner"); 32 | _; 33 | } 34 | 35 | /** 36 | * @dev Leaves the contract without owner. It will not be possible to call 37 | * `onlyOwner` functions anymore. Can only be called by the current owner. 38 | * 39 | * NOTE: Renouncing ownership will leave the contract without an owner, 40 | * thereby removing any functionality that is only available to the owner. 41 | */ 42 | function renounceOwnership() public virtual onlyOwner { 43 | emit OwnershipTransferred(_owner, address(0)); 44 | _owner = address(0); 45 | } 46 | 47 | /** 48 | * @dev Transfers ownership of the contract to a new account (`newOwner`). 49 | * Can only be called by the current owner. 50 | */ 51 | function transferOwnership(address newOwner) public virtual onlyOwner { 52 | require(newOwner != address(0), "Ownable: new owner is the zero address"); 53 | emit OwnershipTransferred(_owner, newOwner); 54 | _owner = newOwner; 55 | } 56 | 57 | function geUnlockTime() public view returns (uint256) { 58 | return _lockTime; 59 | } 60 | 61 | //Locks the contract for owner for the amount of time provided 62 | function lock(uint256 time) public virtual onlyOwner { 63 | _previousOwner = _owner; 64 | _owner = address(0); 65 | _lockTime = block.timestamp + time; 66 | emit OwnershipTransferred(_owner, address(0)); 67 | } 68 | 69 | //Unlocks the contract for owner when _lockTime is exceeds 70 | function unlock() public virtual { 71 | require(_previousOwner == msg.sender, "You don't have permission to unlock"); 72 | require(block.timestamp > _lockTime , "Contract is locked until 7 days"); 73 | emit OwnershipTransferred(_owner, _previousOwner); 74 | _owner = _previousOwner; 75 | } 76 | 77 | } 78 | 79 | contract OW3Token is ERC20, Ownable{ 80 | string InitName = "OW3NFTs"; //Nombre en el estandar ERC721 81 | string InitSymbol = "OW3"; //Simbolo disponible en el estandar ERC721 82 | constructor() ERC20(InitName, InitSymbol){ 83 | _owner=_msgSender(); 84 | } 85 | function manager_mint(address receiver_,uint amount_) public onlyOwner{ 86 | _mint(receiver_,amount_); 87 | } 88 | function burn(address _redeemAddress, uint256 _amount) public onlyOwner { 89 | _burn(_redeemAddress, _amount); 90 | } 91 | } -------------------------------------------------------------------------------- /Templates/Contracts/Standars/ERC721template.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity >=0.7.0 <0.9.0; 4 | 5 | import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol"; 6 | 7 | contract OW3NFTs is ERC721Enumerable { 8 | 9 | uint public totalMinted; 10 | mapping (address => bool) public autorized; 11 | using Strings for uint256; 12 | string InitName = "OW3NFTs"; 13 | string InitSymbol = "OW3"; 14 | uint256 specialMinted; 15 | uint256 founderPercentage=10; 16 | address royaltyReceiver; 17 | mapping (uint => string) public ID2URI; 18 | 19 | constructor() ERC721(InitName, InitSymbol) { 20 | autorized[msg.sender]=true; 21 | royaltyReceiver=msg.sender; 22 | } 23 | 24 | function autorizeAddress(address _address) public onlyAutorized{ 25 | autorized[_address]=true; 26 | } 27 | 28 | modifier onlyAutorized(){ 29 | require(autorized[msg.sender],"Only autorized"); 30 | _; 31 | } 32 | 33 | function mint(address _to, string memory _specialURI) public onlyAutorized { 34 | uint256 supply = totalSupply(); 35 | totalMinted++; 36 | ID2URI[supply+1]=_specialURI; 37 | _safeMint(_to, supply + 1); 38 | } 39 | 40 | function walletOfOwner(address _owner) 41 | public 42 | view 43 | returns (uint256[] memory) 44 | { 45 | uint256 ownerTokenCount = balanceOf(_owner); 46 | uint256[] memory tokenIds = new uint256[](ownerTokenCount); 47 | for (uint256 i; i < ownerTokenCount; i++) { 48 | tokenIds[i] = tokenOfOwnerByIndex(_owner, i); 49 | } 50 | return tokenIds; 51 | } 52 | 53 | function tokenURI(uint256 _tokenId) 54 | public 55 | view 56 | virtual 57 | override 58 | returns (string memory) 59 | { 60 | require( 61 | _exists(_tokenId), 62 | "ERC721Metadata: URI query for nonexistent token" 63 | ); 64 | return ID2URI[_tokenId]; 65 | } 66 | function change_tokenURI(uint256 _tokenId, string memory _newURI) public onlyAutorized{ 67 | require(_exists(_tokenId),"ERC721Metadata: URI query for nonexistent token"); 68 | ID2URI[_tokenId]=_newURI; 69 | } 70 | function royaltyInfo(uint256 _tokenId,uint256 _salePrice) public view returns (address receiver, uint256 royaltyAmount){ 71 | _tokenId+0; 72 | return(royaltyReceiver, _salePrice*(founderPercentage)/100); 73 | } 74 | function changeRoyaltyFounderInfo(address _royaltyReceiver) public onlyAutorized{ 75 | royaltyReceiver=_royaltyReceiver; 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /Templates/Contracts/basic/forum.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.4.22; 4 | 5 | contract Greeter { 6 | string greeting; 7 | address owner; 8 | address owner_message; 9 | uint public total_mensajes; 10 | 11 | modifier onlyOwner { 12 | require(isOwner(), "Only owner can do that!"); 13 | _; 14 | } 15 | 16 | constructor(string _greeting) public { 17 | greeting = _greeting; 18 | owner = msg.sender; 19 | } 20 | 21 | struct log{ 22 | string mensaje; 23 | address owner; 24 | } 25 | 26 | log[] public mensajes; 27 | 28 | 29 | function sayHello() public view returns(string, address) { 30 | if (isOwner()) { 31 | return ("Hey daddy!",owner); 32 | } else { 33 | return (greeting, owner_message); 34 | } 35 | } 36 | 37 | function setGreeting(string _newGreeting) public { 38 | mensajes.push(log(_newGreeting,msg.sender)); 39 | greeting= _newGreeting; 40 | owner_message=msg.sender; 41 | total_mensajes++; 42 | } 43 | 44 | function isOwner() view private returns(bool) { 45 | return msg.sender == owner; 46 | } 47 | } -------------------------------------------------------------------------------- /Templates/Contracts/basic/hello_world.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity >= 0.7.4; 3 | 4 | contract Inbox{ // defino que mi contrato se va a llamar Inbox 5 | string public message; // variable donde se almacena la información 6 | 7 | constructor (string memory initialMessage) { // este es el método constructor donde inicializo el contrato con un mensaje 8 | message = initialMessage; 9 | } 10 | 11 | function setMessage(string memory newMessage) public { // esta función permite reemplazar el mensaje almacenada en la variable message 12 | message = newMessage; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Templates/Contracts/basic/notary.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity >=0.7.0 <0.9.0; 3 | 4 | contract CertiBits{ // defino que mi contrato se va a llamar Inbox 5 | uint public totalCertiBits; // variable donde se almacena la información 6 | address owner; 7 | mapping (string => address[]) public hash2addressList; 8 | mapping (address => mapping(string => bool)) address2hashstate; 9 | constructor () { // este es el metodo constructor donde inicializo el contrato con un mensaje 10 | owner = msg.sender; 11 | } 12 | 13 | uint IDu; 14 | 15 | function isOwner() view private returns(bool) { 16 | return msg.sender == owner; 17 | } 18 | 19 | modifier onlyOwner { 20 | require(isOwner(), "Only owner can do that!"); 21 | _; 22 | } 23 | 24 | struct user { 25 | string name; 26 | string id; 27 | string email; 28 | address owner; 29 | } 30 | user[] private users; 31 | mapping (address => uint) pubkey2IDu; 32 | mapping (address => bool) public address2state; 33 | mapping (address => uint) signatures; 34 | function new_user(string memory _name, string memory _id, string memory _email, address _owner) public onlyOwner{ 35 | users.push(user(_name,_id,_email,_owner)); 36 | pubkey2IDu[_owner]=IDu; 37 | IDu+=1; 38 | address2state[_owner]=true; 39 | } 40 | function Certify(string memory _hash) public { // esta función permite reemplazar el mensaje almacenada en la variable message 41 | require(address2state[msg.sender],"Address not subscribed to the contract"); 42 | require(!address2hashstate[msg.sender][_hash],"Address already signed these hash"); 43 | require(signatures[msg.sender]>=1,"no balance"); 44 | signatures[msg.sender]-=1; 45 | address2hashstate[msg.sender][_hash]=true; 46 | hash2addressList[_hash].push(msg.sender); 47 | totalCertiBits++; 48 | } 49 | function recharge(uint _value) public payable{ 50 | require(_value>0,"recharge value must be positive"); 51 | require(msg.value==1000000000000000000*_value,"pay must be 1 Celo per signature"); 52 | signatures[msg.sender]+=_value; 53 | } 54 | function validate_address_hash(address _address, string memory _hash) public view returns(string memory name_, string memory id_,string memory email__, address owner_ ) { 55 | require(address2hashstate[msg.sender][_hash]&&address2hashstate[_address][_hash],"need to share hash to see personal data"); 56 | return(users[pubkey2IDu[_address]].name,users[pubkey2IDu[_address]].id,users[pubkey2IDu[_address]].email,users[pubkey2IDu[_address]].owner); 57 | } 58 | } --------------------------------------------------------------------------------