Skip to content

AbrahamEarlyWorks Contract#

Overview#

AbrahamEarlyWorks is a limited edition NFT collection contract that allows for controlled minting of unique artworks. The contract implements ERC-721 with ERC721URIStorage for flexible metadata management and includes an authorized minter system for integration with sale contracts.

Key Features#

  • Limited Supply: Configurable maximum supply with overflow protection
  • Owner Minting: Direct minting capability for contract owner
  • Authorized Minter System: Designated contracts can mint NFTs
  • Flexible Metadata: Individual metadata URI for each NFT
  • Supply Management: Dynamic max supply updates
  • Gas Optimized: Efficient minting and metadata storage

Architecture#

graph TB
    subgraph "AbrahamEarlyWorks Contract"
        A[Owner Mint] --> B[mintTo Function]
        C[Authorized Minter] --> B
        B --> D[Supply Check]
        D --> E[ERC721 Mint]
        E --> F[Set Metadata URI]
        F --> G[Emit Events]

        H[Supply Management] --> I[Update Max Supply]
        I --> J[Validate New Limit]

        K[Minter Management] --> L[Update Authorized Minter]
    end

    subgraph "External Integration"
        M[FixedPriceSale Contract]
        N[IPFS Metadata]
        O[Frontend Applications]
    end

    M --> C
    F --> N
    G --> O

Contract Functions#

Core Minting#

mintTo(string metadataURI, address recipient)#

  • Purpose: Mint a new NFT with metadata to specified recipient
  • Access: Owner or authorized minter only
  • Parameters:
  • metadataURI: IPFS URI containing NFT metadata
  • recipient: Address to receive the minted NFT
  • Returns: uint256 - Token ID of minted NFT
  • Reverts: If max supply reached or caller not authorized

Supply Management#

updateMaxSupply(uint256 newMaxSupply)#

  • Purpose: Update the maximum supply limit
  • Access: Owner only
  • Parameters: newMaxSupply: New maximum token supply
  • Requirements: New supply must be ≥ current total supply
  • Events: Emits MaxSupplyUpdated(oldMaxSupply, newMaxSupply)

maxSupply()#

  • Purpose: Get current maximum supply
  • Access: Public view
  • Returns: uint256 - Current max supply

totalSupply()#

  • Purpose: Get total number of minted tokens
  • Access: Public view
  • Returns: uint256 - Current total supply

Authorization System#

updateAuthorizedMinter(address newAuthorizedMinter)#

  • Purpose: Set authorized minter contract
  • Access: Owner only
  • Parameters: newAuthorizedMinter: Address of authorized minting contract
  • Events: Emits AuthorizedMinterUpdated(oldMinter, newMinter)

authorizedMinter()#

  • Purpose: Get current authorized minter
  • Access: Public view
  • Returns: address - Current authorized minter

Standard ERC-721 Functions#

  • tokenURI(uint256 tokenId): Get metadata URI for token
  • ownerOf(uint256 tokenId): Get owner of token
  • transferFrom(address from, address to, uint256 tokenId): Transfer token
  • All standard ERC-721 functions supported

Events#

event MaxSupplyUpdated(uint256 oldMaxSupply, uint256 newMaxSupply);
event AuthorizedMinterUpdated(address indexed oldMinter, address indexed newMinter);
// Standard ERC-721 events also emitted

Integration with FixedPriceSale#

The contract is designed to work seamlessly with sale contracts:

sequenceDiagram
    participant User as Buyer
    participant Sale as FixedPriceSale
    participant NFT as AbrahamEarlyWorks
    participant IPFS as IPFS Network

    User->>Sale: mint(metadataURI) + 0.01 ETH
    Sale->>Sale: Validate payment
    Sale->>NFT: mintTo(metadataURI, user)
    NFT->>NFT: Check supply limits
    NFT->>NFT: Mint token to user
    NFT->>IPFS: Store metadata URI
    NFT-->>Sale: Return token ID
    Sale-->>User: NFT minted successfully

    Note over User,IPFS: User owns unique NFT with metadata

Metadata Schema#

Each NFT supports individual metadata following OpenSea standards:

{
  "name": "Abraham Early Work #123",
  "description": "A unique piece from Abraham's early collection",
  "image": "ipfs://QmImageHash",
  "attributes": [
    {
      "trait_type": "Series",
      "value": "Early Works"
    },
    {
      "trait_type": "Edition",
      "value": "123"
    },
    {
      "trait_type": "Artist",
      "value": "Abraham"
    }
  ],
  "external_url": "https://eden.art/abraham/123",
  "animation_url": "ipfs://QmVideoHash"
}

Security Features#

  • Supply Protection: Cannot mint beyond max supply
  • Access Control: Only owner or authorized minter can mint
  • Overflow Protection: SafeMath operations prevent overflow
  • Input Validation: All parameters validated
  • Reentrancy Protection: Prevents reentrancy attacks

Gas Optimization#

  • Efficient Storage: Optimized storage layout
  • Minimal State Changes: Functions minimize storage writes
  • Batch-Friendly: Designed for potential batch operations

Deployment Info#

  • Network: Sepolia Testnet
  • Address: 0x2cFe7820fcBDBca222E252B46ACe4D6B4D9302Fe
  • Max Supply: 1000 (configurable)
  • Verified: ✅ View on Etherscan

Usage Examples#

Direct Owner Minting#

import { ethers } from 'ethers';
import AbrahamEarlyWorksABI from './AbrahamEarlyWorks.json';

const CONTRACT_ADDRESS = "0x2cFe7820fcBDBca222E252B46ACe4D6B4D9302Fe";

const contract = new ethers.Contract(
  CONTRACT_ADDRESS,
  AbrahamEarlyWorksABI,
  ownerSigner
);

// Mint NFT to recipient
const tx = await contract.mintTo(
  "ipfs://QmYourMetadataHash",
  "0xRecipientAddress"
);
const receipt = await tx.wait();
console.log("Token minted:", receipt.events[0].args.tokenId);

Supply Management#

// Check current supply status
const totalSupply = await contract.totalSupply();
const maxSupply = await contract.maxSupply();
const available = maxSupply - totalSupply;

console.log(`Supply: ${totalSupply}/${maxSupply} (${available} remaining)`);

// Update max supply (owner only)
if (available < 100) {
  await contract.updateMaxSupply(maxSupply + 500);
}

Integration with Sale Contract#

// Example authorized minter contract
contract MyAbrahamSale {
    AbrahamEarlyWorks public immutable nftContract;
    uint256 public constant PRICE = 0.01 ether;

    constructor(address _nftContract) {
        nftContract = AbrahamEarlyWorks(_nftContract);
    }

    function purchaseNFT(string calldata metadataURI) external payable {
        require(msg.value >= PRICE, "Insufficient payment");

        // Mint NFT to buyer
        uint256 tokenId = nftContract.mintTo(metadataURI, msg.sender);

        // Refund excess payment
        if (msg.value > PRICE) {
            payable(msg.sender).transfer(msg.value - PRICE);
        }

        emit NFTPurchased(msg.sender, tokenId, metadataURI);
    }
}

Testing#

The contract includes comprehensive tests:

// Test supply limits
it("Should prevent minting beyond max supply", async function() {
  // Set low max supply for testing
  await contract.updateMaxSupply(2);

  // Mint 2 NFTs successfully
  await contract.mintTo("ipfs://hash1", addr1.address);
  await contract.mintTo("ipfs://hash2", addr1.address);

  // Third mint should fail
  await expect(
    contract.mintTo("ipfs://hash3", addr1.address)
  ).to.be.revertedWith("Max supply reached");
});


Contract Status: Production Ready
Last Updated: September 1, 2025