diff --git a/Contracts/BlueDragon.sol b/Contracts/BlueDragon.sol new file mode 100644 index 0000000..67b0951 --- /dev/null +++ b/Contracts/BlueDragon.sol @@ -0,0 +1,41 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.4; + +import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; +import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol"; +import "@openzeppelin/contracts/access/Ownable.sol"; +import "@openzeppelin/contracts/utils/Counters.sol"; + +contract BlueDragon is ERC721, ERC721URIStorage, Ownable { + using Counters for Counters.Counter; + string[] uriData = [ + "https://gateway.pinata.cloud/ipfs/QmTyf3WE89ezETCcrZpRvTaF1zjyUhwXP4fqC3tkCNn9jr", + "https://gateway.pinata.cloud/ipfs/QmSiZ4XE9an72QdmaHfmFMJ3TxjZUmXHCLFkCzXTiZY2EL", + "https://gateway.pinata.cloud/ipfs/Qmeh1GwaygAhDediixrkrwRVDdkpxmrjnX13MNXTrt1hPj" + ]; + Counters.Counter private _tokenIdCounter; + + constructor() ERC721("BlueDragon", "BLD") {} + + function safeMint(address to, string memory uri) public onlyOwner { + uint256 tokenId = _tokenIdCounter.current(); + _tokenIdCounter.increment(); + _safeMint(to, tokenId); + _setTokenURI(tokenId, uri); + } + + // The following functions are overrides required by Solidity. + + function _burn(uint256 tokenId) internal override(ERC721, ERC721URIStorage) { + super._burn(tokenId); + } + + function tokenURI(uint256 tokenId) + public + view + override(ERC721, ERC721URIStorage) + returns (string memory) + { + return super.tokenURI(tokenId); + } +} \ No newline at end of file diff --git a/Contracts/BlueDragonDNFT.sol b/Contracts/BlueDragonDNFT.sol new file mode 100644 index 0000000..ef55bcb --- /dev/null +++ b/Contracts/BlueDragonDNFT.sol @@ -0,0 +1,66 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.4; + +import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; +import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol"; +import "@openzeppelin/contracts/access/Ownable.sol"; +import "@openzeppelin/contracts/utils/Counters.sol"; + +contract BlueDragon is ERC721, ERC721URIStorage, Ownable { + using Counters for Counters.Counter; + string[] uriData = [ + "https://gateway.pinata.cloud/ipfs/QmTyf3WE89ezETCcrZpRvTaF1zjyUhwXP4fqC3tkCNn9jr", + "https://gateway.pinata.cloud/ipfs/QmSiZ4XE9an72QdmaHfmFMJ3TxjZUmXHCLFkCzXTiZY2EL", + "https://gateway.pinata.cloud/ipfs/Qmeh1GwaygAhDediixrkrwRVDdkpxmrjnX13MNXTrt1hPj" + ]; + Counters.Counter private _tokenIdCounter; + + constructor() ERC721("BlueDragon", "BLD") {} + + function safeMint(address to) public onlyOwner { + uint256 tokenId = _tokenIdCounter.current(); + _tokenIdCounter.increment(); + _safeMint(to, tokenId); + _setTokenURI(tokenId, uriData[0]); + } +function changeNumber(uint256 _tokenId) public { + if (numberStage(_tokenId) >= 2) { + _setTokenURI(_tokenId, uriData[0]); + return; + } + uint256 newVal = numberStage(_tokenId) + 1; // Get the current number and add 1 + string memory newUri = uriData[newVal]; // store the new URI + _setTokenURI(_tokenId, newUri);// Update the URI + } + + // determine the stage of the Nft + function numberStage(uint256 _tokenId) public view returns (uint256) { + string memory _uri = tokenURI(_tokenId); + if (compareStrings(_uri, uriData[0])) {// Dragon 1 + return 0; + } + if (compareStrings(_uri, uriData[1])) { // Dragon 2 + return 1; + } + return 2; // Dragon 3 + } + // helper function to compare strings + function compareStrings(string memory a, string memory b) public pure returns (bool) { + return (keccak256(abi.encodePacked((a))) == + keccak256(abi.encodePacked((b)))); + } + // The following functions are overrides required by Solidity. + + function _burn(uint256 tokenId) internal override(ERC721, ERC721URIStorage) { + super._burn(tokenId); + } + + function tokenURI(uint256 tokenId) + public + view + override(ERC721, ERC721URIStorage) + returns (string memory) + { + return super.tokenURI(tokenId); + } +} \ No newline at end of file diff --git a/Contracts/BlueDragonDNFTKeeper.sol b/Contracts/BlueDragonDNFTKeeper.sol new file mode 100644 index 0000000..ea932d5 --- /dev/null +++ b/Contracts/BlueDragonDNFTKeeper.sol @@ -0,0 +1,92 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.6; + +import "@chainlink/contracts/src/v0.8/KeeperCompatible.sol"; +import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol"; +import "@openzeppelin/contracts/utils/Counters.sol"; + +contract NFTDinamic is ERC721, ERC721URIStorage, KeeperCompatibleInterface { + using Counters for Counters.Counter; + + Counters.Counter public tokenIdCounter; + + // Metadata information for each stage of the NFT on IPFS. + string[] IpfsUri = [ + "https://gateway.pinata.cloud/ipfs/QmTyf3WE89ezETCcrZpRvTaF1zjyUhwXP4fqC3tkCNn9jr", + "https://gateway.pinata.cloud/ipfs/QmSiZ4XE9an72QdmaHfmFMJ3TxjZUmXHCLFkCzXTiZY2EL", + "https://gateway.pinata.cloud/ipfs/Qmeh1GwaygAhDediixrkrwRVDdkpxmrjnX13MNXTrt1hPj" + ]; + + uint256 lastTimeStamp; + uint256 interval; + + constructor(uint256 _interval) ERC721("BlueDragon", "BLD") { + interval = _interval; + lastTimeStamp = block.timestamp; + } + function checkUpkeep(bytes calldata /* checkData */) external view override returns (bool upkeepNeeded, bytes memory /* performData */) { + uint256 tokenId = tokenIdCounter.current() - 1; + bool done; + if (numberStage(tokenId) >= 2) { + done = true; + } + upkeepNeeded = !done && ((block.timestamp - lastTimeStamp) > interval); + } + + function performUpkeep(bytes calldata /* performData */) external override { + if ((block.timestamp - lastTimeStamp) > interval) { + lastTimeStamp = block.timestamp; + uint256 tokenId = tokenIdCounter.current() - 1; + changeNumber(tokenId); + } + // We don't use the performData in this example. The performData is generated by the Keeper's call to your checkUpkeep function + } + + function safeMint(address to) public { + uint256 tokenId = tokenIdCounter.current(); + tokenIdCounter.increment(); + _safeMint(to, tokenId); + _setTokenURI(tokenId, IpfsUri[0]); + } + + function changeNumber(uint256 _tokenId) public { + if (numberStage(_tokenId) >= 2) { + return; + } + // Get the current number and add 1 + uint256 newVal = numberStage(_tokenId) + 1; + // store the new URI + string memory newUri = IpfsUri[newVal]; + // Update the URI + _setTokenURI(_tokenId, newUri); + } + + // determine the stage of number + function numberStage(uint256 _tokenId) public view returns (uint256) { + string memory _uri = tokenURI(_tokenId); + if (compareStrings(_uri, IpfsUri[0])) { // Dragon 1 + return 0; + } + if (compareStrings(_uri, IpfsUri[1])) { // Dragon 2 + return 1; + } + // Dragon 3 + return 2; + } + + // helper function to compare strings + function compareStrings(string memory a, string memory b) public pure returns (bool) { + return (keccak256(abi.encodePacked((a))) == + keccak256(abi.encodePacked((b)))); + } + + // The following functions is an override required by Solidity. + function _burn(uint256 tokenId) internal override(ERC721, ERC721URIStorage) { + super._burn(tokenId); + } + + // The following functions is an override required by Solidity. + function tokenURI(uint256 tokenId) public view override(ERC721, ERC721URIStorage) returns (string memory) { + return super.tokenURI(tokenId); + } +} \ No newline at end of file diff --git a/DNFT.sol b/DNFT.sol deleted file mode 100644 index 44afa3b..0000000 --- a/DNFT.sol +++ /dev/null @@ -1,112 +0,0 @@ -//Begin -// SPDX-License-Identifier: MIT -pragma solidity 0.8.6; - -import "@chainlink/contracts/src/v0.8/KeeperCompatible.sol"; -import "@openzeppelin/contracts@4.6.0/token/ERC721/extensions/ERC721URIStorage.sol"; -import "@openzeppelin/contracts@4.6.0/utils/Counters.sol"; - -contract keeperFlower is ERC721, ERC721URIStorage, KeeperCompatibleInterface { - using Counters for Counters.Counter; - - Counters.Counter public tokenIdCounter; - - // Metadata information for each stage of the NFT on IPFS. - string[] IpfsUri = [ - "https://ipfs.io/ipfs/QmYaTsyxTDnrG4toc8721w62rL4ZBKXQTGj9c9Rpdrntou/seed.json", - "https://ipfs.io/ipfs/QmYaTsyxTDnrG4toc8721w62rL4ZBKXQTGj9c9Rpdrntou/purple-sprout.json", - "https://ipfs.io/ipfs/QmYaTsyxTDnrG4toc8721w62rL4ZBKXQTGj9c9Rpdrntou/purple-blooms.json" - ]; - - uint256 lastTimeStamp; - uint256 interval; - - constructor(uint _interval) ERC721("Flower Platzi", "fPLTZ") { - interval = _interval; - lastTimeStamp = block.timestamp; - } - - function checkUpkeep(bytes calldata /* checkData */) external view override returns (bool upkeepNeeded, bytes memory /* performData */) { - uint256 tokenId = tokenIdCounter.current() - 1; - bool done; - if (flowerStage(tokenId) >= 2) { - done = true; - } - - upkeepNeeded = !done && ((block.timestamp - lastTimeStamp) > interval); - // We don't use the checkData in this example. The checkData is defined when the Upkeep was registered. - } - - function performUpkeep(bytes calldata /* performData */) external override { - //We highly recommend revalidating the upkeep in the performUpkeep function - if ((block.timestamp - lastTimeStamp) > interval ) { - lastTimeStamp = block.timestamp; - uint256 tokenId = tokenIdCounter.current() - 1; - growFlower(tokenId); - } - // We don't use the performData in this example. The performData is generated by the Keeper's call to your checkUpkeep function - } - - function safeMint(address to) public { - uint256 tokenId = tokenIdCounter.current(); - tokenIdCounter.increment(); - _safeMint(to, tokenId); - _setTokenURI(tokenId, IpfsUri[0]); - } - - function growFlower(uint256 _tokenId) public { - if(flowerStage(_tokenId) >= 2){return;} - // Get the current stage of the flower and add 1 - uint256 newVal = flowerStage(_tokenId) + 1; - // store the new URI - string memory newUri = IpfsUri[newVal]; - // Update the URI - _setTokenURI(_tokenId, newUri); - } - - // determine the stage of the flower growth - function flowerStage(uint256 _tokenId) public view returns (uint256) { - string memory _uri = tokenURI(_tokenId); - // Seed - if (compareStrings(_uri, IpfsUri[0])) { - return 0; - } - // Sprout - if ( - compareStrings(_uri, IpfsUri[1]) - ) { - return 1; - } - // Must be a Bloom - return 2; - } - - // helper function to compare strings - function compareStrings(string memory a, string memory b) - public - pure - returns (bool) - { - return (keccak256(abi.encodePacked((a))) == - keccak256(abi.encodePacked((b)))); - } - - // The following functions is an override required by Solidity. - function _burn(uint256 tokenId) - internal - override(ERC721, ERC721URIStorage) - { - super._burn(tokenId); - } - - // The following functions is an override required by Solidity. - function tokenURI(uint256 tokenId) - public - view - override(ERC721, ERC721URIStorage) - returns (string memory) - { - return super.tokenURI(tokenId); - } -} -//End diff --git a/Images/watercolor painting of a small blue dragon in a rock.jfif b/Images/watercolor painting of a small blue dragon in a rock.jfif new file mode 100644 index 0000000..901b716 Binary files /dev/null and b/Images/watercolor painting of a small blue dragon in a rock.jfif differ diff --git a/Images/watercolor painting of a small blue dragon in a rock2.jfif b/Images/watercolor painting of a small blue dragon in a rock2.jfif new file mode 100644 index 0000000..3d8b373 Binary files /dev/null and b/Images/watercolor painting of a small blue dragon in a rock2.jfif differ diff --git a/Images/watercolor painting of a small blue dragon in a rock3.jfif b/Images/watercolor painting of a small blue dragon in a rock3.jfif new file mode 100644 index 0000000..17c31ae Binary files /dev/null and b/Images/watercolor painting of a small blue dragon in a rock3.jfif differ diff --git a/Metadata templates/creciendo.json b/Metadata templates/creciendo.json deleted file mode 100644 index 949502a..0000000 --- a/Metadata templates/creciendo.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "name": "Flor Creciendo", - "description": "Flor NFT va a dar un nuevo paso", - "image": "https://gateway.pinata.cloud/ipfs/QmV8U3DsVNHsrnDcsosuCYmpRtAqadam1zrCW5dDk9hUrB", - "attributes": [ - { - "trait-type": "EtapaFLor", - "value": "Crediendo" - }, - { - "trait-type": "ColorFlor", - "value": "MORADO" - } - ] -} \ No newline at end of file diff --git a/Metadata templates/florecida.json b/Metadata templates/florecida.json deleted file mode 100644 index da75b2b..0000000 --- a/Metadata templates/florecida.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "name": "Semilla Flor", - "description": "Flor NFT con la que vamos a aprender", - "image": "https://gateway.pinata.cloud/ipfs/QmXQsAQk18pLGtfg2knesd17kLFwC6PEAH6eKLpmn8Qhr5", - "attributes": [ - { - "trait-type": "EtapaFLor", - "value": "Semilla" - }, - { - "trait-type": "ColorFlor", - "value": "CAFE" - } - ] -} \ No newline at end of file diff --git a/Metadata templates/semilla.json b/Metadata templates/semilla.json deleted file mode 100644 index da75b2b..0000000 --- a/Metadata templates/semilla.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "name": "Semilla Flor", - "description": "Flor NFT con la que vamos a aprender", - "image": "https://gateway.pinata.cloud/ipfs/QmXQsAQk18pLGtfg2knesd17kLFwC6PEAH6eKLpmn8Qhr5", - "attributes": [ - { - "trait-type": "EtapaFLor", - "value": "Semilla" - }, - { - "trait-type": "ColorFlor", - "value": "CAFE" - } - ] -} \ No newline at end of file diff --git a/Metadata/draco1.json b/Metadata/draco1.json new file mode 100644 index 0000000..78a1b08 --- /dev/null +++ b/Metadata/draco1.json @@ -0,0 +1,15 @@ +{ + "name": "Dragon 1", + "description": "watercolor painting of a small blue dragon in a rock", + "image": "https://gateway.pinata.cloud/ipfs/QmcQfjjg4nn4c3p9b7MYhY9bDpWgZFbfED1Q4L5kmSzegU", + "attributes": [ + { + "trait-type": "EtapaDraco", + "value": 1 + }, + { + "trait-type": "ColorDraco", + "value": "azul" + } + ] +} \ No newline at end of file diff --git a/Metadata/draco2.json b/Metadata/draco2.json new file mode 100644 index 0000000..0919716 --- /dev/null +++ b/Metadata/draco2.json @@ -0,0 +1,15 @@ +{ + "name": "Dragon 2", + "description": "watercolor painting of a small blue dragon in a rock", + "image": "https://gateway.pinata.cloud/ipfs/QmZeiqJb2rYsgHUM1Ezy27nDfNGFdnDRpe67DVD6mgpGff", + "attributes": [ + { + "trait-type": "EtapaDraco", + "value": 2 + }, + { + "trait-type": "ColorDraco", + "value": "azul" + } + ] +} \ No newline at end of file diff --git a/Metadata/draco3.json b/Metadata/draco3.json new file mode 100644 index 0000000..25f82b5 --- /dev/null +++ b/Metadata/draco3.json @@ -0,0 +1,15 @@ +{ + "name": "Dragon 3", + "description": "watercolor painting of a small blue dragon in a rock", + "image": "https://gateway.pinata.cloud/ipfs/Qmdr7iQEo2592XdKJERv3M1fzKSaZ7HwaV3q5cw5hbrrwE", + "attributes": [ + { + "trait-type": "EtapaDraco", + "value": 3 + }, + { + "trait-type": "ColorDraco", + "value": "azul" + } + ] +} \ No newline at end of file diff --git a/README.md b/README.md index c207b56..5c4aa5b 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,21 @@ # Aprendamos a crear NFT's dinámicos +## Datos +Opensea: +https://testnets.opensea.io/assets/rinkeby/0x923fabdc482f0d8702eb20d045eeb9a542d809eb/0 + +keeper +https://keepers.chain.link/rinkeby/63384322163217113884379947884858403956746308248919015528512094251554012088606 + + +contrato +https://rinkeby.etherscan.io/address/0x923fabdc482f0d8702eb20d045eeb9a542d809eb + +minteo +https://rinkeby.etherscan.io/tx/0xe1e69d5d460e606a6fe5bf8a1de659217a8f3cba7483585ed698cb2fda1b0f94 + +creación contrato +https://rinkeby.etherscan.io/tx/0x7627659a35c13e72b699cc5b5ace1ddf4d34c0f532c2a9e5e769ec539efeefa8 + ## Reto 1 @@ -40,4 +57,7 @@ Los pasos que debes seguir son: * [Qué es chainlink](https://chainlinkspanishcommunity.medium.com/qu%C3%A9-es-chainlink-6ea80f9ff95e) * [Documentación de Chainlink ](https://docs.chain.link/docs) +<<<<<<< HEAD +======= +>>>>>>> 9f1ddca74edf234d78cb5629b873f5587bbf514c diff --git a/image/fase 1.jpg b/image/fase 1.jpg deleted file mode 100644 index b8281ef..0000000 Binary files a/image/fase 1.jpg and /dev/null differ diff --git a/image/fase 2.jpg b/image/fase 2.jpg deleted file mode 100644 index 33ae174..0000000 Binary files a/image/fase 2.jpg and /dev/null differ diff --git a/image/fase 3.jpg b/image/fase 3.jpg deleted file mode 100644 index 202b80e..0000000 Binary files a/image/fase 3.jpg and /dev/null differ diff --git a/image/uptadeMetadata_1.jpg b/image/uptadeMetadata_1.jpg deleted file mode 100644 index d2c2c5d..0000000 Binary files a/image/uptadeMetadata_1.jpg and /dev/null differ