Contract-Development
乙太坊陷入智能合約
我部署了一個 NFT 項目的 beta 版本,但是,一些不在白名單中的人的 eth 卡在了智能合約中,現在我需要通過提取智能合約中的 eth 來退款,因為我沒有錢和我一起,但我沒有預見到任何提款功能。
有沒有什麼方法可以通過查看智能合約原始碼、進行預執行、委託、自毀或任何技術來銷毀智能合約或將 eth 發送到部署者錢包?
// SPDX-License-Identifier: MIT pragma solidity ^0.8.3; import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/security/Pausable.sol"; contract NFT is ERC721Enumerable, Ownable, Pausable { using Strings for uint256; string baseURI=""; string private baseExtension = ".json"; uint256 public _batch = 9456; bool public _firstwhitelist = true; bool public _allpeople = false; uint256 public _qtyperMint = 1; uint256 public price = 0.001 ether; uint256 private supplycount = 0; address payable public _holderEth; uint256 public holderID = 0; address[] private allowedWhite1; address[] private HoldersBook; constructor (address _addr, string memory _URI ) ERC721("Our token", "OTK") { _holderEth=payable(_addr); baseURI=_URI; } struct Holders { uint itemId; address owner; bool sold; } mapping(uint256 => Holders) private idToHolders; function ErraseListe1 ()public onlyOwner { delete allowedWhite1; } function addallowedWhite1(address[] memory minteraddr) public onlyOwner { for (uint256 i=0; i<minteraddr.length;i++){ allowedWhite1.push(minteraddr[i]); } } function MinterIsAllowed1(address minteraddr) public view returns (bool) { for ( uint256 allowedminter = 0; allowedminter < allowedWhite1.length; allowedminter++ ) { if (allowedWhite1[allowedminter] == minteraddr) { return true; } } return false; } function IfMinted(address minteraddr) public view returns (bool) { for ( uint256 allowedminter = 0; allowedminter < HoldersBook.length; allowedminter++ ) { if (HoldersBook[allowedminter] == minteraddr) { return true; } } return false; } function changeQtymint(uint256 _newqty) public onlyOwner returns(bool result){ _qtyperMint=_newqty; return true; } function changeHolder(address _newaddr) public onlyOwner returns (bool) { _holderEth=payable(_newaddr); return true; } function changeUri(string memory _newUri) public onlyOwner returns (bool) { baseURI=_newUri; return true; } function changeWhitelist1() public onlyOwner returns (bool) { if(_firstwhitelist){ _firstwhitelist=false; } else if (!_firstwhitelist){ _firstwhitelist=true; _allpeople=false; } return true; } function changeAllminting() public onlyOwner returns (bool) { _allpeople=true; _firstwhitelist=false; return true; } function _baseURI() internal view virtual override returns (string memory) { return baseURI; } function claim(uint256 _qty)public payable returns (bool result){ require(_qty > 0 ,"cannot mint 0 NFT"); require(_qty <= _qtyperMint,"Quantity more than 5"); require(_batch > 0,"first drop is over"); require(msg.value >= price * _qty,"unsufficiant funds"); if (_firstwhitelist) { require(MinterIsAllowed1(msg.sender), "only people allowed can mint"); require((balanceOf(msg.sender)) < _qtyperMint,"You cannot hold more than the limit set"); uint256 supply = supplycount; for (uint256 i = 1; i <= _qty; i++) { _safeMint(msg.sender, supply+i); } supplycount=supplycount+_qty; _holderEth.transfer(msg.value); _batch=_batch - _qty; if(!IfMinted(msg.sender)){ holderID++; uint256 itemId = holderID; idToHolders[itemId] = Holders( itemId, msg.sender, false ); } HoldersBook.push(msg.sender); return true; } else if (_allpeople) { uint256 supply = supplycount; for (uint256 i = 1; i <= _qty; i++) { _safeMint(msg.sender, supply+i); } supplycount=supplycount+_qty; _holderEth.transfer(msg.value); _batch=_batch - _qty; if(!IfMinted(msg.sender)){ holderID++; uint256 itemId = holderID; idToHolders[itemId] = Holders( itemId, msg.sender, false ); } HoldersBook.push(msg.sender); return true; } return false; } function getHolders()public view returns(Holders[] memory){ uint itemCount = holderID; uint currentIndex = 0; Holders[] memory items = new Holders[](itemCount); for (uint i = 0; i < itemCount; i++) { if (idToHolders[i + 1].sold == false) { uint currentId = i + 1; Holders storage currentItem = idToHolders[currentId]; items[currentIndex] = currentItem; currentIndex += 1; } } return items; } function giveAway(address _addr, uint256 _qty) public onlyOwner { uint256 supply = supplycount; for (uint256 i = 1; i <= _qty; i++) { _safeMint(_addr, supply+i); } supplycount=supplycount+_qty; } function changePrice(uint256 _newPrice) public onlyOwner returns (bool) { price=_newPrice; return true; } function getPrice() public view returns (uint256) { return price; } function tokenURI(uint256 tokenId)public view virtual override returns (string memory) { require(_exists(tokenId),"ERC721Metadata: URI query for nonexistent token"); string memory currentBaseURI = _baseURI(); return bytes(currentBaseURI).length > 0 ? string(abi.encodePacked(currentBaseURI, tokenId.toString(), baseExtension)) : ""; } function pause() public onlyOwner { _pause(); } function unpause() public onlyOwner { _unpause(); } function _beforeTokenTransfer(address from, address to, uint256 tokenId) internal whenNotPaused override { super._beforeTokenTransfer(from, to, tokenId); } function transferFrom( address from, address to, uint256 tokenId ) public override { uint itemCount = holderID; for (uint i = 0; i < itemCount; i++) { if (idToHolders[i + 1].owner == msg.sender) { idToHolders[i + 1].owner = msg.sender; idToHolders[i + 1].sold = true; } } _transfer(from, to, tokenId); } function safeTransferFrom( address from, address to, uint256 tokenId ) public override { uint itemCount = holderID; for (uint i = 0; i < itemCount; i++) { if (idToHolders[i + 1].owner == msg.sender) { idToHolders[i + 1].owner = msg.sender; idToHolders[i + 1].sold = true; } } safeTransferFrom(from, to, tokenId, ''); } function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory _data ) public override { uint itemCount = holderID; for (uint i = 0; i < itemCount; i++) { if (idToHolders[i + 1].owner == msg.sender) { idToHolders[i + 1].owner = msg.sender; idToHolders[i + 1].sold = true; } } _safeTransfer(from, to, tokenId, _data); } }
不幸的是,我看不到任何獲得 Eth 的方法。
程式碼發送 Eth 的唯一地方是
claim
當它將發送的金額(在該交易中發送)發送給某人時,但它永遠不會發送超過發送的金額。所以如果現在合約裡面有 Eth,恐怕它會永遠卡住。