Giter VIP home page Giter VIP logo

erc6551-fun's Introduction

ERC6551 Fun

Nothing special here, I'm just playing around with Solidity + Hardhat.

Contracts

The following contracts (and associated libs) were copied from the ERC6551 reference repo:

  • ERC6551Registry
  • SimpleERC6551Account

DudeToken

Just a standard ERC721. Dudes get minted with a name.

ERC721TokenSwapper

Exposes swapTokens(addr1, addr2, token1, token2), which allows us to swap tokens between 2 contracts in 1 transaction. This is needed because of the next contract. Inherits from openzeppelin's ERC721 implementation.

ERC721LimitPerOwner

Limits the number of tokens that can be owned by a single account. Though I don't see real value brought by this limitation, it can be used to impose rules on game-specific tokens. Inherits from ERC721TokenSwapper, which allows us to swap tokens without needing a third account.

HatToken

A special ERC721 composed with ERC721TokenSwapper & ERC721LimitPerOwner(1). An account can only hold at max 1 Hat. How special these are! Better pick your one and only favourite hat to wear.

DudeAccount

Token Bound Account meant for DudeTokens. Inherits from SimpleERC6551Account & ERC721Holder. The latter allows for minting directly to the account.

Testing

The core of the Token Bound Account functionality is tested in the scenarios laid on in test/DudeAccount.ts.

Instructions

Install dependencies using npm (or yarn).

Compile contracts with npx hardhat compile.

Run unit tests with npx hardhat test.

Deploy to a test network with npx hardhat run scripts/deploy.js. If you don't want to mess with deploying to a third party testnet, just run your own with npx hardhat node.

erc6551-fun's People

Contributors

kraxx 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.