Coder Social home page Coder Social logo

buidl-nft's Introduction

BUIDL NFT Loot Box

Simple Summary

An NFT protocol that implements BUIDL NFT with Loot Box. A loot box is a smart contract that contains any programmable behavior upon a successful BUIDL NFT transaction.

Use Cases

In general, anything that can be written as programs can be implemented in the loot box. Some initial use cases include perks, swags, token rewards, airdrops, on-chain registrations, whitelisting, etc. But definitely what loot boxes can do is unlimited.

Specificaiton

The miner of NFT can bind a LootBox contract for his BUIDL NFT with setLootBox(uint256,address) (or initializing while minting).

interface BuidlNFT {
  function setLootBox(uint256 tokenId, address lootBoxAddr) external;
  function mint(uint256 initPrice, uint256 bid, address lootBoxAddr, bytes calldata sign) external;
  function mint(uint256 initPrice, uint256 bid, bytes calldata sign) external;
}

interface ILootBox {
  function afterHarbergerBuy(uint256 tokenId, address newNFTOwner) external;
}

When an NFT is harbergerBuy() by anyone, if there is an existing Loot Box, it will try to call afterHarbergerBuy() function from the LootBox. The miner of BUIDL NFT (a.k.a. the BUIDLer) can arbitrarily define the behavior of afterHarbergerBuy(). Generally, it will be a buyers incentives / rewards. NFT buyers can predict the behavior of this function before purchase.

To ensure safety, the LootBox should always check:

  • msg.sender: Prevent the interface from being abused.
  • tokenID: Prevent other NFTs to use a same LootBox.

Example

The following is a simple example of an AirdropLootBox contract:

pragma solidity 0.8.6;

import "./BuidlNFT.sol";

contract AirdropLootBox is ILootBox {
  address public token;
  address public owner;
  address public entrypoint;
  uint256 public mintTokenId;

  constructor(address _toAirdropToken, address _ep, uint256 _mintTokenId) {
    owner = msg.sender;
    token = _toAirdropToken;
    entrypoint = _ep;
    mintTokenId = _mintTokenId;
  }

  function afterHarbergerBuy(uint256 _tokenId, address _newOwner) override external {
    require(msg.sender == entrypoint);
    require(_tokenId == mintTokenId);

    (,,,uint256 currentPrice,,,,) = BuidlNFT(msg.sender).metadataOf(_tokenId);
    ERC20(token).transferFrom(owner, _newOwner, currentPrice / 100);
  }
}

Background

BUIDL NFT was first proposed in an article that discusses how NFTs with simple Harberger tax like transaction mechanisms can help fund Web3 open source software, as well as creating fun for collectors of the unique collectables created for open source projects.

The mechanism was first experimented on HackerLink. There are more than a dozen of HackerLink BUIDLs minted their BUIDL NFTs. A leaderboard of all BUIDL NFTs is available on HackerLink.

In the original article, the party that mints the NFTs shall define the meaning of the NFTs. It has two requirements that are undesired in the Web3 era:

  • It requires unverifiable trust. Like Web2 / offline services, rights are confirmed off-chain. One example is crowdfunding platforms, where benefits and rights are often written in text and difficult to enforce / verify after actual purchases.
  • It limits what the NFTs can do.

BUIDL NFTs were first described as the "Uniswap Socks" of open source projects / public goods. Now with loot box, the meaning of BUIDL NFTs can be programmed, offering developers and NFT collectors with much more flexibilities to interact.

Ideas

For ideas of interesting use cases of loot box, we are maintaining an lootboxideas.md. Everyone can contribute to the idea list and enlighten others of what loot box can do.

buidl-nft's People

Contributors

zhangjiannan avatar tari404 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.