Skip to content

Open your Loot bags and see what's inside

License

Notifications You must be signed in to change notification settings

yosriady/lootloose

 
 

Repository files navigation

LootLoose

Open your Loot bags and see what's inside

Github Actions

LootLoose is an ERC-1155 contract which allows you to:

  1. Open your Loot bags and mint 8 ERC-1155 tokens, corresponding to each item in the bag
  2. Re-assemble your ERC721 bag by giving back the ERC-1155 tokens to the contract

Each ERC1155's token URI is a b64 encoded SVG image, with the item's name (just that item's, not any other item from the bag that contained it).

You can mint the 8 ERC-1155 tokens via 2 ways:

  1. approve the LootLoose.sol contract to spend your NFT (or via setApprovalForAll) and calling open.
  2. Transferring your NFT directly to the contract, triggerring the onERC721Received callback

You can reassemble the bag by first approve or setApprovalForAll for the tokens contained in the bag and then calling reassemble.

Average gas cost to open is 322k gas, to reassemble 165k.

Run locally

# Install dependencies
yarn

# Optional: compile contracts
yarn compile

# Run tests
yarn test

Security Notes

  • In order to improve gas efficiency, OZ's ERC1155.sol was patched to expose the _balances mapping. We use that to do a batch mint inside open.
  • Dom's original LootComponents was modified to be cheaper to use, since it did a lot of redundant SLOADs in hot code paths.

About

Open your Loot bags and see what's inside

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Solidity 72.0%
  • TypeScript 28.0%