GithubHelp home page GithubHelp logo

nft-contracts's Introduction

NFT Contracts

Generate abi files instruction

Download go-ethereum, choose the preferred version and build the executable abigen file.
Suggest solc version:

Version: 0.6.12+commit.27d51765.Darwin.appleclang
abigen --sol ./contracts/PolyNFTLockProxy.sol --pkg nft_lock_proxy_abi > ./go_abi/nft_lock_proxy_abi/nft_lock_proxy_abi.go

abigen --sol ./contracts/PolyNFTWrapper.sol --pkg nft_wrap_abi > ./go_abi/nft_wrap_abi/nft_wrap_abi.go

abigen --sol ./contracts/erc721_template/CrossChainNFTMapping.sol --pkg nft_mapping_abi > ./go_abi/nft_mapping_abi/nft_mapping_abi.go

NFT Cross chain

  • PolyNFTLockProxy contract

this contract used to lock original asset. and will be deployed to both of the original and destination side chain. and proxy contract record the relationship of sidechain id and NFT contract address in maps, to ensure the destination is correct while cross chain.

so, when we transfer NFT asset named CryptoKitte from ethereum to bsc chain.the original CryptoKitte will be locked in in this proxy contract, and mint a new CryptoKittes with the same metadata in the mirror contract which located in bsc chain. and the original CryptoKitte will be locked in the proxy contract which located in bsc chain.

when we tranfer back CryptoKitte from bsc to ethereum. the mirror CryptoKitte will be unlocked from proxy contract which located in bsc chain, and the original CryptoKitte will be unlocked to the destination user from proxy contract which located in ethereum chain.

  • CrossChainNFTMapping contract

in standard erc721 _mint is an internal function. so we wrapper this function as an external function to ensure that cross chain success. the contract located in dir of ./contracts/erc721_template.

the external mint interface should be standard as follow:

function mintWithURI(address to, uint256 tokenId, string memory uri) external
  • PolyNFTWrapper contract.

this contract wrap the handling fee processing function and the safeTransferFrom interface in the erc721 standard into an interface called lock. and this contract should be deployed in both of source side chain and destination side chain.

How to deploy

deploy NFT contract with erc721_template in both source side chain and destination side chain, and bind this two contracts in source proxy contract and destination proxy contract.

and the abi and bin code located in diretion of ./go_abi/nft_mapping_abi.

nft-contracts's People

Contributors

dylenfu avatar tanziwen avatar

Watchers

 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.