StackAsk is a community where developers ask questions, share answers and learn from each others real-world experience, so every solved problem helps the next person who runs into it.
// contracts/GameItem.sol // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./extensions/ERC721URIStorage.sol"; import "./../../utils/Counters.sol"; contract GameItem is ERC721URIStorage { using Counters for Counters.Counter; Counters.Counter private _tokenIds; constructor() public ERC721("GameItem", "ITM") {} function awardItem(address player, string memory tokenURI) public returns (uint256) { _tokenIds.increment(); uint256 newItemId = _tokenIds.current(); _mint(player, newItemId); _setTokenURI(newItemId, tokenURI); return newItemId; } }
module.exports = { networks: { development: { host: "localhost", port: 8545, network_id: "*", gas: 0, from: "0x3c31b4b9d6c24bad29498f99aaa6914231362c7f" } }, compilers: { solc: { version: "0.8.0" } } };
const GameItem = artifacts.require("token/GameItem"); module.exports = function (deployer) { deployer.deploy( GameItem ); };
let contract = await GameItem.deployed() let contract = contract.awardItem("0x0070c24257f49e73359cd8eff347bfd5e6081e23", "https://public.nftstatic.com/static/nft/zipped/4d7dfb4cdffc43a583c71c1bb5e07597_zipped.png") contract.ownerOf(1) contract.tokenURI(1)
truffle(development)> contract.ownerOf(1) '0x0070C24257F49E73359Cd8eff347bfD5e6081E23' truffle(development)> contract.tokenURI(1) 'https://public.nftstatic.com/static/nft/zipped/4d7dfb4cdffc43a583c71c1bb5e07597_zipped.png' truffle(development)>
2.2K Point(s)
1.2K Point(s)
313 Point(s)
178 Point(s)
138 Point(s)
Input your email to receive reset password link, or if you remember your password, you can click