onft

package
v3.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 7, 2024 License: MIT Imports: 18 Imported by: 0

README

oNFT - OmniFlix Non-Fungible Token

The oNFT module is a part of the OmniFlix Network and enables the classification and tokenization of assets.

  • Assets can be classified under denoms (aka collections across various ecosystems)
  • Tokenize media assets by minting NFTs

Note: This module used the irismod/nft repository for initial development and has been modified to meet the requirements of the OmniFlix Network.

Denom / Collection

A denom is a collection of NFTs. It is a unique identifier for a collection of NFTs.

message Denom {
  option (gogoproto.equal) = true;

  string id                = 1;
  string symbol            = 2;
  string name              = 3;
  string schema            = 4;
  string creator           = 5;
  string description       = 6;
  string preview_uri       = 7 [
    (gogoproto.moretags)   = "yaml:\"preview_uri\"",
    (gogoproto.customname) = "PreviewURI"
  ];
}

oNFT

oNFT is a non-fungible token that represents a unique asset

message ONFT {
  option (gogoproto.equal)                = true;

  string                    id            = 1;
  Metadata                  metadata      = 2 [(gogoproto.nullable) = false];
  string                    data          = 3;
  string                    owner         = 4;
  bool                      transferable  = 5;
  bool                      extensible    = 6;
  google.protobuf.Timestamp created_at    = 7 [
    (gogoproto.nullable) = false,
    (gogoproto.stdtime)  = true,
    (gogoproto.moretags) = "yaml:\"created_at\""
  ];
  bool                      nsfw          = 8;
  string                    royalty_share = 9 [
    (gogoproto.nullable)   = false,
    (gogoproto.moretags)   = "yaml:\"royalty_share\"",
    (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec"
  ];
}

message Metadata {
  option (gogoproto.equal) = true;

  string name              = 1 [(gogoproto.moretags) = "yaml:\"name\""];
  string description       = 2 [(gogoproto.moretags) = "yaml:\"description\""];
  string media_uri         = 3 [
    (gogoproto.moretags)   = "yaml:\"media_uri\"",
    (gogoproto.customname) = "MediaURI"
  ];
  string preview_uri       = 4 [
    (gogoproto.moretags)   = "yaml:\"preview_uri\"",
    (gogoproto.customname) = "PreviewURI"
  ];
}
State

The state of the module is expressed by following fields

  1. Collection: an object contains denom & list of NFTs
  2. Params: an object contains the parameters of the module
message GenesisState {
  repeated Collection collections = 1 [(gogoproto.nullable) = false];
  Params params = 2 [(gogoproto.nullable) = false];
}

message Collection {
  option (gogoproto.equal) = true;

  Denom         denom      = 1 [(gogoproto.nullable) = false];
  repeated ONFT onfts      = 2 [(gogoproto.customname) = "ONFTs", (gogoproto.nullable) = false];
}

// module params
message Params {
  cosmos.base.v1beta1.Coin     denom_creation_fee = 1 [
    (gogoproto.moretags) = "yaml:\"denom_creation_fee\"",
    (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Coin",
    (gogoproto.nullable) = false
  ];
}

The module supports the following capabilities for classification and tokenization:

  • Creation of collections (denoms)
  • Minting of NFTs
  • Transferring of NFTs
  • Burning of NFTs

Various queries are available to get details about denoms/collections, NFTs, and related metadata including but not limited to ownership. Click here to try them out by interacting with the chain.

1) Create Denom (Collection)

To create an oNFT denom, you will need to use the "onftd tx onft create" command with the following args and flags:

args: symbol: denom symbol

flags: name : name of denom/collection description: description for the denom preview-uri: display picture url for denom schema: json schema for additional properties creation-fee: denom creation-fee to create denom

Example:

    onftd tx onft create <symbol> \
     --name=<name> \
     --description=<description> \
     --preview-uri=<preview-uri> \
     --schema=<schema> \
     --creation-fee=<creation-fee> \
     --chain-id=<chain-id> \
     --fees=<fee> \
     --from=<key-name>
2) Mint an oNFT

To create an oNFT, you will need to use the "onftd tx onft mint" command with the following flags:

denom-id: the ID of the collection in which you want to mint the NFT name: the name of the NFT description: a description of the NFT media-uri: the IPFS URI of the NFT preview-uri: the preview URI of the NFT data: any additional properties for the NFT (optional) recipient: the recipient of the NFT (optional, default is the minter of the NFT) non-transferable: flag to mint a non-transferable NFT (optional, default is false) inextensible: flag to mint an inextensible NFT (optional, default is false) nsfw: flag to mark the NFT as not safe for work (optional, default is false) royalty-share: the royalty share for the NFT (optional, default is 0.00)

Example:

onftd tx onft mint <denom-id> \
--name="NFT name" \
--description="NFT description" \
--media-uri="https://ipfs.io/ipfs/...." \
--preview-uri="https://ipfs.io/ipfs/...." \
--data="{}" \
--recipient="" \
--chain-id=<chain-id> \
--fees=<fee> \
--from=<key-name> 

Optional flags:

--non-transferable 
--inextensible 
--nsfw 

For a royalty share:

--royalty-share="0.05" # 5%
3) Transfer an oNFT

To transfer an oNFT, you will need to use the "onftd tx onft transfer" command with the following flags:

recipient: the recipient's account address denom-id: the ID of the collection in which the NFT is located onft-id: the ID of the NFT to be transferred chain-id: the ID of the blockchain where the transaction will be made (required) fees: the transaction fees (required) from: the name of the key to sign the transaction with (required)

Example:

onftd tx onft transfer <recipient> <denom-id> <onft-id> \
--chain-id=<chain-id> \
--fees=<fee> \
--from=<key-name>
4) Burn an oNFT

To burn an oNFT, you will need to use the "onftd tx onft burn" command with the following flags:

denom-id: the ID of the collection in which the NFT is located onft-id: the ID of the NFT to be burned chain-id: the ID of the blockchain where the transaction will be made (required) fees: the transaction fees (required) from: the name of the key to sign the transaction with (required)

Example:

onftd tx onft burn <denom-id> <onft-id> \
--chain-id=<chain-id> \
--fees=<fee> \
--from=<key-name>
Queries

List of queries available for the module:

service Query {
  rpc Collection(QueryCollectionRequest) returns (QueryCollectionResponse) {
    option (google.api.http).get = "/omniflix/onft/v1beta1/collections/{denom_id}";
  }

  rpc Denom(QueryDenomRequest) returns (QueryDenomResponse) {
    option (google.api.http).get = "/omniflix/onft/v1beta1/denoms/{denom_id}";
  }

  rpc Denoms(QueryDenomsRequest) returns (QueryDenomsResponse) {
    option (google.api.http).get = "/omniflix/onft/v1beta1/denoms";
  }
  rpc ONFT(QueryONFTRequest) returns (QueryONFTResponse) {
    option (google.api.http).get = "/omniflix/onft/v1beta1/denoms/{denom_id}/onfts/{id}";
  }
  rpc OwnerONFTs(QueryOwnerONFTsRequest) returns (QueryOwnerONFTsResponse) {
    option (google.api.http).get = "/omniflix/onft/v1beta1/onfts/{denom_id}/{owner}";
  }
  rpc Supply(QuerySupplyRequest) returns (QuerySupplyResponse) {
    option (google.api.http).get = "/omniflix/onft/v1beta1/denoms/{denom_id}/supply";
  }
  rpc Params(QueryParamsRequest) returns (QueryParamsResponse) {
    option (google.api.http).get = "/omniflix/onft/v1beta1/params";
  }
}
CLI Queries
  • Get List of denoms (collections)
    onftd query onft denoms
    
  • Get Denom details by it's Id
    onftd query onft denom <denom-id>
    
  • Get List of NFTs in a collection
    onftd query onft collection <denom-id>
    
  • Get Total Count of NFTs in a collection
    onftd query onft supply <denom-id>
    
  • Get NFT details by it's Id
    onftd query onft asset <denom-id> <nft-id>
    
  • Get All NFTs owned by an address
    onftd query onft owner <account-address>
    

Documentation

Index

Constants

View Source
const ConsensusVersion = 2

ConsensusVersion defines the current onft module consensus version.

Variables

This section is empty.

Functions

func DefaultGenesisState

func DefaultGenesisState() *types.GenesisState

func ExportGenesis

func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState

func InitGenesis

func InitGenesis(ctx sdk.Context, k keeper.Keeper, data types.GenesisState)

Types

type AppModule

type AppModule struct {
	AppModuleBasic
	// contains filtered or unexported fields
}

func NewAppModule

func NewAppModule(cdc codec.Codec, keeper keeper.Keeper, accountKeeper types.AccountKeeper,
	bankKeeper types.BankKeeper, distrKeeper types.DistributionKeeper, ss exported.Subspace,
) AppModule

func (AppModule) BeginBlock

func (AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock)

func (AppModule) ConsensusVersion

func (AppModule) ConsensusVersion() uint64

func (AppModule) EndBlock

func (AppModule) ExportGenesis

func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage

func (AppModule) GenerateGenesisState

func (AppModule) GenerateGenesisState(simState *module.SimulationState)

GenerateGenesisState creates a randomized GenState of the onft module.

func (AppModule) InitGenesis

func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage) []abci.ValidatorUpdate

func (AppModule) Name

func (AppModule) Name() string

func (AppModule) ProposalContents

func (am AppModule) ProposalContents(_ module.SimulationState) []simtypes.WeightedProposalMsg

func (AppModule) QuerierRoute

func (AppModule) QuerierRoute() string

func (AppModule) RegisterInvariants

func (am AppModule) RegisterInvariants(ir sdk.InvariantRegistry)

func (AppModule) RegisterQueryService

func (am AppModule) RegisterQueryService(server grpc.Server)

func (AppModule) RegisterServices

func (am AppModule) RegisterServices(cfg module.Configurator)

func (AppModule) RegisterStoreDecoder

func (am AppModule) RegisterStoreDecoder(sdr sdk.StoreDecoderRegistry)

RegisterStoreDecoder registers a decoder for onft module's types

func (AppModule) WeightedOperations

func (am AppModule) WeightedOperations(simState module.SimulationState) []simtypes.WeightedOperation

WeightedOperations returns the all the onft module operations with their respective weights.

type AppModuleBasic

type AppModuleBasic struct {
	// contains filtered or unexported fields
}

func (AppModuleBasic) DefaultGenesis

func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage

func (AppModuleBasic) GetQueryCmd

func (AppModuleBasic) GetQueryCmd() *cobra.Command

func (AppModuleBasic) GetTxCmd

func (AppModuleBasic) GetTxCmd() *cobra.Command

func (AppModuleBasic) Name

func (AppModuleBasic) Name() string

func (AppModuleBasic) RegisterGRPCGatewayRoutes

func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux)

func (AppModuleBasic) RegisterInterfaces

func (AppModuleBasic) RegisterInterfaces(registry codectypes.InterfaceRegistry)

func (AppModuleBasic) RegisterLegacyAminoCodec

func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino)

func (AppModuleBasic) ValidateGenesis

Directories

Path Synopsis
client
cli
migrations
v2
Package types is a reverse proxy.
Package types is a reverse proxy.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL