Code Monkey home page Code Monkey logo

laos-erc721's Introduction

ERC721Universal Template Contract

This repository contains a Solidity ERC721 template contract designed for Universal asset minting and evolution. The contract is deployable on any EVM-compatible network. On deploy, the contract allocates slots (indexed by a 96b integer) to each possible 160b address. These slots can be filled, equivalent to minting and evolving, on the LAOS evolution chain.

To learn more about this pattern, and the overall LAOS architecture, please refer to the Additional Resources section.

The contract is built on top of the OpenZeppelin ERC721 Contracts library.

Getting Started

Prerequisites

Make sure you have all the required dependencies:

npm ci

Compiling the Contract

Compile the contracts with the following command:

npx hardhat compile

Testing the Contract

The following command runs the test suite:

npx hardhat test

Deploying the Contract

To deploy the contract, edit the hardhat.config.ts file, and use the following command:

npx hardhat run --network <network-name> scripts/deploy.ts

Verifying Contract

The following command can be used to verify the deployed contracts on etherscan or any other EVM scan (e.g Polygonscan):

npx hardhat verify --network <network-name> <contract-address> <contract-deploy-arguments>

Gas cost considerations

The pattern implemented by this contract, in conjunction with the LAOS blockchain, allows the minting and evolution of an arbitrary number of NFTs on any EVM-compatible Layer 1. All minting gas fees are paid on the LAOS blockchain, with a single exception: the initial cost of deploying the contract on the chosen Layer 1.

Assets appear on-chain in the selected Layer 1 and can be traded using that chain's native currency within its existing ecosystem.

For DApps to accurately reflect bridgelessly minted assets, they can opt to monitor both consensus systems or, more conveniently, utilize a Universal Node as their RPC endpoint. Additional details are available in these resources.

Users desiring visibility for their bridgelessly minted assets in DApps not yet integrating the above methods have several options:

  • Transferring the asset once ensures automatic tracking by all DApps. This can be done via importing the asset to a web3 wallet (e.g. Metamask), and sending it, either via a 'self-transfer' (the same address acts as sender and receiver), or to another controlled address.

  • Utilizing the contract's broadcast features, which emit mint events (broadcastMint) or self-transfer events (broadcastSelfTransfer), not altering the contract's storage, and thus incurring minimal gas fees. The batch versions of these methods significantly reduce gas costs by circumventing the base transaction fee of 21000 gas.

Here are approximate gas costs for comparison (check the tests for verification):

  • Any number of mints in DApps using any of the above patterns: 0 gas
  • Mint of 1 asset using the default OpenZeppelin ERC721 Contracts: 140,683 gas
  • broadcastMint of 1 asset: 28,140 gas
  • broadcastSelfTransfer of 1 asset: 28,207 gas
  • broadcastSelfTransferBatch of 1000 assets: 7,016,723 = 7,016 per asset

Additional resources

  • LAOS Documentation: For developers wanting to start building on LAOS, here.
  • LAOS Whitepaper: For a comprehensive understanding of the LAOS project, please review the whitepaper.
  • LAOS Roadmap: To explore the future plans and updates for LAOS, visit the roadmap.

laos-erc721's People

Contributors

tonimateos avatar zorjak avatar gerardcolomerfv avatar

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.