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

Desarrollo realizado para completar el Reto - NFT dinámicos con datos… #65

Open
wants to merge 1 commit 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
24 changes: 24 additions & 0 deletions Metadata templates/charizard.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"nombre": "Charizard Gigantamax",
"descripción": "POKFT",
"imagen": "https://gateway.pinata.cloud/ipfs/QmU7JcdwEyHX63ppCjWhFu3kJ1asKbSuNi1Ak9x9gJEG9h",
"background_color": "E3350D",
"atributos": [
{
"tipo-rasgo": "Categoría",
"valor": "Llama"
},
{
"tipo-rasgo": "Tipo",
"value": "Fuego, Volador"
},
{
"tipo-rasgo": "Habilidades",
"value": "BLAZE"
},
{
"trait-type": "Weaknesses",
"value": "Water, Electric, Rock*4"
}
]
}
24 changes: 24 additions & 0 deletions Metadata templates/charizard_gigantamax.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"nombre": "Charizard Gigantamax",
"descripción": "POKFT",
"imagen": "https://gateway.pinata.cloud/ipfs/QmU7JcdwEyHX63ppCjWhFu3kJ1asKbSuNi1Ak9x9gJEG9h",
"background_color": "E3350D",
"atributos": [
{
"tipo-rasgo": "Categoría",
"valor": "Llama"
},
{
"tipo-rasgo": "Tipo",
"value": "Fuego, Volador"
},
{
"tipo-rasgo": "Habilidades",
"value": "BLAZE"
},
{
"trait-type": "Weaknesses",
"value": "Water, Electric, Rock*4"
}
]
}
24 changes: 24 additions & 0 deletions Metadata templates/charizard_max.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "Charizard Max",
"description": "POKFT",
"image": "https://gateway.pinata.cloud/ipfs/QmegFcnQ5YyNScRUES7gL74YHDkFSgXVLVaua7W4CzfEZC",
"background_color": "E3350D",
"attributes": [
{
"trait-type": "Category",
"value": "Flame"
},
{
"trait-type": "Type",
"value": "Fire, Dragon"
},
{
"trait-type": "Abilities",
"value": "TOUGH CLAWS"
},
{
"trait-type": "Weaknesses",
"value": "Ground, Rock, Dragon"
}
]
}
24 changes: 24 additions & 0 deletions Metadata templates/charmander.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "Charmander",
"description": "POKFT",
"image": "https://gateway.pinata.cloud/ipfs/QmPdRCb7Q7nTYeKCxdPZ9SCaxQH5FkhabRRmvd62XVfoRY",
"background_color": "E3350D",
"attributes": [
{
"trait-type": "Category",
"value": "Lizard"
},
{
"trait-type": "Type",
"value": "Fire"
},
{
"trait-type": "Abilities",
"value": "BLAZ"
},
{
"trait-type": "Weaknesses",
"value": "Water, Ground, Rock"
}
]
}
24 changes: 24 additions & 0 deletions Metadata templates/charmelon.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "Charmeleon",
"description": "POKFT",
"image": "https://gateway.pinata.cloud/ipfs/QmZgkDVeg1Ev8USH2PJpHSiwNfDNmhBRRF8cwM1HyUjNix",
"background_color": "E3350D",
"attributes": [
{
"trait-type": "Category",
"value": "Flame"
},
{
"trait-type": "Type",
"value": "Fire"
},
{
"trait-type": "Abilities",
"value": "BLAZ"
},
{
"trait-type": "Weaknesses",
"value": "Water, Ground, Rock"
}
]
}
2 changes: 1 addition & 1 deletion Metadata templates/creciendo.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "Flor Creciendo",
"description": "Flor NFT va a dar un nuevo paso",
"image": "https://gateway.pinata.cloud/ipfs/QmV8U3DsVNHsrnDcsosuCYmpRtAqadam1zrCW5dDk9hUrB",
"image": "https://gateway.pinata.cloud/ipfs/QmPaCenJqPj2dVqtumePtDLoWkhkFbY9DhqFRQpismPWTv",
"attributes": [
{
"trait-type": "EtapaFLor",
Expand Down
2 changes: 1 addition & 1 deletion Metadata templates/florecida.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "Semilla Flor",
"description": "Flor NFT con la que vamos a aprender",
"image": "https://gateway.pinata.cloud/ipfs/QmXQsAQk18pLGtfg2knesd17kLFwC6PEAH6eKLpmn8Qhr5",
"image": "https://gateway.pinata.cloud/ipfs/QmV8U3DsVNHsrnDcsosuCYmpRtAqadam1zrCW5dDk9hUrB",
"attributes": [
{
"trait-type": "EtapaFLor",
Expand Down
112 changes: 112 additions & 0 deletions full.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.7;

import "@chainlink/contracts/src/v0.8/KeeperCompatible.sol";
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 EAGNFTPLATZIV2 is
ERC721,
ERC721URIStorage,
Ownable,
KeeperCompatibleInterface
{
using Counters for Counters.Counter;
Counters.Counter private tokenIdCounter;
string[] uriData = [
"https://gateway.pinata.cloud/ipfs/QmQrzxt1fvzoR6J91FTe58dd8Dg79CfPmPKhzhkDZKS1xP",
"https://gateway.pinata.cloud/ipfs/Qmf8RDvw5XP1XyzbEVdcYQcYqdp9Xe9aAkuAqrf2eh7bZs",
"https://gateway.pinata.cloud/ipfs/QmQKyA8wUUbCgjBnqibxLqEZW3FPZqJXj5i6YBEKgHXMcJ"
];
uint256 lastTimeStamp;
uint256 interval;

constructor(uint256 _interval) ERC721("EAGNFTPLATZIV2", "EAGPNFTV2") {
interval = _interval;
lastTimeStamp = block.timestamp;
}

function checkUpkeep(
bytes calldata /* checkData */
)
external
view
override
returns (
bool unkeepNeeded,
bytes memory /* performData */
)
{
uint256 tokenId = tokenIdCounter.current() - 1;
bool done;
if (getStage(tokenId) >= 2) {
done = true;
}
unkeepNeeded = !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;
updateToken(tokenId);
}
}

function safeMint(address to) public onlyOwner {
uint256 tokenId = tokenIdCounter.current();
tokenIdCounter.increment();
_safeMint(to, tokenId);
_setTokenURI(tokenId, uriData[0]);
}

function getStage(uint256 _tokenId) public view returns (uint256) {
string memory _uri = tokenURI(_tokenId);
if (compareStrings(_uri, uriData[0])) {
return 0;
}
if (compareStrings(_uri, uriData[1])) {
return 1;
}
return 2;
}

function updateToken(uint256 _tokenId) private {
if (getStage(_tokenId) >= 2) {
return;
}
uint256 newVal = getStage(_tokenId) + 1;
string memory newUri = uriData[newVal];
_setTokenURI(_tokenId, newUri);
}

function compareStrings(string memory a, string memory b)
private
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);
}
}
Binary file added image/chamander.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions image/chamander.png:Zone.Identifier
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[ZoneTransfer]
ZoneId=3
HostUrl=https://raw.githubusercontent.com/EdgarAGuevara/platziretoDNFT/ef600a88d0c7be2e4e583792b82d46474feeb774/image/chamander.png
Binary file added image/charizard.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions image/charizard.png:Zone.Identifier
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[ZoneTransfer]
ZoneId=3
HostUrl=https://raw.githubusercontent.com/EdgarAGuevara/platziretoDNFT/ef600a88d0c7be2e4e583792b82d46474feeb774/image/charizard.png
Binary file added image/charizard_gigantamax.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions image/charizard_gigantamax.png:Zone.Identifier
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[ZoneTransfer]
ZoneId=3
HostUrl=https://raw.githubusercontent.com/EdgarAGuevara/platziretoDNFT/ef600a88d0c7be2e4e583792b82d46474feeb774/image/charizard_gigantamax.png
Binary file added image/charizard_max.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions image/charizard_max.png:Zone.Identifier
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[ZoneTransfer]
ZoneId=3
HostUrl=https://raw.githubusercontent.com/EdgarAGuevara/platziretoDNFT/ef600a88d0c7be2e4e583792b82d46474feeb774/image/charizard_max.png
Binary file added image/charmleon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added image_test/Chaing_Link_byrdtp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added image_test/NFTBYRDTP_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added image_test/OpenSea_PKM_by_RDTP.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added image_test/OpenSea_byRDTP.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added image_test/PKM_by_RDTP_Chamander.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions image_test/PKM_by_RDTP_Chamander.png:Zone.Identifier
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[ZoneTransfer]
ZoneId=3
HostUrl=https://raw.githubusercontent.com/camohe90/platziretoDNFT/ef600a88d0c7be2e4e583792b82d46474feeb774/challenges_images/2-challenge/POKEFT_Chamander.png
Binary file added image_test/PKM_by_RDTP_Chamleon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions image_test/PKM_by_RDTP_Chamleon.png:Zone.Identifier
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[ZoneTransfer]
ZoneId=3
HostUrl=https://raw.githubusercontent.com/camohe90/platziretoDNFT/ef600a88d0c7be2e4e583792b82d46474feeb774/challenges_images/2-challenge/POKEFT_Chamleon.png
Binary file added image_test/PKM_by_RDTP_Charizard.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions image_test/PKM_by_RDTP_Charizard.png:Zone.Identifier
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[ZoneTransfer]
ZoneId=3
HostUrl=https://raw.githubusercontent.com/camohe90/platziretoDNFT/ef600a88d0c7be2e4e583792b82d46474feeb774/challenges_images/2-challenge/POKEFT_Charizard.png
Binary file added image_test/PKM_by_RDTP_Charizard_gigantamax.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[ZoneTransfer]
ZoneId=3
HostUrl=https://raw.githubusercontent.com/camohe90/platziretoDNFT/ef600a88d0c7be2e4e583792b82d46474feeb774/challenges_images/2-challenge/POKEFT_Charizard_gigantamax.png
Binary file added image_test/PKM_by_RDTP_Charizard_max.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions image_test/PKM_by_RDTP_Charizard_max.png:Zone.Identifier
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[ZoneTransfer]
ZoneId=3
HostUrl=https://raw.githubusercontent.com/camohe90/platziretoDNFT/ef600a88d0c7be2e4e583792b82d46474feeb774/challenges_images/2-challenge/POKEFT_Charizard_max.png
3 changes: 3 additions & 0 deletions image_test/POKEFT_Chamander.png:Zone.Identifier
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[ZoneTransfer]
ZoneId=3
HostUrl=https://raw.githubusercontent.com/camohe90/platziretoDNFT/ef600a88d0c7be2e4e583792b82d46474feeb774/challenges_images/2-challenge/POKEFT_Chamander.png
3 changes: 3 additions & 0 deletions image_test/POKEFT_Chamleon.png:Zone.Identifier
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[ZoneTransfer]
ZoneId=3
HostUrl=https://raw.githubusercontent.com/camohe90/platziretoDNFT/ef600a88d0c7be2e4e583792b82d46474feeb774/challenges_images/2-challenge/POKEFT_Chamleon.png
3 changes: 3 additions & 0 deletions image_test/POKEFT_Charizard.png:Zone.Identifier
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[ZoneTransfer]
ZoneId=3
HostUrl=https://raw.githubusercontent.com/camohe90/platziretoDNFT/ef600a88d0c7be2e4e583792b82d46474feeb774/challenges_images/2-challenge/POKEFT_Charizard.png
3 changes: 3 additions & 0 deletions image_test/POKEFT_Charizard_gigantamax.png:Zone.Identifier
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[ZoneTransfer]
ZoneId=3
HostUrl=https://raw.githubusercontent.com/camohe90/platziretoDNFT/ef600a88d0c7be2e4e583792b82d46474feeb774/challenges_images/2-challenge/POKEFT_Charizard_gigantamax.png
3 changes: 3 additions & 0 deletions image_test/POKEFT_Charizard_max.png:Zone.Identifier
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[ZoneTransfer]
ZoneId=3
HostUrl=https://raw.githubusercontent.com/camohe90/platziretoDNFT/ef600a88d0c7be2e4e583792b82d46474feeb774/challenges_images/2-challenge/POKEFT_Charizard_max.png
Binary file added image_test/Pinata_ByRDTP.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
48 changes: 48 additions & 0 deletions nft.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// 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 EAGNFTPLATZI is ERC721, ERC721URIStorage, Ownable {
using Counters for Counters.Counter;
string[] uriData = [
"https://gateway.pinata.cloud/ipfs/QmQrzxt1fvzoR6J91FTe58dd8Dg79CfPmPKhzhkDZKS1xP",
"https://gateway.pinata.cloud/ipfs/QmfWfqhhWFN1acW25iZ5chhDUBjPitgpRHHrHccpmetAmY",
"https://gateway.pinata.cloud/ipfs/QmYfnDNxyfAMPVaimRxQQ8jqqaR7QAE8GExdW8pD7F1FxK"
];

Counters.Counter private _tokenIdCounter;

constructor() ERC721("EAGNFTPLATZI", "EAGNPT") {}

function safeMint(address to) public onlyOwner {
uint256 tokenId = _tokenIdCounter.current();
_tokenIdCounter.increment();
_safeMint(to, tokenId);
_setTokenURI(tokenId, uriData[0]);
}

function changeData(uint256 _tokenId) public {
_setTokenURI(_tokenId, uriData[2]);
}

// 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);
}
}
Loading