Skip to content

Commit a7fc81e

Browse files
authored
Add change nane
1 parent ad25944 commit a7fc81e

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

contracts/GameAnime.sol

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,16 +121,20 @@ contract GameAnime is ERC721, VRFConsumerBase, Ownable {
121121
return characters.length;
122122
}
123123

124-
function changeCharacterName(uint256 tokenId, string memory _newName)
124+
function changeCharacterName(uint256 tokenId, string memory updatedTokenURI)
125125
public
126126
payable
127127
{
128128
require(
129129
msg.value == 0.05 ether,
130130
"You need to send 0.05 ETH to edit the Name"
131131
);
132-
balances[owner()] += msg.value;
133-
return characters[tokenId].name = _newName;
132+
require(
133+
_isApprovedOrOwner(_msgSender(), tokenId),
134+
"ERC721: transfer caller is not owner nor approved"
135+
);
136+
(payable(owner())).transfer(0.05 ether);
137+
_setTokenURI(tokenId, updatedTokenURI);
134138
}
135139

136140
function getCharacterOverView(uint256 tokenId)

0 commit comments

Comments
 (0)