DEV Community

Cover image for ¿El ERC721A es tan bueno como dicen?
Ahmed Castro
Ahmed Castro

Posted on

3 2

¿El ERC721A es tan bueno como dicen?

La colección de NFTs de Azuki destaca por su estilo artístico. Pero además de eso trajo a la mesa el ERC721A una nueva implementación del estándar ERC-721. El objetivo de esta librería es ahorrar gas a los participantes que deseen comprar mas de un NFT en el mercado primario. En este video haremos pruebas y compararemos los gastos de gas para los NFTs lanzados con Azuki y para los NFTs lanzados con las librerías de OpenZeppelin.

https://www.youtube.com/watch?v=TTEzsdQKU-g

Ejecuta los tests

Al ejecutar los siguientes comandos bajarás los tests desde el repo de github de Filosofía Código, los ejecutarás y verás los resultados en la terminal.

git clone https://github.com/FilosofiaCodigo/ERC721AComparison.git
cd ERC721AComparison/
npm install
npx hardhat run scripts/gas-comparison.js 
Enter fullscreen mode Exit fullscreen mode

Ejemplos usados en este video

Aquí les dejo los contratos con funcionalidad mínima que usamos para realizar los tests.

Azuki NFT

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

import "erc721a/contracts/ERC721A.sol";

contract Azuki is ERC721A {
    constructor() ERC721A("Azuki", "AZUKI") {}

    function mint(uint256 quantity) external payable {
        // `_mint`'s second argument now takes in a `quantity`, not a `tokenId`.
        _mint(msg.sender, quantity);
    }
}
Enter fullscreen mode Exit fullscreen mode

Openzeppelin NFT

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

import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol";
import "@openzeppelin/contracts/utils/Counters.sol";

contract GameItem is ERC721URIStorage {
    using Counters for Counters.Counter;
    Counters.Counter private _tokenIds;

    constructor() ERC721("GameItem", "ITM") {}

    function mint() external
    {
        _mint(msg.sender, _tokenIds.current());
        _tokenIds.increment();
    }

    function mintWithAmount(uint amount) external
    {
        for(uint i; i<amount; i++)
        {
            _mint(msg.sender, _tokenIds.current());
            _tokenIds.increment();
        }
    }
}
Enter fullscreen mode Exit fullscreen mode

Gracias por ver este tutorial!

Sígannos en dev.to y en Youtube para todo lo relacionado al desarrollo en Blockchain en Español.

Sentry image

Hands-on debugging session: instrument, monitor, and fix

Join Lazar for a hands-on session where you’ll build it, break it, debug it, and fix it. You’ll set up Sentry, track errors, use Session Replay and Tracing, and leverage some good ol’ AI to find and fix issues fast.

RSVP here →

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay