Git Product home page Git Product logo

xenft's Introduction

Xen NFT

This is a Xen NFT project.

Installation

npm install

Tests

npm run test

Code Style

https://docs.soliditylang.org/en/latest/style-guide.html

Check code lint

npm run lint

Fix code lint

npm run lint:fix

Git Hook

This project uses Husky to run git hooks. The pre-commit hook runs lint-staged to run code lint checking and code formatting before committing.

Install Husky hooks

npm run husky:install

Forwarder

Reference forwarder implementation from OpenGSN: https://github.com/opengsn/gsn/blob/master/packages/contracts/src/forwarder/Forwarder.sol

xenft's People

Contributors

lbelyaev avatar nibty avatar youvegotmail-1998 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

xenft's Issues

Make XENFT EIP-2771 compatible (for meta transactions and flash loans)

Intent: Enable developers to build proxy based DApps that allow users operate without native coin balance. Thus the users will make bulk claims/rewards with "borrowed gas" that will be repaid with a share of their XEN rewards.

Example: Alice has no ETH in her wallet but today is her XENFT mint term. Instead of transferring the required amount from somewhere else, Alice uses Bob's DApp that entirely subsidizes gas for Alice. In return for the service, Bob's smart contract will retain a share of the minted XEN rewards, while the rest of the amount will be transferred to Alice's wallet. Bob also has the option to fund the gas with a one-block flash loan (like Aave's).

Why EIP-2771: It is the standard for making smart contract meta-transaction capable, but it also indirectly enables the ability to fund gas usage with flash loans. Flash loans implementations similar to Aave's are built for smart contracts. It is not possible to borrow, convert the funds to native coin and repay them from an EOA wallet because everything needs to happen within a transaction. More than that, decentralized gas subsidizers like GSN implement EIP-2771. What is interesting in GSN's architecture is that the payment logic is separated from relay servers, allowing to receive the flashloan into the contract while the relayer as EOA can perform the actual claim reward operation having the guarantee that it will be compensated for the incurred gas cost. Frontends can choose to deploy their own relayer or use other relayer instances available in the GSN network. This change will allow integrations for other EIP-2771 compatible relayers (like Open Zeppelin Defender Relayer) while remaining perfectly functional for EOAs.

How (implementation): The XENFT contract needs to inherit a ERC2771Context implementation (like OpenGSN or OpenZeppelin) and the constructor will pass a trusted Forwarder that will be deployed before the XENFT contract. Also msg.sender have to be replaced with _msgSender() implementation of the inherited context.

If this proposition starts to show interest, I will submit a PR with a potential contract implementation and tests to demonstrate the applicability.

reuse the create2 address to save gas

reason

  1. use "powerDown" to destroy the created address, each minting is the same gas consumption;
  2. in terms of economic benefits, the lower the cost, the greater the competitive advantage. If the address is reused, the gas consumption will be reduced.

gas used difference

  • The address is not reused
    first ClaimRank * 10: 1929000
    second ClaimRank * 10: 1929000

  • Address multiplexing
    first ClaimRank * 10: 1929000
    second ClaimRank * 10: 1536000

other instructions

Adding address multiplexing will increase the complexity, just a suggestion.

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.