ERC721 | ERC-721 Token based on non-finalised spec | Blockchain library
kandi X-RAY | ERC721 Summary
kandi X-RAY | ERC721 Summary
Scaleable ERC-721 Token based on standard found here. The "standard" directory contains interfaces for relevant standards. The mutability and visibility of some functions in the interface files have been modified. This is done in accordance with the standard, and does not affect the function signatures, nor the interfaceIDs. The "libraries" directory contains required libraries, such as "SafeMath.sol" for preventing sneaky business with overflows and such. TokenERC721.sol adheres to only the most basic of the standards, that being in ERC721.sol. It is fully scalable, but tokens have no metadata. The only parameter the constructor takes is the total number of tokens. For scalability, tokenIds start at 1, and increment by 1. Initially, the contract creator owns all tokens in the contract. The tokenIds don't start at 0 is because 0 is the default value of ints, which I plan to take advantage of in the future (by using the 0 val as invalid). When tokens are created during contract deployment (with initialTokens), it's fully scalable because it costs the same to create 1 as it does to create 10,000. There is also an optional public function, only callable by the contract creator for issuing more tokens, but in order to conform to the event emitting requirements, this function is slightly less scalable because it needs to emit an event for each token that gets created (so gas cost is linearly proportional to number of tokens being minted). TokenERC721Metadata.sol extends TokenERC721.sol and adheres both to the basic 721 standard, and also the ERC721Metadata.sol standard, which gives the token contract a name and symbol (as with the ERC20 standard), as well as giving each token a URI for a file which contains metadata for the token. In order to keep the contract scalable, the metadata contract has a "uriBase" parameter, which is a string (stored as bytes). When the tokenURI function is called, the contract returns a string which is the uriBase concatenated with the tokenId. This means each token's URI doesn't need to be manually defined. It's assumed that the URI base will take the form of "something.com/" with the trailing "/", but it's not required so long as the concatenated form resolves to a file with the tokens metadata. TokenERC721Enumerable.sol extends TokenERC721.sol aswell, and adheres to basic 721 and also the ERC721Enumerable.sol standard, which allows token lookup via index aswell as token ID.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of ERC721
ERC721 Key Features
ERC721 Examples and Code Snippets
Community Discussions
Trending Discussions on ERC721
QUESTION
I understand why it's important that all nodes on the Ethereum mainnet must execute any smart contract function call which changes the internal state of the contract or the chain. (For example, transfers from one account to another ec.)
What I'm wondering is, if its true that every node must execute every function called on any smart contract, even if the function doesn't result in a state change.
For example, if an ERC721 smart contract has a function "getName()" which just returns the name of the artwork the NFT represents which is stored in the NFt. Let's say joe connects to the network, and wants executes getName() on a contract. Does that mean that all 9,000 nodes end up spinning cycles executing getName(), even though Joe only needs it to be executed once? Does the gas cost of running "getName()" compensate each of the nodes for the overhead of running "getName()"? If that is true (that every node gets paid) will gas get even more expensive as more nodes join the pool?
Is one of the reasons gas prices are high is because of the inefficiency of every node having to execute every function called on a smart contract, even those that have no effect on state?
If so it would seem to be a very (and perhaps unnecessarily) expensive proposition to execute a computationally intensive but "pure" (no side effects) function on Ethereum, right?
Thanks. apologies for the possibly naive question!
...ANSWER
Answered 2021-Jun-11 at 08:41There's a difference between a transaction (can make state changes - but doesn't need to), and a call (read-only, cannot make state changes).
I'll start with the call simply because it's easier.
When a node performs a call, it executes the contract function that most likely reads from storage, stores to memory, and returns from memory.
Example:
QUESTION
I'm currently building a ERC721 compliant contract and have published the contract here: https://ropsten.etherscan.io/address/0xa513bc0a0d3af384fefcd8bbc1cc0c9763307c39 - I'm now attempting to verify and publish the contract source code
The start of my file looks like so:
...ANSWER
Answered 2021-May-28 at 15:51Simply put I had to go down a rabbit hole to work this out as I'm pretty new to Solidity.
I had to do the following;
- Learn and use https://www.trufflesuite.com/ to setup a project and put my contract there (Using Ganache helped a lot with testing for anyone new to Solidity too)
- Use HD Wallet provider package and follow tutorial here to get it on ropsten Etherscan https://medium.com/coinmonks/5-minute-guide-to-deploying-smart-contracts-with-truffle-and-ropsten-b3e30d5ee1e
- Finally, use truffle-plugin-verify https://github.com/rkalis/truffle-plugin-verify to verify the contract on Etherscan
All in all, I am pretty sure there is no way within the Etherscan web app to verify a contract that contains an imported file.
The final product is here if anyone is interested in seeing how I structured it all https://github.com/lukecurtis93/viper-nft (it's just a CryptoKitties clone I found online as a base and updated it all)
QUESTION
Most of the ERC721 examples using Open Zeppelin I see require the mint function to have an access control where only the owner of the contract is allowed to call the function. For example,
...ANSWER
Answered 2021-May-19 at 23:10The ERC-721 standard does not define a "best" or "correct" way to mint new tokens (such as whether it should be open or restricted) and it's up to each contract developer to implement or omit the minting feature in a way that reflects their needs.
Creating of NFTs ("minting") and destruction NFTs ("burning") is not included in the specification. Your contract may implement these by other means. Please see the event documentation for your responsibilities when creating or destroying NFTs.
But having a whitelist of addresses that are authorized to mint new tokens (e.g. MINTER_ROLE
or onlyOwner
) seems to be more common than allowing anyone to freely mint new tokens.
Even though it's theoretically possible to deploy new contract each time a new token is minted, it's not a standard approach (and I personally haven't seen any contract that does it). In most cases the minting process "just" creates a new ID, stores a new string/URL value associated with the ID, associates this new token with an owner address (of the token, not a contract owner), plus updates some metadata such as amount of tokens owned by an address (see example below).
The token owner can then transfer their tokens, give anyone control over their tokens, and do other stuff depending on the contract implementation.
The mappings that you point out in your question (_owners
and _balances
) suggest that they store token owner (not contract owner) addresses as well as amount of tokens held by each address.
Example:
Contract owner mints token ID
1
to address0x123
.Value of
_owners[1]
is0x123
(was 0, the default value)Value of
_balances[0x123]
becomes1
(was 0, the default value)
Contract owner mints token ID
2
to address0x123
.Value of
_owners[1]
is still0x123
Value of
_owners[2]
is now0x123
(was 0, the default value)Value of
_balances[0x123]
becomes2
(because they now own 2 tokens)
QUESTION
I'm currently using ERC721PresetMinterPauserAutoId for a smart contract and the Web3.js library in the Node.js backend server. When I try to call the mint function using this Web3 API:
...ANSWER
Answered 2021-Apr-20 at 07:56Install a Web3.js middleware layer that signs transactions locally, instead of sending a JSON-RPC method to Infura.
One of the solutions is Truffle HDWallet.
QUESTION
I am following along the documentation here: https://docs.alchemyapi.io/alchemy/tutorials/how-to-create-an-nft/how-to-mint-a-nft. And have a smart contract of form:
...ANSWER
Answered 2021-Apr-16 at 08:51OpenZeppelin's Ownable.sol defines the default owner
value as the contract deployer. You can later change it by calling transferOwnership()
or renounce the owner (i.e. set to 0x0
) by calling renounceOwnership()
.
The onlyOwner
modifier reverts the transaction if it's not sent by the current owner
. (see the code)
So you need to call the mintNFT()
function from the same address that deployed the contract, because that's the current owner
. Or you can change the owner
first by calling transferOwnership()
(from the current owner
address).
Removing the onlyOwner
modifier from the mintNFT()
function would allow anyone to call the function.
QUESTION
ANSWER
Answered 2021-Apr-18 at 11:19Your ERC721Full .sol
has a space in the name, before the dot.
Remove the space, so that it's ERC721Full.sol
, and you'll be able to import it.
QUESTION
I want to override the following inherited function:
...ANSWER
Answered 2021-Apr-18 at 09:32It's a visibility issue.
If you want to access the _baseURI
property in a derived contract, you need to make it at least internal
(it's currently private
).
Which also means copying a set of contracts locally so that you can update the ERC721Metadata.sol
and import the updated version (and not the remote version) from the other contracts.
The _setBaseURI()
function alone can be overridden because it's visible from your contract.
Private functions and state variables are only visible for the contract they are defined in and not in derived contracts.
Cannot access private property in a derived contract.
Source of the quote: https://docs.soliditylang.org/en/v0.8.3/contracts.html#visibility-and-getters
QUESTION
I just uploaded a folder of 5 images to IPFS (using the Mac Desktop IPFS Client App, so it was a very simple drag and drop operation.)
So being that I’m the one that created and published this folder, does that mean that I’m the only one that’s allowed to make further modifications to it - like adding or deleting more images from it? Or can anyone out there on IPFS do that as well?
If they can, is there a way to prevent that from happening?
=======================================
UPDATED QUESTION:
My specific use-case has to do with updating the metadata of ERC721 Tokens - after they’ve already been minted.
Imagine for example a game where certain objects - like say a magical sword - gains special powers after a certain amount of usage or after the completion of certain missions by its owner. So we’d want to update this sword’s attributes by editing it’s Metadata and re-committing this updated metadata file to the Blockchain.
If our game has 100 swords for example, and we initially uploaded to IPFS a folder containing all 100 json files (one for each sword), then I’m pretty sure IPFS still let’s you access the specific files within the hashed-folder by their specific human-readable names (and not only by their hash.)
So if our sword happens to be sword #76, and our naming convention for our JSON files was of this format: “sword000.json”
, then sword#76’s JSON metadata file would have a path such as:
http://ipfs.infura.io/QmY2xxxxxxxxxxxxxxxxxxxxxx/sword076.json
If we then edited the “sword076.json“ file and drag-n-dropped it back into our master JSON folder, it would obviously cause that folder’s Hash/CID value to change. BUT, as long as we’re able update our Solidity Contract’s “tokenURI” method to look for and serve our “.json” files from this newly updated HASH/CID folder name, we could still refer to the individual files within it by their regular English names. Which means we’d be good to go.
Whether or not this is a good scheme to employ is something we can definitely discuss, but I FIRST want to go back to my original question/concern, which is that I want to make sure that WE are the ONLY ones that can update the contents of our folder - and that no one else has permission to do that.
Does that make sense?
...ANSWER
Answered 2021-Apr-08 at 18:26IPFS is immutable, meaning when you add your directory along with the files, the directory gets a unique CID based on the contents of the directory. So in a sense, nobody can modify it, not even you, because it's immutable. I believe this confusion can be resolved with more background on how IPFS works.
When you add things to IPFS each file is hashed, and given a CID. The same is true for directories, but their CID can more easily be understood as a sum of the contents of the directory. So if any files in the directory are updated, added, or deleted, the directory gets a new CID.
Understanding this, if someone else added the exact same content in the exact same way, they'd end up with the exact same CID! With this, if two people added the same CID, and a third person requested that file (or directory), both nodes would be able to serve the data, as we know it's exactly the same. The same is true if you simply shared your CID and another node pinned it, both nodes would have the same data, so if anyone requested it, both nodes would be able to serve it.
So your local copy, cannot be edited by anyone. In a sense, if you're relying on the IPFS CID as the address of your data, not even by you! This is why IPFS is typically referred to as "immutable", because any data you request via an IPFS CID will always be the same. If you change any of the data, you'll get a new CID.
More info can be found here: Content Addressing & Immutability
If you read all this and thought "well what if I want mutable data?", I'd recommend looking into IPNS and possibly ipfs-sync if you're looking for a tool to automatically update IPNS for you.
QUESTION
I have a newby ethereum question--just getting started and trying to understand the Ethereum dev environment.
I have a very simple 721 test contract that I deployed to Ropsten and I can use REMIX to use it and it works to mint and to view balance of tokens (tokenCounter) etc.
Here is the 'contract' : https://ropsten.etherscan.io/address/0x97E0175415cB7D758cFB0ffc27Be727360664B90
...ANSWER
Answered 2021-Apr-01 at 14:28Solution: I had the wrong address in the transaction object. I had the account address and not the contract address. Correction below.
QUESTION
I'm not having so much experience with ERC721 token standard, currently I'm working on a real-estate DAPP. I have a question. if I want to add external information related to a specific property like Location, Price, property number etc. every time if a new property register, what will be the best way to do that..?? but I don't want this with solidity Struct, is it possible to extend the ERC721 Metadata Interface Contract
?? or any other solution??
I have tried almost everything but I think I'm missing something.
...ANSWER
Answered 2021-Mar-29 at 16:43If you want to store the data on-chain, a mapping (uint256 => Property)
, where the uint256
is the token ID and Property
is "struct(location, price, ...)", containing the data is probably the cheapest option gas-wise.
But since your question states you don't want to use struct, you can chose to store the data on-chain with a series of mappings:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install ERC721
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page