hashlips / hashlips_nft_contract Goto Github PK
View Code? Open in Web Editor NEWA simple NFT smart contract that works with the rest of the HashLips ecosystem.
License: MIT License
A simple NFT smart contract that works with the rest of the HashLips ecosystem.
License: MIT License
I believe I've done everything correct, all I did was edit the mint price and change to Polygon testnet yet no price is coming up at all when I go to mint. Tried on Rinkeby too. It just wants to charge the gas fee but no NFT cost at mint. Any tips? Any thing I couldve forgot to edit?
I deployed on Mumbai testnet, everything seems okay, but when it comes to transacting withdraw I have that famous error message from remix "gas estimation errored. Blah blah blah -3200..."
I double checked everything.
The contract has value in it since I've used the mint fiction from another different wallet address other than the owner one.
I transact withdraw from owner address.
I tried with Goving a specific value
And with no value at all
Doesn't work anyways.
Can please someone help me figuring out what am I doing wrong 🙏
The issue is that when I deployed the smart contract on the Kovan test net and checked out the test.opensea.io none of the images are showing. I need help to figure this out I have a relatively small collection only 28 pngs in that collection. Is it due to the test network? or maybe the file sizes are too big the largest being 30MB? if anyone has an answer it will be greatly appreciated.
Generated images and JSON, updated everything according to the video instructions and deployed the contract according to the instructions. Contract is out there running on Rinkeby but no images show up on the OpenSea.io test site. No hidden image, no NFT image, nothing. Would love to take my collection live but I don't trust the contract.
I'd pay someone good money to help me get this project over the finish line.
Regarding the 'ONLY WHITELIST', I tried to change the value to 'false' and it works properly in JavaScript VM. BUT when I tried to change the value to 'false' in Injected Web3, In the DAPP once click the 'MINT' button error occurred 'Warning! Error encountered during contract execution' Can you help this?
Upload to Opensea displays token_Id in place of the metadata 'name' attribute. I need the metadata name to display, not token_id.
Hi ,
When I am deploying on polygon testnet and trying to change the cost via the setcost function it doesn't work.
Ive first deploy the contract with the cost = 0.02 ether .
Once I 've verify and deploy the contract on polygonscan testnet Ive called the setCost function and put 1 and the transaction has been validated.
So when I try to mint , I can still mint with a value of 0.02 I am trying to understand but it should have rejected my transaction since Ive put 1 on the setCost function???
Moreover , Why do I have to specify the price of the mint item on polygonscan testnet and not on remix ?
I can't do too many Mint at once I get the following error.
Internal JSON-RPC error. { "code": -32000, "message": "gas required exceeds allowance (29970705)" }
I don't want to have to do 200 mint at a time.
To be faster, I'd like to mint the 10k in one go.
Detail: I am using the main polygon network, and the contract is below:
0xce55d7d4a457bb07b177acb43fe5d538028bf1c8
I'm also using the account responsible for creating the smart contract.
The max mint is set to 2000 and the cost is 11 matic.
I've already tried to do the same through polygonscan and with no success.
I hope someone responds as soon as possible, that would be of great help.
Thanks.
Hi , I deployed the contract on mainnet , when i am withdrawing the funds , some share of the total amount is being sent to hashlips address
why is it?? , if i am not wrong , you should mention in the readme that , you are taking some share of revenue of User's project for providing the smart contract , i mean its not wrong , if you are doing this , but atleast you should mention this publically
, so anyone who is using this smart contract , should be aware of this
Hi, converting this repo to a Hardhat project may allow for the following improvements:
I would be happy to create a PR for this, but I don't know if you are ok with it. I also decided to make a quick YouTube video that shows everything step-by-step in order save you some time (at least I hope so). @HashLips, I think you probably already know most of the stuff I'm showing in the video, but I thought it might be better to cover everything in detail so anyone can follow along.
Thank you for your time.
So, any suggestions? After days of trying to get REMIX to let me select Injected Web3, I jumped the gun and hit deploy before realizing that I had just started a new contract without flattening it. I have only added the contract name and id. Now what? Is there anyway I can edit this and reuse it? I know I cannot delete it but do not know the ways that I have left myself vulnerable with this contract. Any suggestions appreciated. Thank you.
Hello there
if you read about eip-2981, it allows the contract to signal the royalty fees to marketplaces, its not yet supported by opensea, but other marketplaces like looksrare, superrare and rariple do support it
I know you may see that OS is the leader and the one with the most volume, but missing the royalty fees usually happens with other marketplaces that sometimes the contract creator has no clue that his collection is being sold there.
I'll try to implement it in the low gas contract and push it for @HashLips for review, but implementation from the man himself gives it more credibility with the community IMO
Thanks for reading
For some reason this keeps creating a new value next to the token ID name. Is there any way to hide that? Problem is when uploading onto opensea, it keeps displaying the 10 digits added to the token name. For example it reads "SAMPLE" as "SAMPLE 1234567890" when it should read "SAMPLE" , metadata and base uri are correct. Why does this keep happening?
Function MaxMint per wallet not working, i can mint as much as i want with any wallets.
and do you know how can i configure whitelisted wallets here and legendary hidden images + reveal images?
Everything was working fine, but the images where not showing up on opensea for the hidden image. Only during the reveal function. So I redid the contract and now I keep getting the error "Invalid parameters: must provide an Ethereum address.". I get this error when I try to mint 2 on another wallet as a test. I'm using rinkeby network, contract pause is set to false. Correct contract is selected and metamask is showing the correct 2nd text wallet. For some reason I keep getting this error and it will not allow to make a transaction. I attempted with multiple wallets and still the same. Only the contract owner wallet address allows a second mind. Max mint is set to 2 and supply set to 4000. Ether is set at 0.02 and wei is doubled after getting it from calling the cost. I'm using the lower gas sol file. Had the same error on the flat file aswell. I'm using injected Web3 on Rinkeby. Someone please help, I dont know what i'm doing wrong, but I'm sure I am. Been going at it for days :(
Hi all - I just deployed my first contract using the code Hashlips shared with the community (thanks again!!). The only issue is that my hidden.json file isn't working. In short, the "hidden image" isn't showing after minting, and the metadata isn't updating on OpenSea either. I found a solution in a different thread, so I now know how this json file could be fixed. My only issue is that the contract has already been deployed, verified, and published.
Can I currently use the function setNotRevealedURI
in Remix to update the metadata now? Similar question for the SetBaseURI
function. Can this be used to update the metadata?
My thought is to:
Hoping that all this will allow me to update the contract and finally see the correct metadata on OpenSea.
Thanks in advance!
In the tutorial (Ultimate guide), Daniel leaves the cost set to 0.02 ether despite deploying it later on the polygon network. As he explains, "ether" just make it to be readable. I have three questions regarding this:
Hi , Friends
I want just to sell to 2 NFTs and i want you suggest me a simpe contract,
should i use that repo or is there any contract simple than that?
Thanks @HashLips Daniel <3
Waiting for help
Was set to 0.12 ETH, was working but when launched changed to 12 ETH and now I cant get back in and change the price
How can we upgrade our deployed smart contract?
Recently customized the Hashlips NFT contract and I am unable to mint on Etherscan (or Remix) when using my Ledger device. I receive the following error on Metamask: Please enable Blind signing or Contract data in the Ethereum app Settings. A similar error message is received on Remix: transact to (ProjectNameRedacted).mint errored: Please enable Blind signing or Contract data in the Ethereum app Settings.
Blind signing IS enabled on my Ledger and Ledger Live firmware/updates are all up-to-date. I am able to successfully mint through my version of the Hashlips NFT contract when I do not use the Ledger and use a Metamask hot wallet.
I found a potential issue, everything in the blockchain is public from outside even if the variables are set to private. The token constructor allows to set the baseURI before the tokens are revealed, in this case anyone could decode the contract storage and know in advance the tokens they will get before minting. Ideally the baseURI should not be allowed to be set until the tokens are revealed.
Im trying to verify a smart contract on etherscan test net and will be deploying on polygon when i can get it to verify.
Ive followed the Hashlips guide exactly (https://www.youtube.com/watch?v=fzH7Gjadmj0&t=5922s) but the copy button in remix does not copy the abi and byte code.
Im using SimpleNFT_flat.sol by the way
I carried on anyway but the contract will not verify. Brings up the unable to generate contract ByteCode and ABI. It then lists possible matches that it doesnt match with, despite on the list is a matching bytecode. https://ibb.co/Ss49CZ5
I deployed to testnet, clicked abi to copy it in the image, pasted that into hash ex, clicked parse and filled in the info at the bottom and tthen copied that into the constructor argument section.
https://ibb.co/9nZkXHh
https://ibb.co/hKjbgNW
https://ibb.co/Z2L9skt
Ive gone through every answer on here and google and nothing is fixing this.
Ive tried starting it from scratch, re deploying over and over again. Same issue. I just cant verify this thing. Everything is matching, compiler version, whether its optimised or not, the optimisation.
Would love some help on this.
Hi there im pretty new to this n im not entirely sure whats wrong. But i keep getting this error when trying to put in a wallet address for the owner.
ERROR Code:
TypeError: Wrong argument count for call: 1 arguments given but expected 0
REMIX Code:
function withdraw() public payable onlyOwner {
// This will pay HashLips 5% of the initial sale.
// You can remove this if you want, or keep it in to support HashLips and his channel.
// =============================================================================
(bool hs, ) = payable(0x943590A42C27D08e3744202c4Ae5eD55c2dE240D).call{value: address(this).balance * 5 / 100}("");
require(hs);
// =============================================================================
// This will payout the owner 95% of the contract balance.
// Do not remove this otherwise you will not be able to withdraw the funds.
// =============================================================================
(bool os, ) = payable(owner(0x818B283213873Df5600cC51B9F4451566028679E)).call{value: address(this).balance}("");
require(os);
// =============================================================================
}
}
Not sure if i should be adding a owner wallet there or not, any help would be much appreciated.
when creating a contract, it displays an error like this
https://ibb.co/znM4W9X
Help friends. After checking the test contract, which turned out to be successful for me, I started the transaction of this contract through polygon matic. Metamask opened, I confirmed the payment, but then this appears...
there is enough matic on the wallet (actions on the remix)
creation of name collection errored: [ethjs-query] while formatting outputs from RPC '{"value":{"code":-32603,"data":{"code":-32000,"message":"transaction underpriced"}}}'
I have a problem.
When i deploy the contract and mint my NFTs the not revealed pictures are not showing up and i cant see them. Whats the issue?
I airdropped 1000 NFTs to the holders.
But when I tried to call walletOfOwner function to check holding NFTs, it raises Out of Gas Error.
It works for holders holding earlier NFTs (tokenIDs are not high) but doesn't for for others.
How can this be fixed?
I did maybe reset my remix 5 times, each time re"Transact" and then minting an image to test it. Each new "Transact" I would get a "V" then the transaction version number. Assuming it means new version... but then I got random letters after a dash on the 5th and 6th transaction I tested. I'm hoping when I Transact on the real network I won't get these "V's" or "-RaNdoM".
Example:
1st Transact: NFT NAME
2nd Transact: NFT NAME V2
3rd Transact: NFT NAME V3
4th Transact: NFT NAME V4
5th Transact: NFT NAME - PdpVusXINl
6th Transact: NFT NAME - FvTpuUIEpl
I am just a bit confused about these two and want to be sure that I understand it right.
When I set the cost
inside the contract or change it later with setCost method on remix, this is the cost for minting (for example the cost to mint nft on the Dapp during pre-sale).
Meanwhile, I can only manually list for sale and set the cost on Opensea for those that are pre-minted (for example the rest of the nfts inside the same collection that weren't sold during pre-sale and that I have to pre-mint so they show up on Opensea).
The cost in the contract does not affect the cost I set on Opensea in any way (?)
Is my understanding correct?
when mint nft some other wallets address rise this issue and but remix VM network nft create by other wallets successfullly.
Hello,
Can you update the ERC 1155 contract with the Lower Gas functionality?
I love the idea of being able to mint additional NFTs to the contract after it has been deployed. However, it can expensive to do so with the current ERC 1155 contract. Lower gas on minting would be amazing.
Do I need to debug after I mint on remix? I have minted a couple NFTS and non show up on open sea test net. I ran debug and I got an " Invalid JSON RPC response" Anyone have the same or similar issue? If not any trouble shooting suggestions ? Im new to coding (actually this is my first coding project) so Im not really sure where to start. Any feedback would be great!
How to add freeze NFT metadata like boredape in this code?
When somebody use my mint button i want him to receive a random NFT from this transaction.
When i use mint button (mintAmount = 2) my NFT's metadata's will be like,
ipfs://image_link/1.json
ipfs://image_link/2.json
But i dont want this. I want to receive my NFT's randomly. Like this,
ipfs://image_link/578.json
ipfs://image_link/877.json
I hope i was clear. How can i do that and can this process increase gas fees?
Error: Unsupported image type
at setSource (/Users/Usr/Documents/nft codiing/hashlips_art_engine-1.1.2_patch_v1/node_modules/canvas/lib/image.js:91:13)
at Image.set (/Users/Usr/Documents/nft codiing/hashlips_art_engine-1.1.2_patch_v1/node_modules/canvas/lib/image.js:62:9)
at /Users/Usr/Documents/nft codiing/hashlips_art_engine-1.1.2_patch_v1/node_modules/canvas/index.js:34:15
at new Promise ()
at loadImage (/Users/Usr/Documents/nft codiing/hashlips_art_engine-1.1.2_patch_v1/node_modules/canvas/index.js:23:10)
at /Users/Usr/Documents/nft codiing/hashlips_art_engine-1.1.2_patch_v1/src/main.js:184:25
at new Promise ()
at Usr (/Users/Usr/Documents/nft codiing/hashlips_art_engine-1.1.2_patch_v1/src/main.js:183:10)
at /Users/Usr/Documents/nft codiing/hashlips_art_engine-1.1.2_patch_v1/src/main.js:364:31
at Array.forEach ()
HI, It's possible to add whitlist with this contract? ty
Hi,
I have used and deployed this contract and the problem is when i mint the NFT with 0.1 Matic if go through
is there a way to update this with the existing contract ?
// SPDX-License-Identifier: MIT
// Amended by HashLips
/**
!Disclaimer!
These contracts have been used to create tutorials,
and was created for the purpose to teach people
how to create smart contracts on the blockchain.
please review this code on your own before using any of
the following code for production.
HashLips will not be liable in any way if for the use
of the code. That being said, the code has been tested
to the best of the developers' knowledge to work as intended.
*/
// File: @openzeppelin/contracts/utils/introspection/IERC165.sol
pragma solidity ^0.8.0;
/**
interfaceId
. See the corresponding// File: @openzeppelin/contracts/token/ERC721/IERC721.sol
pragma solidity ^0.8.0;
/**
@dev Required interface of an ERC721 compliant contract.
/
interface IERC721 is IERC165 {
/*
tokenId
token is transferred from from
to to
./**
owner
enables approved
to manage the tokenId
token./**
owner
enables or disables (approved
) operator
to manage all of its assets./**
owner
's account./**
tokenId
token.tokenId
must exist./**
tokenId
token from from
to to
, checking first that contract recipientsfrom
cannot be the zero address.to
cannot be the zero address.tokenId
token must exist and be owned by from
.from
, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}.to
refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer./**
tokenId
token from from
to to
.from
cannot be the zero address.to
cannot be the zero address.tokenId
token must be owned by from
.from
, it must be approved to move this token by either {approve} or {setApprovalForAll}./**
to
to transfer tokenId
token to another account.tokenId
must exist./**
tokenId
token.tokenId
must exist./**
operator
as an operator for the caller.operator
cannot be the caller./**
operator
is allowed to manage all of the assets of owner
./**
tokenId
token from from
to to
.from
cannot be the zero address.to
cannot be the zero address.tokenId
token must exist and be owned by from
.from
, it must be approved to move this token by either {approve} or {setApprovalForAll}.to
refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.// File: @openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol
pragma solidity ^0.8.0;
/**
@title ERC-721 Non-Fungible Token Standard, optional enumeration extension
@dev See https://eips.ethereum.org/EIPS/eip-721
/
interface IERC721Enumerable is IERC721 {
/*
/**
owner
at a given index
of its token list.owner
's tokens./**
index
of all the tokens stored by the contract.// File: @openzeppelin/contracts/utils/introspection/ERC165.sol
pragma solidity ^0.8.0;
/**
return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
// File: @openzeppelin/contracts/utils/Strings.sol
pragma solidity ^0.8.0;
/**
@dev String operations.
*/
library Strings {
bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef";
/**
@dev Converts a uint256
to its ASCII string
decimal representation.
*/
function toString(uint256 value) internal pure returns (string memory) {
// Inspired by OraclizeAPI's implementation - MIT licence
// https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol
if (value == 0) {
return "0";
}
uint256 temp = value;
uint256 digits;
while (temp != 0) {
digits++;
temp /= 10;
}
bytes memory buffer = new bytes(digits);
while (value != 0) {
digits -= 1;
buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
value /= 10;
}
return string(buffer);
}
/**
uint256
to its ASCII string
hexadecimal representation./**
uint256
to its ASCII string
hexadecimal representation with fixed length.// File: @openzeppelin/contracts/utils/Address.sol
pragma solidity ^0.8.0;
/**
@dev Collection of functions related to the address type
/
library Address {
/*
@dev Returns true if account
is a contract.
[IMPORTANT]
====
It is unsafe to assume that an address for which this function returns
false is an externally-owned account (EOA) and not a contract.
Among others, isContract
will return false for the following
types of addresses:
====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize, which returns 0 for contracts in
// construction, since the code is only stored at the end of the
// constructor execution.
uint256 size;
assembly {
size := extcodesize(account)
}
return size > 0;
}
/**
@dev Replacement for Solidity's transfer
: sends amount
wei to
recipient
, forwarding all available gas and reverting on errors.
https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
of certain opcodes, possibly making contracts go over the 2300 gas limit
imposed by transfer
, making them unable to receive funds via
transfer
. {sendValue} removes this limitation.
https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
IMPORTANT: because control is transferred to recipient
, care must be
taken to not create reentrancy vulnerabilities. Consider using
{ReentrancyGuard} or the
https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
call
. Acall
is an unsafe replacement for a function call: use thistarget
reverts with a revert reason, it is bubbled up by thistarget
must be a contract.target
with data
must not revert./**
functionCall
], but witherrorMessage
as a fallback revert reason when target
reverts./**
functionCall
],value
wei to target
.value
.payable
./**
@dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[functionCallWithValue
], but
with errorMessage
as a fallback revert reason when target
reverts.
Available since v3.1.
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
require(isContract(target), "Address: call to non-contract");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
functionCall
],/**
@dev Same as {xref-Address-functionCall-address-bytes-string-}[functionCall
],
but performing a static call.
Available since v3.3.
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
functionCall
],/**
@dev Same as {xref-Address-functionCall-address-bytes-string-}[functionCall
],
but performing a delegate call.
Available since v3.4.
*/
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
require(isContract(target), "Address: delegate call to non-contract");
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
@dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
revert reason using the provided one.
Available since v4.3.
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
// File: @openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol
pragma solidity ^0.8.0;
/**
@title ERC-721 Non-Fungible Token Standard, optional metadata extension
@dev See https://eips.ethereum.org/EIPS/eip-721
/
interface IERC721Metadata is IERC721 {
/*
/**
/**
tokenId
token.// File: @openzeppelin/contracts/token/ERC721/IERC721Receiver.sol
pragma solidity ^0.8.0;
/**
tokenId
token is transferred to this contract via {IERC721-safeTransferFrom}operator
from from
, this function is called.IERC721.onERC721Received.selector
.// File: @openzeppelin/contracts/utils/Context.sol
pragma solidity ^0.8.0;
/**
@dev Provides information about the current execution context, including the
sender of the transaction and its data. While these are generally available
via msg.sender and msg.data, they should not be accessed in such a direct
manner, since when dealing with meta-transactions the account sending and
paying for execution may not be the actual sender (as far as an application
is concerned).
This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}
// File: @openzeppelin/contracts/token/ERC721/ERC721.sol
pragma solidity ^0.8.0;
/**
@dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including
the Metadata extension, but not including the Enumerable extension, which is available separately as
{ERC721Enumerable}.
*/
contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
using Address for address;
using Strings for uint256;
// Token name
string private _name;
// Token symbol
string private _symbol;
// Mapping from token ID to owner address
mapping(uint256 => address) private _owners;
// Mapping owner address to token count
mapping(address => uint256) private _balances;
// Mapping from token ID to approved address
mapping(uint256 => address) private _tokenApprovals;
// Mapping from owner to operator approvals
mapping(address => mapping(address => bool)) private _operatorApprovals;
/**
name
and a symbol
to the token collection./**
/**
/**
/**
/**
/**
@dev See {IERC721Metadata-tokenURI}.
*/
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token");
string memory baseURI = _baseURI();
return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : "";
}
/**
baseURI
and the tokenId
. Empty/**
@dev See {IERC721-approve}.
*/
function approve(address to, uint256 tokenId) public virtual override {
address owner = ERC721.ownerOf(tokenId);
require(to != owner, "ERC721: approval to current owner");
require(
_msgSender() == owner || isApprovedForAll(owner, _msgSender()),
"ERC721: approve caller is not owner nor approved for all"
);
_approve(to, tokenId);
}
/**
@dev See {IERC721-getApproved}.
*/
function getApproved(uint256 tokenId) public view virtual override returns (address) {
require(_exists(tokenId), "ERC721: approved query for nonexistent token");
return _tokenApprovals[tokenId];
}
/**
@dev See {IERC721-setApprovalForAll}.
*/
function setApprovalForAll(address operator, bool approved) public virtual override {
require(operator != _msgSender(), "ERC721: approve to caller");
_operatorApprovals[_msgSender()][operator] = approved;
emit ApprovalForAll(_msgSender(), operator, approved);
}
/**
/**
@dev See {IERC721-transferFrom}.
*/
function transferFrom(
address from,
address to,
uint256 tokenId
) public virtual override {
//solhint-disable-next-line max-line-length
require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");
_transfer(from, to, tokenId);
}
/**
/**
/**
tokenId
token from from
to to
, checking first that contract recipients_data
is additional data, it has no specified format and it is sent in call to to
.from
cannot be the zero address.to
cannot be the zero address.tokenId
token must exist and be owned by from
.to
refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer./**
tokenId
exists._mint
),_burn
)./**
spender
is allowed to manage tokenId
.tokenId
must exist./**
tokenId
and transfers it to to
.tokenId
must not exist.to
refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer./**
_safeMint
], with an additional data
parameter which is/**
@dev Mints tokenId
and transfers it to to
.
WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible
Requirements:
tokenId
must not exist.to
cannot be the zero address.Emits a {Transfer} event.
*/
function _mint(address to, uint256 tokenId) internal virtual {
require(to != address(0), "ERC721: mint to the zero address");
require(!_exists(tokenId), "ERC721: token already minted");
_beforeTokenTransfer(address(0), to, tokenId);
_balances[to] += 1;
_owners[tokenId] = to;
emit Transfer(address(0), to, tokenId);
}
/**
@dev Destroys tokenId
.
The approval is cleared when the token is burned.
Requirements:
tokenId
must exist.Emits a {Transfer} event.
*/
function _burn(uint256 tokenId) internal virtual {
address owner = ERC721.ownerOf(tokenId);
_beforeTokenTransfer(owner, address(0), tokenId);
// Clear approvals
_approve(address(0), tokenId);
_balances[owner] -= 1;
delete _owners[tokenId];
emit Transfer(owner, address(0), tokenId);
}
/**
@dev Transfers tokenId
from from
to to
.
As opposed to {transferFrom}, this imposes no restrictions on msg.sender.
Requirements:
to
cannot be the zero address.tokenId
token must be owned by from
.Emits a {Transfer} event.
*/
function _transfer(
address from,
address to,
uint256 tokenId
) internal virtual {
require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer of token that is not own");
require(to != address(0), "ERC721: transfer to the zero address");
_beforeTokenTransfer(from, to, tokenId);
// Clear approvals from the previous owner
_approve(address(0), tokenId);
_balances[from] -= 1;
_balances[to] += 1;
_owners[tokenId] = to;
emit Transfer(from, to, tokenId);
}
/**
to
to operate on tokenId
/**
/**
from
and to
are both non-zero, from
's tokenId
will beto
.from
is zero, tokenId
will be minted for to
.to
is zero, from
's tokenId
will be burned.from
and to
are never both zero.// File: @openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol
pragma solidity ^0.8.0;
/**
@dev This implements an optional extension of {ERC721} defined in the EIP that adds
enumerability of all the token ids in the contract as well as all token ids owned by each
account.
*/
abstract contract ERC721Enumerable is ERC721, IERC721Enumerable {
// Mapping from owner to list of owned token IDs
mapping(address => mapping(uint256 => uint256)) private _ownedTokens;
// Mapping from token ID to index of the owner tokens list
mapping(uint256 => uint256) private _ownedTokensIndex;
// Array with all token ids, used for enumeration
uint256[] private _allTokens;
// Mapping from token id to position in the allTokens array
mapping(uint256 => uint256) private _allTokensIndex;
/**
/**
/**
/**
/**
@dev Hook that is called before any token transfer. This includes minting
and burning.
Calling conditions:
from
and to
are both non-zero, from
's tokenId
will betransferred to to
.
from
is zero, tokenId
will be minted for to
.to
is zero, from
's tokenId
will be burned.from
cannot be the zero address.to
cannot be the zero address.To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(
address from,
address to,
uint256 tokenId
) internal virtual override {
super._beforeTokenTransfer(from, to, tokenId);
if (from == address(0)) {
_addTokenToAllTokensEnumeration(tokenId);
} else if (from != to) {
_removeTokenFromOwnerEnumeration(from, tokenId);
}
if (to == address(0)) {
_removeTokenFromAllTokensEnumeration(tokenId);
} else if (to != from) {
_addTokenToOwnerEnumeration(to, tokenId);
}
}
/**
/**
/**
@dev Private function to remove a token from this extension's ownership-tracking data structures. Note that
while the token is not assigned a new owner, the _ownedTokensIndex
mapping is not updated: this allows for
gas optimizations e.g. when performing a transfer operation (avoiding double writes).
This has O(1) time complexity, but alters the order of the _ownedTokens array.
@param from address representing the previous owner of the given token ID
@param tokenId uint256 ID of the token to be removed from the tokens list of the given address
*/
function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId) private {
// To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and
// then delete the last slot (swap and pop).
uint256 lastTokenIndex = ERC721.balanceOf(from) - 1;
uint256 tokenIndex = _ownedTokensIndex[tokenId];
// When the token to delete is the last token, the swap operation is unnecessary
if (tokenIndex != lastTokenIndex) {
uint256 lastTokenId = _ownedTokens[from][lastTokenIndex];
_ownedTokens[from][tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token
_ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index
}
// This also deletes the contents at the last position of the array
delete _ownedTokensIndex[tokenId];
delete _ownedTokens[from][lastTokenIndex];
}
/**
@dev Private function to remove a token from this extension's token tracking data structures.
This has O(1) time complexity, but alters the order of the _allTokens array.
@param tokenId uint256 ID of the token to be removed from the tokens list
*/
function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private {
// To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and
// then delete the last slot (swap and pop).
uint256 lastTokenIndex = _allTokens.length - 1;
uint256 tokenIndex = _allTokensIndex[tokenId];
// When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so
// rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding
// an 'if' statement (like in _removeTokenFromOwnerEnumeration)
uint256 lastTokenId = _allTokens[lastTokenIndex];
_allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token
_allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index
// This also deletes the contents at the last position of the array
delete _allTokensIndex[tokenId];
_allTokens.pop();
}
}
// File: @openzeppelin/contracts/access/Ownable.sol
pragma solidity ^0.8.0;
/**
@dev Contract module which provides a basic access control mechanism, where
there is an account (an owner) that can be granted exclusive access to
specific functions.
By default, the owner account will be the one that deploys the contract. This
can later be changed with {transferOwnership}.
This module is used through inheritance. It will make available the modifier
onlyOwner
, which can be applied to your functions to restrict their use to
the owner.
*/
abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
/**
/**
/**
onlyOwner
functions anymore. Can only be called by the current owner./**
newOwner
).function _setOwner(address newOwner) private {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
pragma solidity >=0.7.0 <0.9.0;
contract ULZZANG101 is ERC721Enumerable, Ownable {
using Strings for uint256;
string baseURI;
string public baseExtension = ".json";
uint256 public cost = 139.65 ether;
uint256 public maxSupply = 8888;
uint256 public maxMintAmount = 5;
bool public paused = false;
bool public revealed = true;
string public notRevealedUri;
constructor(
string memory _name,
string memory _symbol,
string memory _initBaseURI,
string memory _initNotRevealedUri
) ERC721(_name, _symbol) {
setBaseURI(_initBaseURI);
setNotRevealedURI(_initNotRevealedUri);
}
// internal
function _baseURI() internal view virtual override returns (string memory) {
return baseURI;
}
// public
function mint(uint256 _mintAmount) public payable {
uint256 supply = totalSupply();
require(!paused);
require(_mintAmount > 0);
require(_mintAmount <= maxMintAmount);
require(supply + _mintAmount <= maxSupply);
if (msg.sender != owner()) {
require(msg.value >= cost * _mintAmount);
}
for (uint256 i = 1; i <= _mintAmount; i++) {
_safeMint(msg.sender, supply + i);
}
}
function walletOfOwner(address _owner)
public
view
returns (uint256[] memory)
{
uint256 ownerTokenCount = balanceOf(_owner);
uint256[] memory tokenIds = new uint256;
for (uint256 i; i < ownerTokenCount; i++) {
tokenIds[i] = tokenOfOwnerByIndex(_owner, i);
}
return tokenIds;
}
function tokenURI(uint256 tokenId)
public
view
virtual
override
returns (string memory)
{
require(
_exists(tokenId),
"ERC721Metadata: URI query for nonexistent token"
);
if(revealed == false) {
return notRevealedUri;
}
string memory currentBaseURI = _baseURI();
return bytes(currentBaseURI).length > 0
? string(abi.encodePacked(currentBaseURI, tokenId.toString(), baseExtension))
: "";
}
//only owner
function reveal() public onlyOwner() {
revealed = true;
}
function setCost(uint256 _newCost) public onlyOwner() {
cost = _newCost;
}
function setmaxMintAmount(uint256 _newmaxMintAmount) public onlyOwner() {
maxMintAmount = _newmaxMintAmount;
}
function setNotRevealedURI(string memory _notRevealedURI) public onlyOwner {
notRevealedUri = _notRevealedURI;
}
function setBaseURI(string memory _newBaseURI) public onlyOwner {
baseURI = _newBaseURI;
}
function setBaseExtension(string memory _newBaseExtension) public onlyOwner {
baseExtension = _newBaseExtension;
}
function pause(bool _state) public onlyOwner {
paused = _state;
}
function withdraw() public payable onlyOwner {
(bool success, ) = payable(msg.sender).call{value: address(this).balance}("");
require(success);
}
}
I followed the video of ultimate guide. I managed to list some my nfts on Opensea. The problem is I can’t edit commission. Whenever I submit change, the error message 401 Not Authorized appears.
I really need your help
Hi, I had followed the How to create an NFT collection up until 1:30:00 and for some reason my NFT collection on Opensea testnet is not showing my hidden image. I had double checked to make sure that my hidden image and hidden metadata files were correctly written in ArtEngine and uploaded to Pinata correctly.
It had worked when I had used a different hidden image yesterday, so I am wondering if it's because my new hidden image may be too big or something?
This is what I am seeing on Opensea testnet
Thank you for any help!
Hi,
i saw some videos where there was a function to mint first 20 or so nfts to owner when deploying the contract.. but this repo doesnt have that function in it.. would it be added in later? or if someone can help me add that in?
thanks.
Seems like multiple people are having this issue.
I foolowed the newest video on how to generate and mint my collection, which was more than awesome and easy to follow.
I'm unsure if I missed something, but now do I need to go through every 1 of my 1000 NFTs and click Sell and put a price in?
I have put a number in the contract to 12 Ether. I also went back to the contract on polygonscan and set_Cost to 13,transaction goes through but no change on Opensea (people can only make an offer not buy now or bid).
Please can someone let me know how to fix this? Wouldn't mind setting up the same cost for every single NFT, as long as it's done in a batch.
Thank you kindly!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.