-
Notifications
You must be signed in to change notification settings - Fork 4
How to deploy a mintable TestNFT
Tobias Schubotz edited this page Dec 3, 2020
·
1 revision
This guide shows how to deploy a mintable TestNFT via Remix.
- Go to https://remix.ethereum.org/
- Click
+
in the file explorer to create a new file
- Enter a filename of your liking, e.g.
TestNFT.sol
- Paste the following smart contract code:
// contracts/TestNFT.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.0;
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v3.2.0/contracts/token/ERC721/ERC721.sol";
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v3.2.0/contracts/utils/Counters.sol";
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v3.2.0/contracts/utils/Strings.sol";
contract TestNFT is ERC721 {
using Counters for Counters.Counter;
Counters.Counter private _tokenIds;
constructor() public ERC721("TestNFT", "TNFT") {
_setBaseURI("https://www.google.com/search?q=");
}
function mint() public returns (uint256) {
return mintTo(msg.sender);
}
function mintTo(address to) public returns (uint256) {
_tokenIds.increment();
uint256 newItemId = _tokenIds.current();
_mint(to, newItemId);
_setTokenURI(newItemId, Strings.toString(newItemId));
return newItemId;
}
}
- Go to the "Compiler" section and hit "Compile". There should not be any error.
- Go to the "Deploy & run txs" section, select "Injected Web3". This will take your Metamask. Make sure Metamask is set to the desired network.
- Hit "Deploy" and sign with Metamask. This will deploy your contract. The address of your deployed contract will show up in the respective section:
A successful deploy to Rinkeby with verified contract code can be found here: https://rinkeby.etherscan.io/address/0x0263Ed323eb183F38621cC4d6FC7D767F6c51dC0