Skip to content

OnBlockIO/NEP11TemplatePy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NEP11-Template.py

Fully featured NEP-11 python contract to allow to easily deploy your own NFT minting contract, and make it seamless to integrate it on GhostMarket.

Contract overview

The contract features a generic mint() method, a burn() method, has builtin support for royalties (both GhostMarket and NEO official standard), locked content and is pausable and updatable (restricted to owner). On top of that its possible to add or remove authorized addresses, allowed to interact with the contract admin functions (pause / mint / etc.)

What to replace

manifest_metadata section : fill out author/description/email accordingly

TOKEN_SYMBOL : replace with your desired SYMBOL

mint : either leave as is, to allow anyone to mint on the contract, or uncomment verify() to restrict minting to one of the authorized addresses

Royalties

This template features royalties for NFT through two standard: GhostMarket standard and NEO official standard. For each sale happening on GhostMarket trading contract, a configurable percentage will be sent to the original creator (minter) if configured (or multiple ones). For convenience sake, both are supported on this contract, and any NFT minted support both.

The details have to be passed as an array during minting, and follow a json structure.

Note that the value is in BPS (ie 10% is 1000). We support multiple royalties, up to a maximum combined of 50% royalties. Note that if a NFT has royalties, our current implementation prevent it to be traded against indivisible currencies (like NEO), but if it does not have royalties it's allowed.

[{"address":"NNau7VyBMQno89H8aAyirVJTdyLVeRxHGy","value":"1000"}] or [{"address":"NNau7VyBMQno89H8aAyirVJTdyLVeRxHGy","value":1000}]

where NNau7VyBMQno89H8aAyirVJTdyLVeRxHGy would be getting 10% of all sales as royalties.

Locked Content

This template features the built-in feature of GhostMarket related to lock content. When a NFT is minted directly from GhostMarket UI with this template, you can decide to store content (which is encrypted before storing it on smart contract), which can then only be retrieved by the current NFT owner (through a custom proprietary GhostMarket API). This is totally optional, and is currently only supported for NFT minted directly from GhostMarket (for the ones using this template), as it requires encryption before minting.

Metadata

This contract features two methods to handle properties:

properties and propertiesJson

properties returns a MAP of all the NFT metadata, and is what follows NEP-11 standard (even though currently the standard is inconsistent as the signature shows it should be a MAP, while the explanation tied to it shows it should be a serialized NVM object).

propertiesJson returns a serialized JSON string of all the NFT metadata, and is what makes more sense for us to handle metadata.

This contract supports both methods for convenience purposes.

Compiling contract

Currently tested and working with neo3-boa 1.2.1

./compile.py
or
neo3-boa compile NEP11-Template.py

Deploying from neo-cli

open wallet <wallet path>
deploy <nef path> <manifest.path>

Upgrading from neo-cli

open wallet <path>
update <scripthashcontract> <nef path> <manifest path> <scripthashaddress>

Testing

Dependencies required to be installed for testing:

pip install "neo3-boa[test]"
pip3 install typing-extensions

tests can be run with:

python3 -m unittest test_nep11

individual test can be run witn

python3 -m unittest test_nep11.TestNEP11.test_decimals

About

A template for a NEP11 contract written in python

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •  

Languages