eth-erc721

ERC-721 'NFT' token interface with example developer badge token contract
Log | Files | Refs | LICENSE

commit ea3c8ad0ebe202b3e09ef8728c80427af45e6793
parent f2055c88b5107bd345ad4917b390f5d58461c8b3
Author: lash <dev@holbrook.no>
Date:   Wed, 22 Mar 2023 11:50:04 +0000

Fix non-trivial issues for BadgeToken reported by slither (0.9.3)

Diffstat:
Mpython/CHANGELOG | 4++++
Mpython/setup.cfg | 2+-
Msolidity/BadgeToken.sol | 12++++++++++--
3 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/python/CHANGELOG b/python/CHANGELOG @@ -1,3 +1,7 @@ +- 0.1.5 + * Fix non-trivial issues for BadgeToken reported by slither (0.9.3) +- 0.1.4 + * Upgrade deps - 0.1.3 * Correct interface signatures in contract (ERC165) - 0.1.2 diff --git a/python/setup.cfg b/python/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = eth-erc721 -version = 0.1.4 +version = 0.1.5 description = ERC721 interface and simple contract with deployment script providing arbitrary minting of NFTs with freely settable tokenids author = Louis Holbrook author_email = dev@holbrook.no diff --git a/solidity/BadgeToken.sol b/solidity/BadgeToken.sol @@ -47,6 +47,11 @@ contract BadgeToken { name = _name; symbol = _symbol; } + + function withdraw(uint256 _amount) public returns(bool) { + require(msg.sender == owner, 'ERR_ACCESS'); + payable(msg.sender).transfer(_amount); + } // ERC-721 function balanceOf(address _owner) external view returns (uint256) { @@ -78,7 +83,7 @@ contract BadgeToken { tokenOwner[_tokenId] = _to; - for (uint256 i; i < _data.length; i++) { + for (uint256 i = 0; i < _data.length; i++) { tokenData[_tokenId][i % 32] = _data[i]; } } @@ -87,6 +92,7 @@ contract BadgeToken { function transferFrom(address _from, address _to, uint256 _tokenId) external payable { bytes memory _data; + _data = new bytes(0); transferCore(_from, _to, _tokenId, _data); emit Transfer(_from, _to, _tokenId); } @@ -102,6 +108,7 @@ contract BadgeToken { function safeTransferFrom(address _from, address _to, uint256 _tokenId) external payable { bytes memory _data; + _data = new bytes(0); transferCore(_from, _to, _tokenId, _data); emit Transfer(_from, _to, _tokenId); } @@ -237,7 +244,8 @@ contract BadgeToken { previousOwner = owner; currentTokenOwnerIndex = tokenOwnerIndex[previousOwner]; - for (uint256 i; i < currentTokenOwnerIndex.length; i++) { + zeroData = new bytes(0); + for (uint256 i = 0; i < currentTokenOwnerIndex.length; i++) { transferCore(previousOwner, _newOwner, currentTokenOwnerIndex[i], zeroData); }