Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ivy Saskia Sejas Rocabado - platziretoDNFT #63

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions DNFT.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ contract keeperFlower is ERC721, ERC721URIStorage, KeeperCompatibleInterface {

// 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"
"https://gateway.pinata.cloud/ipfs/Qma4nV3k5NXsaNo6e6CxicaQWh6tLJvC7K7D2PqKUCnAiE",
"https://gateway.pinata.cloud/ipfs/QmYGUcvf8CQP89NDNxdQSn9ykF4zuaYxHmyco68GwZtDBH",
"https://gateway.pinata.cloud/ipfs/QmVMvXtGiS57dfPx1EMiQ6i2caD6vyrnpbj1Yv84Ar5BJt"
];

uint256 lastTimeStamp;
uint256 interval;

constructor(uint _interval) ERC721("Flower Platzi", "fPLTZ") {
constructor(uint _interval) ERC721("Pokemon Platzi", "pPLTZ") {
interval = _interval;
lastTimeStamp = block.timestamp;
}
Expand Down Expand Up @@ -110,3 +110,4 @@ contract keeperFlower is ERC721, ERC721URIStorage, KeeperCompatibleInterface {
}
}
//End

126 changes: 126 additions & 0 deletions DNFT5.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
//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 keeperPokemon5 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/QmSkDEFufbd5mF6hJczXfnx5Shc6JLv5MtYrfFNTYQiL2R",
"https://gateway.pinata.cloud/ipfs/QmWBjDp7TEBm94en7TSAwQwmhbAJonjmYZav2kVVJFWfFq",
"https://gateway.pinata.cloud/ipfs/QmW7TfZjgK555tWBm1oHibduAVCCXT2MzLEdRRtiGAoMxg",
"https://gateway.pinata.cloud/ipfs/QmNrsdjfScyS2MCYehxFD8RAB7u19CACBmVxBSWvZ6buTc",
"https://gateway.pinata.cloud/ipfs/QmVxTPZmD1WttW8PZJE9FVujBTy9Rnbk5m4MfvJd74AkgZ"
];

uint256 lastTimeStamp;
uint256 interval;

constructor(uint _interval) ERC721("Pokemon 5 Platzi", "pPLTZ5") {
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) >= 4) {
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) >= 4){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;
}
if (
compareStrings(_uri, IpfsUri[2])
) {
return 2;
}
if (
compareStrings(_uri, IpfsUri[3])
) {
return 3;
}
// Must be a Bloom
return 4;
}

// 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

//Reto 2
10 changes: 5 additions & 5 deletions Metadata templates/creciendo.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"name": "Flor Creciendo",
"description": "Flor NFT va a dar un nuevo paso",
"image": "https://gateway.pinata.cloud/ipfs/QmV8U3DsVNHsrnDcsosuCYmpRtAqadam1zrCW5dDk9hUrB",
"name": "Pokemon Creciendo",
"description": "Pokemon NFT va a dar un nuevo paso",
"image": "https://gateway.pinata.cloud/ipfs/QmPuiVbbw77Cx4EwrxC12YMesyz8pEjt94k41PivCwaBpc",
"attributes": [
{
"trait-type": "EtapaFLor",
"trait-type": "EtapaPokemon",
"value": "Crediendo"
},
{
"trait-type": "ColorFlor",
"trait-type": "ColorPokemon",
"value": "MORADO"
}
]
Expand Down
15 changes: 15 additions & 0 deletions Metadata templates/eevee.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "Eevee Pokemon",
"description": "Pokemon NFT con la que vamos a aprender",
"image": "https://gateway.pinata.cloud/ipfs/QmNn6WnbjcPzQ8JG53AhE2CUNjwqXJFYhG4E1LxsdeYkqw",
"attributes": [
{
"trait-type": "EtapaPokemon",
"value": "Eevee"
},
{
"trait-type": "ColorPokemon",
"value": "CAFE"
}
]
}
15 changes: 15 additions & 0 deletions Metadata templates/espeon.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "Espeon Pokemon",
"description": "Pokemon NFT con la que vamos a aprender",
"image": "https://gateway.pinata.cloud/ipfs/Qmawink1SbUxpLLVCb6ctZEDAKoHSYKs7CzfJ7ui11ysuu",
"attributes": [
{
"trait-type": "EtapaPokemon",
"value": "Espeon"
},
{
"trait-type": "ColorPokemon",
"value": "MORADO"
}
]
}
15 changes: 15 additions & 0 deletions Metadata templates/flareon.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "Flareon Pokemon",
"description": "Pokemon NFT con la que vamos a aprender",
"image": "https://gateway.pinata.cloud/ipfs/QmZKGmYtPLxY2Xy2KfYewZ71QEXcNaduYwWE2qKaQTm4AM",
"attributes": [
{
"trait-type": "EtapaPokemon",
"value": "Flareon"
},
{
"trait-type": "ColorPokemon",
"value": "NARANJA"
}
]
}
12 changes: 6 additions & 6 deletions Metadata templates/florecida.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"name": "Semilla Flor",
"description": "Flor NFT con la que vamos a aprender",
"image": "https://gateway.pinata.cloud/ipfs/QmXQsAQk18pLGtfg2knesd17kLFwC6PEAH6eKLpmn8Qhr5",
"name": "Pokemon Pokemonecida",
"description": "Pokemon NFT con la que vamos a aprender",
"image": "https://gateway.pinata.cloud/ipfs/QmeYMVmo4mC4DyEmwEbZUhf6tMMA5SdLZu8AAUKNqt5Xx9",
"attributes": [
{
"trait-type": "EtapaFLor",
"value": "Semilla"
"trait-type": "EtapaPokemon",
"value": "Pokemonecida"
},
{
"trait-type": "ColorFlor",
"trait-type": "ColorPokemon",
"value": "CAFE"
}
]
Expand Down
15 changes: 15 additions & 0 deletions Metadata templates/joldeon.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "Joldeon Pokemon",
"description": "Pokemon NFT con la que vamos a aprender",
"image": "https://gateway.pinata.cloud/ipfs/QmSGyf4GvchJAJp6q2ugoHio5rkGHpybhEjmNFpKmJXWFP",
"attributes": [
{
"trait-type": "EtapaPokemon",
"value": "Joldeon"
},
{
"trait-type": "ColorPokemon",
"value": "AMARILLO"
}
]
}
10 changes: 5 additions & 5 deletions Metadata templates/semilla.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"name": "Semilla Flor",
"description": "Flor NFT con la que vamos a aprender",
"image": "https://gateway.pinata.cloud/ipfs/QmXQsAQk18pLGtfg2knesd17kLFwC6PEAH6eKLpmn8Qhr5",
"name": "Semilla Pokemon",
"description": "Pokemon NFT con la que vamos a aprender",
"image": "https://gateway.pinata.cloud/ipfs/QmXQP9fDEGWGvAh6ZrAmsYks6RsQwjGvERn3JQRoCYxYh6",
"attributes": [
{
"trait-type": "EtapaFLor",
"trait-type": "EtapaPokemon",
"value": "Semilla"
},
{
"trait-type": "ColorFlor",
"trait-type": "ColorPokemon",
"value": "CAFE"
}
]
Expand Down
15 changes: 15 additions & 0 deletions Metadata templates/vaporeon.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "Vaporeon Pokemon",
"description": "Pokemon NFT con la que vamos a aprender",
"image": "https://gateway.pinata.cloud/ipfs/QmPPJ7wetmdNkYsXZLrkhu5yh8JdL1kg1NJDUAF2xADW7Q",
"attributes": [
{
"trait-type": "EtapaPokemon",
"value": "Vaporeon"
},
{
"trait-type": "ColorPokemon",
"value": "CELESTE"
}
]
}
65 changes: 65 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,68 @@ 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)

-------------------------------------------------------
# Solucion

## Reto 1

- [X] Reto 1

* contrato: 0xaFAAefe84D5059974af04c4a2C5833144cf1DE53

https://keepers.chain.link/rinkeby/67236507226672645450615757267471949287176678663968073965228452075164911897158

https://rinkeby.etherscan.io/address/0xaFAAefe84D5059974af04c4a2C5833144cf1DE53

Usando Pokemon
- bulbasaur

![image](https://user-images.githubusercontent.com/41027286/186071656-5cc43e0d-bf5c-4fcf-a706-b786994dc7be.png)


- ivysaur

![image](https://user-images.githubusercontent.com/41027286/186071484-76788ebc-b1aa-40c6-bda2-aec5eb6e5b56.png)


- venusaur

![image](https://user-images.githubusercontent.com/41027286/186071752-bfdf90b2-91ad-4ff6-9aa7-999806a2d033.png)


## Reto 2

- [X] Reto 2

* contrato: 0x60623c5916467B0378c91C4a535bDdc6d06DeEC3

https://keepers.chain.link/rinkeby/20532400068560510943293901040443387277531400425084381226482019174743555611463

https://rinkeby.etherscan.io/tx/0xae93fdc2f697159306911399571d4fc862482d7641ddd43ce6c6e5246bc4b55e

- eevee

![image](https://user-images.githubusercontent.com/41027286/186082000-a54a9f16-bb74-45f9-a248-cf67bd9848e3.png)


- vaporeon

![image](https://user-images.githubusercontent.com/41027286/186082173-4984ceec-6737-4dc7-9718-aecac4a984a9.png)


- joldeon

![image](https://user-images.githubusercontent.com/41027286/186082407-2837f01f-587a-4549-8d14-abe04c960278.png)


- flareon

![image](https://user-images.githubusercontent.com/41027286/186082550-9cc0f8c4-6a4a-4be4-a635-8ce561f5a632.png)

- espeon

![image](https://user-images.githubusercontent.com/41027286/186082958-c22392c8-3fde-4556-975c-952591ed22bd.png)

## Reto 3

- [ ] Reto 3