Giter VIP home page Giter VIP logo

sol-nft-wrap's Introduction

sol-nft-wrap

This set of smart contracts presents an account abstraction, and an ERC721 NFT as ownership registry and transfer mechanism for abitrary contracts.

Components

C1: Acct, an asset container

Acct is a contract whose sole purpose is to hold assets, in order to transfer those assets between owners, possibly including ownership by an NFT marketplace.

An Acct contract holds ERC20 tokens or ETH. This on-chain account (aka on-chain wallet) may be owned by

  1. An owner address (EOA or another contract), or
  2. The NFT ownership registry contract.

TBD: Holding NFTs.

C2: OwnerRegistry, an ERC721 NFT registry for contracts

OwnerRegistry is a standard ERC721 contract with 'OWNER' ticker symbol.

The Token-ID within this registry is the contract address of an Acct.

Ownership of an Acct may be transferred to the registry. The Acct may then be transferred via ERC721 standard means.

Ownership is transferred from the registry to the NFT owner by burning the NFT.

Features

NFT Lock

While an Acct is owned by the registry, assets cannot be withdrawn or transferred (unless prior approvals were granted).

Time Lock

A non-revokable time lock can be applied to an Acct. If the time lock's timestamp is in the future, when withdrawals are disabled. When the timestamp is in the past, withdrawals are enabled.

User stories

Asset package and transfer

Alice provably locks up assets in a smart contract, and registers the contract with an ERC721-compatible registry. Alice deposits the NFT on an NFT marketplace.

Bob examines the NFT on the marketplace, and inspects the assets associated with the NFT.

Bob purchases the NFT on the marketplace, ownership of the NFT transfers to Bob. Bob unlocked the Acct by burning the NFT. Bob may then immediately withdraw any or all of the assets. Alice cannot access the assets, following NFT ownership transfer to Bob.

Setup.

  1. Install packages
    npm i -g truffle
    npm i
    
  2. Update provider url in config/default.json
  3. Set DEPLOYMENT_ACCOUNT_KEY in env
    create a .env file in root
    DEPLOYMENT_ACCOUNT_KEY =  "my mnemonic phrase"
    
  4. Deploy you own contracts if want to do arb-
    truffle migrate --reset --network mainnet/ropsten
    

sol-nft-wrap's People

Contributors

cleanunicorn avatar jgarzik avatar kevinbeauregard avatar rokso avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  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

sol-nft-wrap's Issues

Can Accidentally put an account into permanently locked state

An Account can be permanently locked by:

  1. Transferring ownership of an Acct to an NFT (OwnerRegistry)
  2. Transferring the NFT to the Acct Address (using transferFrom or safeTransferFrom)

This can potentially be addressed in two ways

  • Extend the ownable lib to check if the new owner is an ERC721 contract
  • Update our depositNFT function to check if the NFT ID matches our self address when cast to a unit256. However, this does not handle an unsafe deposit using 'transferFrom' directly.

Extensible module system

User story: An asset held by an Acct should be able to be deposited, staked, or otherwise manipulated via remote contract call, as initiated by the Acct owner.

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.