Variants | Clear | Drizzle | Rain | Thunderstorm |
---|---|---|---|---|
Taipei | ![]() |
![]() |
![]() |
![]() |
Tokyo | ![]() |
![]() |
![]() |
![]() |
-
Clone the project
git clone https://github.com/leonasdev/city-weather-nft
-
Install dependencies
pnpm install
-
Compile contracts
pnpm compile
-
Setting the
.env
file- Adjust values in
.env.example
and rename it to.env
- Adjust values in
-
Deploy contract to sepolia test network
npx hardhat run scripts/deploy.ts --network sepolia
-
Minting token
-
const contractAddress = "0xXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; // replace it with contract address const DNFT = await ethers.getContractFactory("CityWeatherNFT"); const dnft = DNFT.attach(contractAddress); console.log("Minting..."); await dnft.mint(); console.log("Done.");
npx hardhat run scripts/index.ts --network sepolia
-
-
Checking your NFT
- Import nft contract in Matamask to observe your NFT token
- Token ID must start with
1
-
Fund contract LINK token
- See: https://docs.chain.link/resources/fund-your-contract#send-funds-to-your-contract
- Funding
3
LINK should enough (can withdraw latter)
-
Transfer your NFT token to another accoount
-
Waitting for fulfillment
- You can check status of request by:
const contractAddress = "0xXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; // replace it with contract address const DNFT = await ethers.getContractFactory("CityWeatherNFT"); const dnft = DNFT.attach(contractAddress); console.log("Last request status:"); console.log(await dnft.s_requests(await dnft.requestIds(await dnft.lastRequestId())));
npx hardhat run scripts/index.ts --network sepolia
- Wait
fulfilled
totrue
- You can check status of request by:
-
Checking your NFT in another account
- You need import NFT contract again in another account
-
Observe that NFT transform its appearance!
-
Withdraw your LINK token
-
const contractAddress = "0xXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; // replace it with contract address const DNFT = await ethers.getContractFactory("CityWeatherNFT"); const dnft = DNFT.attach(contractAddress); await dnft.withdrawLink();
npx hardhat run scripts/index.ts --network sepolia
-
- Sodility Solidity is an object-oriented, high-level language for implementing smart contracts. Smart contracts are programs that govern the behavior of accounts within the Ethereum state.
- Sepolia Testnet Sepolia was a proof-of-authority testnet created in October 2021 by Ethereum core developers and maintained ever since.
- Hardhat Hardhat is a development environment for Ethereum software. It consists of different components for editing, compiling, debugging and deploying your smart contracts and dApps, all of which work together to create a complete development environment.
- OpenZeppelin Contracts OpenZeppelin Contracts helps you minimize risk by using battle-tested libraries of smart contracts for Ethereum and other blockchains. It includes the most used implementations of ERC standards.
- Chainlink
- Chainlink VRFv2 Chainlink VRF provides cryptographically secure randomness for your blockchain-based applications.
- Chainlink Any API Connecting to any API with Chainlink enables your contracts to access to any external data source through our decentralized oracle network.
- OpenWeatherAPI Access current weather data for any location including over 200,000 cities
- IPFS A peer-to-peer hypermedia protocol designed to preserve and grow humanity's knowledge by making the web upgradeable, resilient, and more open.
- Metamask Available as a browser extension and as a mobile app, MetaMask equips you with a key vault, secure login, token wallet, and token exchange—everything you need to manage your digital assets.
- Auto fund LINK token when deployed
- Handle secret key on chain (openweather api key)