Skip to content

Latest commit

 

History

History
279 lines (222 loc) · 9.53 KB

Solidity Programmer.md

File metadata and controls

279 lines (222 loc) · 9.53 KB

GPT名称:Solidity Programmer

访问链接

简介:编写代码。构建Dapps。进行审核。

头像


1. **CustomContract.pdf:**

// SPDX-License-Identifier: MIT pragma solidity ^0.8.20;

import "@openzeppelin/contracts-upgradeable/utils/PausableUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/access/manager/AccessManagedUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";

contract MyContract is Initializable, PausableUpgradeable, AccessManagedUpgradeable { /// @custom:oz-upgrades-unsafe-allow constructor constructor() { _disableInitializers(); }

   function initialize(address initialAuthority) initializer public {
       __Pausable_init();
       __AccessManaged_init(initialAuthority);
   }

   function pause() public restricted {
       _pause();
   }

   function unpause() public restricted {
       _unpause();
   }

}


2. **Governor.pdf:**

// SPDX-License-Identifier: MIT pragma solidity ^0.8.20;

import "@openzeppelin/contracts-upgradeable/governance/GovernorUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/governance/extensions/GovernorSettingsUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/governance/extensions/GovernorCountingSimpleUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/governance/extensions/GovernorStorageUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/governance/extensions/GovernorVotesUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/governance/extensions/GovernorVotesQuorumFractionUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/governance/extensions/GovernorTimelockControlUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";

contract MyGovernor is Initializable, GovernorUpgradeable, GovernorSettingsUpgradeable, GovernorCountingSimpleUpgradeable, GovernorStorageUpgradeable, GovernorVotesUpgradeable, GovernorVotesQuorumFractionUpgradeable, GovernorTimelockControlUpgradeable, OwnableUpgradeable, UUPSUpgradeable { /// @custom:oz-upgrades-unsafe-allow constructor constructor() { _disableInitializers(); }

   function initialize(IVotes _token, TimelockControllerUpgradeable _timelock, address initialOwner)
   initializer public { 
       __Governor_init("MyGovernor");
       __GovernorSettings_init(7200 /* 1 day */, 50400 /* 1 week */, 100000e18);
       __GovernorCountingSimple_init();
       __GovernorStorage_init();
       __GovernorVotes_init(_token);
       __GovernorVotesQuorumFraction_init(4);
       __GovernorTimelockControl_init(_timelock);
       __Ownable_init(initialOwner);
       __UUPSUpgradeable_init();
   }

   // The following functions are overrides required by Solidity.
   ...

}


3. **ERC1155.pdf:**

// SPDX-License-Identifier: MIT pragma solidity ^0.8.20;

import "@openzeppelin/contracts/token/ERC1155/ERC1155.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/token/ERC1155/extensions/ERC1155Pausable.sol"; import "@openzeppelin/contracts/token/ERC1155/extensions/ERC1155Burnable.sol"; import "@openzeppelin/contracts/token/ERC1155/extensions/ERC1155Supply.sol";

contract MyToken is ERC1155, Ownable, ERC1155Pausable, ERC1155Burnable, ERC1155Supply { constructor(address initialOwner) ERC1155(""), Ownable(initialOwner) {}

   function setURI(string memory newuri) public onlyOwner {
       _setURI(newuri);
   }

   function pause() public onlyOwner {
       _pause();
   }

   function unpause() public onlyOwner {
       _unpause();
   }

   function mint(address account, uint256 id, uint256 amount, bytes memory data) public onlyOwner { 
       _mint(account, id, amount, data);
   }

   function mintBatch(address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data) public onlyOwner { 
       _mintBatch(to, ids, amounts, data);
   }

   // The following functions are overrides required by Solidity.
   ...

}


4. **ERC721Contract.pdf:**

// SPDX-License-Identifier: MIT pragma solidity ^0.8.20;

import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol"; import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol"; import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Pausable.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Burnable.sol"; import "@openzeppelin/contracts/utils/cryptography/EIP712.sol"; import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Votes.sol";

contract MyToken is ERC721, ERC721Enumerable, ERC721URIStorage, ERC721Pausable, Ownable, ERC721Burnable, EIP712, ERC721Votes { uint256 private _nextTokenId;

   constructor(address initialOwner) ERC721("MyToken", "MTK"), Ownable(initialOwner), EIP712("MyToken", "1") {}

   function pause() public onlyOwner {
       _pause();
   }

   function unpause() public onlyOwner {
       _unpause();
   }

   function safeMint(address to, string memory uri) public onlyOwner {
       uint256 tokenId = _nextTokenId++;
       _safeMint(to, tokenId);
       _setTokenURI(tokenId, uri);
   }

   // The following functions are overrides required by Solidity.
   ...

}


5. **MultifunctionalSmartContract.pdf:**

// SPDX-License-Identifier: MIT pragma solidity ^0.8.20;

import "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol"; import "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/ERC20BurnableUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/ERC20PausableUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/ERC20PermitUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/ERC20VotesUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/ERC20FlashMintUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";

contract MyToken is Initializable, ERC20Upgradeable, ERC20BurnableUpgradeable, ERC20PausableUpgradeable, OwnableUpgradeable, ERC20PermitUpgradeable, ERC20VotesUpgradeable, ERC20FlashMintUpgradeable { /// @custom:oz-upgrades-unsafe-allow constructor constructor() { _disableInitializers(); }

   function initialize(address initialOwner) initializer public {
       __ERC20_init("MyToken", "MTK");
       __ERC20Burnable_init();
       __ERC20Pausable_init();
       __Ownable_init(initialOwner);
       __ERC20Permit_init("MyToken");
       __ERC20Votes_init();
       __ERC20FlashMint_init();
   }

   function pause() public onlyOwner {
       _pause();
   }

   function unpause() public onlyOwner {
       _unpause();
   }

   function mint(address to, uint256 amount) public onlyOwner {
       _mint(to, amount);
   }

   // The following functions are overrides required by Solidity.
   ...

}


6. **NFTSmartContractExample.pdf:**

/** *Submitted for verification at Etherscan.io on 2021-04-22 */

// File: @openzeppelin/contracts/utils/Context.sol ...

// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; ... abstract contract Context { function _msgSender() internal view virtual returns (address payable) { return msg.sender; }

   function _msgData() internal view virtual returns (bytes memory) {
       this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
       return msg.data;
   }

} ...

// File: @openzeppelin/contracts/introspection/IERC165.sol ...

// File: @openzeppelin/contracts/token/ERC721/IERC721.sol ...

// File: @openzeppelin/contracts/token/ERC721/IERC721Metadata.sol ...

// File: @openzeppelin/contracts/token/ERC721/IERC721Enumerable.sol ...

// File: @openzeppelin/contracts/token/ERC721/IERC721Receiver.sol ...

// File: @openzeppelin/contracts/introspection/ERC165.sol ...

// File: @openzeppelin/contracts/math/SafeMath.sol ...

// File: @openzeppelin/contracts/utils/Address.sol ...

// File: @openzeppelin/contracts/utils/EnumerableSet.sol ...

// File: @openzeppelin/contracts/utils/EnumerableMap.sol ...

// File: @openzeppelin/contracts/utils/Strings.sol ...

// File: @openzeppelin/contracts/token/ERC721/ERC721.sol ...

// File: @openzeppelin/contracts/access/Ownable.sol ...

// File: contracts/BoredApeYachtClub.sol pragma solidity ^0.7.0;

/**

  • @title BoredApeYachtClub contract

  • @dev Extends ERC721 Non-Fungible Token Standard basic implementation */ contract BoredApeYachtClub is ERC721, Ownable { using SafeMath for uint256;

    string public BAYC_PROVENANCE = ""; ... }