Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: ERC721 NFT Contract #197

Open
julio4 opened this issue May 28, 2024 · 22 comments · May be fixed by #250
Open

Feature: ERC721 NFT Contract #197

julio4 opened this issue May 28, 2024 · 22 comments · May be fixed by #250
Assignees
Labels
good first issue Good for newcomers

Comments

@julio4
Copy link
Contributor

julio4 commented May 28, 2024

Description

In this feature, we will implement a simple ERC721 Non-Fungible Token (NFT) contract. This will allow the creation, transfer, and management of NFTs. Users will be able to mint new NFTs, transfer ownership, and query the ownership and metadata of their NFTs.

Criteria:

  • Keep it simple, focus on explaining the interface methods with a minimal implementation
  • Include comprehensive tests
  • Deploy the contract on a testnet

Resources:

ODHack

To be eligible for additional rewards, be sure to review and follow the ODHack Common Guidelines and Contributing Guidelines.
Be sure to join the telegram group and introduce yourself.

@julio4 julio4 added ODHack good first issue Good for newcomers labels May 28, 2024
@raizo07
Copy link
Contributor

raizo07 commented May 28, 2024

Hello @julio4 I'll like to be assigned to this

@the-first-elder
Copy link
Contributor

i can do this

@Timilehin-bello
Copy link

Timilehin-bello commented May 28, 2024

@julio4 I'd like to take on the task of implementing and testing the ERC721 NFT contract. Here's my plan

What I'll Implement:

ERC721 Contract:
Mint new NFTs.
Transfer NFT ownership.
Query ownership and metadata.

Interface Methods:
Minting: Create new NFTs.
Transferring: Transfer ownership of NFTs.
Querying: Get ownership and metadata of NFTs.

Plan:
Implementation:

I will follow the ERC721 standard.
I will use minimal implementation for clarity.
I will refer to OZ ERC721 and our ERC20 for guidance.

Comprehensive Tests:

Test minting functionality.
Test transferring functionality.
Test querying ownership and metadata.
Cover edge cases like invalid transfers and minting.
I will also deploy the contract on a testnet to verify functionality.

Example Test Cases:
Minting:

Ensure new NFTs are created correctly.
Verify metadata is set correctly.

Transferring:

Ensure ownership is transferred correctly.
Handle invalid transfers.

Querying:

Verify correct ownership details.
Check metadata retrieval.

I think this should cover everything needed to make sure the NFT721 contract works correctly. Let me know if I can take this on. Thank you

@BenFaruna
Copy link

Hello @julio4 I would like to be assigned to this. I am currently working on an ERC721 contract and I'm about to write tests for it. I can rewrite it to follow the pattern used for the ERC20 contract. I added an image to show what I am currently working on.
image
Thank you

@coxmars
Copy link

coxmars commented May 28, 2024

Hi, @julio4,

I would like to help with this one if it hasn't been assigned yet. I have extensive experience with Solidity and smart contract development. Here’s my plan:

  • Implement the ERC721 NFT contract focusing on minting, transferring, and querying ownership and metadata, leveraging OpenZeppelin's ERC721 for security and compliance.
  • Write comprehensive tests to cover all interface methods, ensuring correctness and robustness.
  • Deploy the contract on a testnet to validate functionality in a live environment and provide deployment instructions.
  • I am confident I can complete this task within 4 days.

Thanks!

@julio4
Copy link
Contributor Author

julio4 commented May 30, 2024

Hello @julio4 I'll like to be assigned to this

@raizo07 assigned for now

@julio4 julio4 removed the ODHack label Jun 4, 2024
@julio4
Copy link
Contributor Author

julio4 commented Jun 4, 2024

@raizo07 Any updates on this?

@raizo07
Copy link
Contributor

raizo07 commented Jun 4, 2024 via email

@ScottyDavies

This comment was marked as off-topic.

@livinalt

This comment was marked as off-topic.

@ShantelPeters
Copy link

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

I am a blockchain developer with experience in typescript, html, css, react, javascript cario and solidility . this would be my first time contributing to this ecosystem .. please i will love to be assigned to this issue

How I plan on tackling this issue

  1. Implement Basic ERC721 Contract: Start by importing OpenZeppelin's ERC721 implementation as a base. Define the NFT's name, symbol, and any specific token properties. Implement core functions for minting, transferring, and querying ownership.
  2. Interface Methods: Clearly explain each interface method and keep the implementation minimal while ensuring functionality is clear and concise.
  3. Comprehensive Testing: Write unit tests covering minting, transfers, and ownership queries. Ensure edge cases like invalid transfers and approvals are handled.
  4. Deployment on Testnet: After testing locally, deploy the contract to a testnet like Rinkeby or Goerli using Hardhat or Truffle. Verify deployment and functionality.
  5. Use Existing ERC20 as Reference: Leverage your previous ERC20 implementation for contract structure, especially with testing and deployment scripts.

@Lukman-01

This comment was marked as off-topic.

@ajalaoluwasogo
Copy link

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

I am a Junior web developer, working with Javascript, HTML and CSS. I have over a decade experience designing graphics and organization branding.

How I plan on tackling this issue

I will follow the guidelines and put my creativeness to work

@0xNeshi 0xNeshi linked a pull request Oct 17, 2024 that will close this issue
3 tasks
@pheobeayo
Copy link

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

I am a Web3 front-end developer skilled in technical documentation and software development. I greatly understand technologies like JavaScript, Typescript, Cairo, Rust and Solidity. I have contributed successfully to open-source projects like Stark Quest and Speedrun scaffold-stark.

How I plan on tackling this issue

My Approach includes :

  • Thorough studying of the way ERC20 was implemented
  • Follow the same procedure in the implementation of the ERC721.
  • Create a Pull Request (PR).
  • Request for a Review.
  • Make changes based on the Review of the PR.

@jaiminRaiyani
Copy link

Mind if I try this one?

@julio4
Copy link
Contributor Author

julio4 commented Nov 4, 2024

Mind if I try this one?

It'll be closed by #250

@GradleD
Copy link

GradleD commented Nov 5, 2024

To implement a simple ERC721 Non-Fungible Token (NFT) contract, we will follow the ERC721 standard using OpenZeppelin's contracts. Below is a minimal implementation of the ERC721 contract, along with explanations of the interface methods, comprehensive tests, and deployment instructions on a testnet.

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.9;

// Import OpenZeppelin contracts
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol";
import "@openzeppelin/contracts/access/Ownable.sol";

contract MyNFT is ERC721, ERC721URIStorage, Ownable {
uint256 public tokenCounter;

constructor() ERC721("MyNFT", "MNFT") {
    tokenCounter = 0; // Initialize the token counter
}

/// @dev Mint a new NFT with a unique token ID and metadata URI
function mintNFT(string memory tokenURI) public onlyOwner {
    uint256 newTokenId = tokenCounter;
    _safeMint(msg.sender, newTokenId); // Mint the NFT to the sender
    _setTokenURI(newTokenId, tokenURI); // Set the metadata URI for the NFT
    tokenCounter++; // Increment the counter for the next token
}

/// @dev Override the base URI function to return a custom base URI if needed
function _baseURI() internal view virtual override returns (string memory) {
    return "https://api.mynft.com/metadata/"; // Example base URI
}

}
You can use Hardhat or Truffle for testing your smart contract. Below is an example of how you might set up tests using Hardhat:

const { expect } = require("chai");
const { ethers } = require("hardhat");

describe("MyNFT Contract", function () {
let myNFT;
let owner;
let addr1;

beforeEach(async function () {
    const MyNFT = await ethers.getContractFactory("MyNFT");
    myNFT = await MyNFT.deploy();
    [owner, addr1] = await ethers.getSigners();
});

describe("Minting NFTs", function () {
    it("Should mint a new NFT and set its metadata URI", async function () {
        await myNFT.mintNFT("https://example.com/metadata/1");
        const ownerOfToken = await myNFT.ownerOf(0);
        const tokenURI = await myNFT.tokenURI(0);
        expect(ownerOfToken).to.equal(owner.address);
        expect(tokenURI).to.equal("https://example.com/metadata/1");
    });

    it("Should fail if a non-owner tries to mint", async function () {
        await expect(myNFT.connect(addr1).mintNFT("https://example.com/metadata/2"))
            .to.be.revertedWith("Ownable: caller is not the owner");
    });
});

});
Create a deploy script in scripts/deploy.js:
async function main() {
const MyNFT = await ethers.getContractFactory("MyNFT");
const myNFT = await MyNFT.deploy();
await myNFT.deployed();
console.log("MyNFT deployed to:", myNFT.address);
}

main()
.then(() => process.exit(0))
.catch((error) => {
console.error(error);
process.exit(1);
});

@Amarjeet325
Copy link

Could I take a shot at this?

@ryzen-xp
Copy link

Hi, I am proficient Blockchain developer expert in Cairo , Rust and Solidity .
I have contributed many stark net project and more . please /assign this issue .
Thank You

@MrRoudyk
Copy link

Let me try this one!

@julio4 julio4 self-assigned this Nov 21, 2024
@julio4
Copy link
Contributor Author

julio4 commented Nov 21, 2024

This issue was already done by @0xNeshi and will be merged after review.

@Nanle100
Copy link

i can do this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.