Forem

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.

Top comments (0)

Image of Docusign

🛠️ Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more

👋 Kindness is contagious

Discover a treasure trove of wisdom within this insightful piece, highly respected in the nurturing DEV Community enviroment. Developers, whether novice or expert, are encouraged to participate and add to our shared knowledge basin.

A simple "thank you" can illuminate someone's day. Express your appreciation in the comments section!

On DEV, sharing ideas smoothens our journey and strengthens our community ties. Learn something useful? Offering a quick thanks to the author is deeply appreciated.

Okay