Git Product home page Git Product logo

nft-demo's Introduction

This is a repo demonstrating the code from the freecodecamp video.

It was inspired by the up to date nft-mix

nft-demo's People

Contributors

cromewar avatar patrickalphac avatar sevasoft avatar ssghost avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

nft-demo's Issues

Did you also have problems with verifying your code?

Looking at the repo it seems like you also tried to manually flatten the contract. Also see here

I ended up flattening the contract via remix and was able to upload the flattened .sol file, but that is horribly cumbersome. Did you somehow manage to solve this?

ValueError: Gas estimation failed: 'execution reverted'. This transaction will likely revert. If you wish to broadcast, you must set the gas limit manually

Brownie v1.19.3 - Python development framework for Ethereum

NftDemoProject is the active project.

Running 'scripts\advanced_collectible\create_collectible.py::main'...
Transaction sent: 0x4eb46d1f15867577d9496c8c60496b70bbc4dc1ad2d8f8c4b8d2d65e0c029114
Gas price: 9.8e-08 gwei Gas limit: 38176 Nonce: 58
LinkToken.transfer confirmed Block: 9693374 Gas used: 34706 (90.91%)

LinkToken.transfer confirmed Block: 9693374 Gas used: 34706 (90.91%)

Funded 0x55b2439e9cd9EDA30ADdBB1Cb854e2C812E11a68
File "C:\Users\Computer.local\pipx\venvs\eth-brownie\lib\site-packages\brownie_cli\run.py", line 51, in main
return_value, frame = run(
File "C:\Users\Computer.local\pipx\venvs\eth-brownie\lib\site-packages\brownie\project\scripts.py", line 110, in run
return_value = f_locals[method_name](*args, **kwargs)
File ".\scripts\advanced_collectible\create_collectible.py", line 10, in main
creation_transaction = advanced_collectible.createCollectible({"from": account})
File "C:\Users\Computer.local\pipx\venvs\eth-brownie\lib\site-packages\brownie\network\contract.py", line 1864, in call
return self.transact(*args)
File "C:\Users\Computer.local\pipx\venvs\eth-brownie\lib\site-packages\brownie\network\contract.py", line 1737, in transact
return tx["from"].transfer(
File "C:\Users\Computer.local\pipx\venvs\eth-brownie\lib\site-packages\brownie\network\account.py", line 644, in transfer
receipt, exc = self._make_transaction(
File "C:\Users\Computer.local\pipx\venvs\eth-brownie\lib\site-packages\brownie\network\account.py", line 727, in _make_transaction
raise VirtualMachineError(e) from None
File "C:\Users\Computer.local\pipx\venvs\eth-brownie\lib\site-packages\brownie\exceptions.py", line 93, in init
raise ValueError(str(exc)) from None
ValueError: Gas estimation failed: 'execution reverted'. This transaction will likely revert. If you wish to broadcast, you must set the gas limit manually.

Working with VRFcoordinatorV2Mock doesn't work?

when i try to run create_collectible with vrfV2Mock configured it gives me the error:
brownie.exceptions.VirtualMachineError: revert: typed error: 0x1f6a65b6

it works fine with the actual VRFCoordinatorV2 on rinkeby

IndexError: list index out of range

When following the NFT class I have experienced an error I seem unable to solve. When running the create_collectible.py script I receive the following message:

IndexError: list index out of range

My AdvancedCollectible code:

// SPDX-License-Identifier: MIT
pragma solidity 0.6.6;

import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@chainlink/contracts/src/v0.6/VRFConsumerBase.sol";

contract AdvancedCollectible is ERC721, VRFConsumerBase {
    uint256 public tokenCounter;
    bytes32 public keyhash;
    uint256 public fee;
    enum Breed {
        PUG,
        SHIBA_INU,
        ST_BERNARD
    }
    mapping(uint256 => Breed) public tokenIdToBreed;
    mapping(bytes32 => address) public requestIdToSender;
    event requestedCollectible(bytes32 indexed requestId, address requester);
    event breedAssigned(uint256 indexed tokenId, Breed breed);

    constructor(
        address _vrfCoordinator,
        address _linkToken,
        bytes32 _keyhash,
        uint256 _fee
    )
        public
        VRFConsumerBase(_vrfCoordinator, _linkToken)
        ERC721("Dogie", "DOG")
    {
        tokenCounter = 0;
        keyhash = _keyhash;
        fee = _fee;
    }

    function createCollectible() public returns (bytes32) {
        bytes32 requestId = requestRandomness(keyhash, fee);
        requestIdToSender[requestId] = msg.sender;
        emit requestedCollectible(requestId, msg.sender);
    }

    function fulfillRandomness(bytes32 requestId, uint256 randomNumber)
        internal
        override
    {
        Breed breed = Breed(randomNumber % 3);
        uint256 newTokenId = tokenCounter;
        tokenIdToBreed[newTokenId] = breed;
        emit breedAssigned(newTokenId, breed);
        address owner = requestIdToSender[requestId];
        _safeMint(owner, newTokenId);
        tokenCounter = tokenCounter + 1;
    }

    function setTokenURI(uint256 tokenId, string memory _tokenURI) public {

        require(
            _isApprovedOrOwner(_msgSender(), tokenId),
            "ERC721: caller is not owner no approved"
        );
        _setTokenURI(tokenId, _tokenURI);
    }
}

my create_collectible.py code:

from brownie import AdvancedCollectible
from scripts.helpful_scripts import fund_with_link, get_account
from web3 import Web3


def main():
    account = get_account()
    advanced_collectible = AdvancedCollectible[-1]
    fund_with_link(advanced_collectible.address, amount=Web3.toWei(0.1, "ether"))
    creation_transaction = advanced_collectible.createCollectible({"from": account})
    creation_transaction.wait(1)
    print("Collectible created!")

I have tried referencing different numbers in the line advanced_collectible = AdvancedCollectible[-1] however no luck. Any help would be appreciated!

Cannot see metadata on opensea

Hi guys, if i go to https://testnets.opensea.io/assets?search[query]=0xeFfc5d2E70d0961D35e94cee63f87203000a36A9 i can see that i minted two items from my contract but i cannot see the metadata even after hours.

In my python script, if i run print(advanced_collectible.tokenURI(token_id)) i can see all the metadata links:

so i suppose that the metadata field has been wrote on the chain.
Any idea on why i cannot see the metadata on opensea?

thank you and cheers from Italy

ImportError: cannot import name 'LinkToken' from 'brownie'

brownie Version: v1.16.4
ganache-cli Version: v6.12.2
solc Version: ^0.6.6
Python Version: 3.9.7
OS: window 10

command use: brownie run scripts/advance_collectible/deploy_and_create.py --network rinkeby.

I have enough LinkToken in rinkeby testnet.

issue

Lesson 11: Token Counter Does Not Change to 2

I'm curious as to why this might be happening: is it just a matter of waiting for the network to process it?

It's not a matter of impatience: I've waited 20min-an hour for it before.

There have been a few times where it has changed to 2 but while running the final manual tests, it just stays at 1.

It initially shows up as a 0.

What factors play a part in this value?

My contract: 0xC00cA10Cb79F2b5F9B883351b4fc6854Ee140a84

Why this one cannot be verified on Etherscan Rinkeby Testnet

Hi!

I just finished deploying the AdvancedCollectible.sol
Everything went well, except I couldn't verify the deployed contract on Etherscan directly.
Here's the address of the contract: https://rinkeby.etherscan.io/address/0x0Dc3dF23EF61C608F819487C6E17C41C32F7dA28
My solidity compiler version is 0.8.0. I'm not sure if that matter. Everything else stays alone with the video content.
I tried to add the ETHERSCAN_TOKEN in .env and set rinkeby: verify: True in brownie-config.
But it still couldn't be verified like Patrick showed in the video (10:50:20).
Anyone has any idea about this?
Is that because of my code or etherscan?
Thanks in advance!

error when brownie compile

File "C:\Users\Dell\AppData\Local\Programs\Python\Python39\lib\site-packages\brownie_cli_main_.py", line 64, in main
importlib.import_module(f"brownie._cli.{cmd}").main()
File "C:\Users\Dell\AppData\Local\Programs\Python\Python39\lib\site-packages\brownie_cli\compile.py", line 50, in main
proj = project.load()
File "C:\Users\Dell\AppData\Local\Programs\Python\Python39\lib\site-packages\brownie\project\main.py", line 750, in load
return Project(name, project_path)
File "C:\Users\Dell\AppData\Local\Programs\Python\Python39\lib\site-packages\brownie\project\main.py", line 182, in init
self.load()
File "C:\Users\Dell\AppData\Local\Programs\Python\Python39\lib\site-packages\brownie\project\main.py", line 237, in load
self._compile(changed, self._compiler_config, False)
File "C:\Users\Dell\AppData\Local\Programs\Python\Python39\lib\site-packages\brownie\project\main.py", line 89, in _compile
_install_dependencies(self._path)
File "C:\Users\Dell\AppData\Local\Programs\Python\Python39\lib\site-packages\brownie\project\main.py", line 756, in _install_dependencies
install_package(package_id)
File "C:\Users\Dell\AppData\Local\Programs\Python\Python39\lib\site-packages\brownie\project\main.py", line 778, in install_package
return _install_from_github(package_id)
File "C:\Users\Dell\AppData\Local\Programs\Python\Python39\lib\site-packages\brownie\project\main.py", line 851, in _install_from_github
raise ConnectionError(msg)
ConnectionError: Status 404 when getting package versions from Github: 'Not Found'

Missing or forbidden.
If this issue persists, generate a Github API token and store it as the environment variable GITHUB_TOKEN:
https://github.blog/2013-05-16-personal-api-tokens/

///////
added Github-Token in .env
and dotenv: .env in bronie-config.yaml
image
image

Created tokens, collectibles and metadata, same dog every time, and not visible on OpenSea

Hi!

I'm at the end of lesson 11, when we test all our scripts on Rinkeby.

I've successfully deployed and created new collectibles, I have 3uint256 in my
tokenCounter on Etherscan, but when creating the metadata json files, I see that the three of them are PUG dogs. Is it normal?

Secondly, on OpenSea, after more than an hour waiting and refreshing the page, the dog pictures are not visible and their name is all the same : Dogie - lmUs6d9XtY on OpenSea, my contract's Etherscan page

I'm not really sure which code to share that would give you relevant information to try to help, so feel free to ask and I'll add to this post.

All the images are correctly named in an img folder, the rinkeby folder is correctly inside the metadata folder

Metadata file with another "attributes" actually not upload to IPFS

Hi all!

In Lesson 11, when creating the metadata template, I decided to use "power" instead of "cuteness".
The script runs without errors, gives the hash of the file. It certainly differs from the "standard".
But if you click on the link, then IPFS gives an error 504
If I use a metadata template with the "cuteness" parameter, then a hash and a link to a previously uploaded file by someone are issued. And of course file is opens.
This is easy to check - just change any letter in the metadata template.
There is a suspicion that the presented script is not quite workable.

ImportError: cannot import name 'LinkToken' from 'brownie'

Launching 'ganache-cli.cmd --accounts 10 --hardfork istanbul --gasLimit 12000000 --mnemonic brownie --port 8545'...
File "c:\users\js_sa\appdata\local\programs\python\python39\lib\site-packages\brownie_cli\run.py", line 50, in main
return_value, frame = run(
File "c:\users\js_sa\appdata\local\programs\python\python39\lib\site-packages\brownie\project\scripts.py", line 53, in run
module = _import_from_path(script)
File "c:\users\js_sa\appdata\local\programs\python\python39\lib\site-packages\brownie\project\scripts.py", line 149, in _import_from_path
import_cache[import_str] = importlib.import_module(import_str)
File "c:\users\js_sa\appdata\local\programs\python\python39\lib\importlib_init
.py", line 127, in import_module
return _bootstrap.gcd_import(name[level:], package, level)
File "<frozen, line line, in in
File "<frozen, line line, in in
File "<frozen, line line, in in
File "<frozen, line line, in in
File "<frozen, line line, in in
File "<frozen, line line, in in
File "\Users\js_sa\OneDrive\Blockchain\NFT-Demo\scripts\advanced_collectible\deploy_and_create.py", line 1, in
from scripts.helpful_scripts import (
File ".\scripts\helpful_scripts.py", line 1, in
from brownie import accounts, network, config, LinkToken, VRFCoordinatorMock, Contract
ImportError: cannot import name 'LinkToken' from 'brownie' (c:\users\js_sa\appdata\local\programs\python\python39\lib\site-packages\brownie_init
.py)

Couldn't import LinkToken or VRFCoordinatorMock from brownie

Hi,
I am trying to run the advanced_collectible deploy_and_create.py, but cannot import LinkToken or VRFCoordinatorMock from brownie.
This is the command line I am using.
brownie run scripts/advanced_collectible/deploy_and_create.py

Any suggestions?

Undeclared identifier: requestRandomness

Can't figure out why this error won't go away.

I assumed it was an import error so played around with getting chainlink packages installed with yarn etc but no luck

CompilerError: solc returned the following errors:

contracts/AdvancedCollectible.sol:29:29: DeclarationError: Undeclared identifier.
        bytes32 requestId = requestRandomness(keyhash, fee);`

Config:

dependencies:
  - OpenZeppelin/[email protected]
  - smartcontractkit/[email protected]
compiler:
  solc:
    remappings:
      - '@openzeppelin=OpenZeppelin/[email protected]'
      - '@chainlink=smartcontractkit/[email protected]'
dotenv: .env
wallets:
  from_key: ${PRIVATE_KEY}

AdvancedCollectible.sol

// An NFT Contract
// Where the tokenURI can be one of 3 different dogs
// Randomly selected

// SPDX-License-Identifier: MIT
pragma solidity 0.6.6;

import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@chainlink/contracts/src/v0.6/VRFConsumerBase.sol";

contract AdvancedCollectible is ERC721, VRFConsumerBase {
    uint256 public tokenCounter;
    bytes32 public keyhash;
    uint256 public fee;
    enum Breed{PUG, SHIBA_INU, ST_BERNARD}
    mapping(uint256 => Breed) public tokenIdToBreed;
    mapping(bytes32 => address) public requestIdToSender;
    event requestedCollectible(bytes32 indexed requestId, address requester);
    event breedAssigned(uint256 indexed tokenId, Breed breed);

    constructor(address _vrfCoordinator, address _linkToken, bytes32 _keyhash, uint256 _fee) public 
    VRFConsumerBase(_vrfCoordinator, _linkToken)
    ERC721("Dogie", "DOG")
    {
        tokenCounter = 0;
        keyhash = _keyhash;
        fee = _fee;
    }

    function createCollectible() public returns (bytes32) {
        bytes32 requestId = requestRandomness(keyhash, fee);
        requestIdToSender[requestId] = msg.sender;
        emit requestedCollectible(requestId, msg.sender);
    }

    function fulfillRandomness(bytes32 requestId, uint256 randomNumber) internal override {
        Breed breed = Breed(randomNumber % 3);
        uint256 newTokenId = tokenCounter;
        tokenIdToBreed[newTokenId] = breed;
        emit breedAssigned(newTokenId, breed);
        address owner = requestIdToSender[requestId];
        _safeMint(owner, newTokenId);
        tokenCounter = tokenCounter + 1;
    }

    function setTokenURI(uint256 tokenId, string memory _tokenURI) public {
        // pug, shiba inu, st bernard
        require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: caller is not owner no approved");
        _setTokenURI(tokenId, _tokenURI);
    }
}

Any help would be hugely appreciated!

createCollectible Sequence has incorrect length, expected 1 but got 2

hi...I have a new issue about this and I see everywhere to fix it
in your GitHub repo
in your solidity course and I was confused why work on your systm but in my system give me an error

File "eth_brownie-1.19.0-py3.10.egg/brownie/_cli/run.py", line 51, in main
return_value, frame = run(
File "eth_brownie-1.19.0-py3.10.egg/brownie/project/scripts.py", line 110, in run
return_value = f_locals[method_name](*args, **kwargs)
File "./scripts/deploy_and_create.py", line 14, in main
tx = simple_collectible.createCollectible(sample_token_uri, {"from", account})
File "eth_brownie-1.19.0-py3.10.egg/brownie/network/contract.py", line 1861, in call
return self.transact(*args)
File "eth_brownie-1.19.0-py3.10.egg/brownie/network/contract.py", line 1744, in transact
data=self.encode_input(*args),
File "eth_brownie-1.19.0-py3.10.egg/brownie/network/contract.py", line 1779, in encode_input
data = format_input(self.abi, args)
File "eth_brownie-1.19.0-py3.10.egg/brownie/convert/normalize.py", line 20, in format_input
raise type(e)(f"{abi['name']} {e}") from None
ValueError: createCollectible Sequence has incorrect length, expected 1 but got 2

you pass 2 in your video and it's work but not for me
please help me

Advanced NFT always breed 1

Hi,

I'm following along with the tutorial for the advanced NFT and it looks like every time the code is being run the breed is always 1.

I have copied the codebase from the git repo to be sure and the result is still the same, the contract address is 0xfB372045283C46E134042794c37A87FfA3e48B73

Any ideas what maybe happing would be helpful, I'd be surprised if the VRF gave me the same result 4 times.

Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.