Skip to content

Instantly share code, notes, and snippets.

@losh11
Last active May 13, 2022 04:22
Show Gist options
  • Save losh11/f07a942353a68e2951b5b476cb9ebf50 to your computer and use it in GitHub Desktop.
Save losh11/f07a942353a68e2951b5b476cb9ebf50 to your computer and use it in GitHub Desktop.

NFT design & data structure

In OmniLite all NFTs belong to a Collection. Single NFT also belong to a collection. Each NFT is issued into a Collection, therefore you must first create a collection, then issue the NFT.

Each NFT has 3 data fields, as described below:

Data Type Length Mutability Description Reccomended Uses
Grant 255 chars immutable Data assigned during issuance ipfs link! unique attributes
Issuer 255 chars non-immutable Data assigned by NFT creator/issuer royalty address/percentage. any unique attributes
Holder 255 chars non-immutable Data assigned by NFT owner ?

The Issuer and Holder data fields can be modified at any time using omni_setnonfungibledata. More details.

Creating NFTs

To create a NFT collection use omni_sendissuancemanaged with type 5 denoting NFT.

omnilite-cli omni_sendissuancemanaged "NFT_FROM_ADDRESS" 1 5 0 "CATEGORY" "SUBCATEGORY" "NFT_COLLECTION_NAME" "URL_FOR_NFT_PROJECT" "DATA"

Recommended "CATEGORY": "NFT"

Recommended "SUBCATEGORY": "collection" or "unique"

Recommended "URL_FOR_NFT_PROJECT": this is not the ipfs link. Link to project website.

Recommended "DATA": this is not the ipfs link. use for collection description.


To issue a NFT in a collection use omni_sendgrant.

omni_sendgrant

Issue or grant new units of managed tokens.

Arguments:

Name Type Presence Description
fromaddress string required the address to send from
toaddress string required the receiver of the tokens (sender by default, can be "")
propertyid number required the identifier of the tokens to grant
amount string required the amount of tokens to create
grantdata string optional NFT only: data set in all NFTs created in this grant (default: empty)

Result:

"hash"  // (string) the hex-encoded transaction hash

Example:

$ omnicore-cli "omni_sendgrant" "3HsJvhr9qzgRe3ss97b1QHs38rmaLExLcH" "" 51 "7000"

Get/Set Data

omni_getnonfungibletokendata

Returns owner and all data set in a non-fungible token. If looking up a single token on tokenidstart can be specified only.

Arguments:

Name Type Presence Description
propertyid number required the property identifier
tokenidstart number required the first non-fungible token in range
tokenidend number required the last non-fungible token in range

Result:

{
  "index" : n,                  // (number) the unique index of the token
  "owner" : "owner",            // (string) the Bitcoin address of the owner
  "grantdata" : "grantdata",    // (string) contents of the grant data field
  "issuerdata" : "issuerdata",  // (string) contents of the issuer data field
  "holderdata" : "holderdata",  // (string) contents of the holder data field
}

Example:

$ omnicore-cli "omni_getnonfungibletokendata 1 10 20"

omni_setnonfungibledata

Sets either the issuer or holder data field in a non-fungible token. Holder data can only be updated by the token owner and issuer data can only be updated by address that created the tokens.

Arguments:

Name Type Presence Description
propertyid number required the property identifier
tokenstart number required the first token in the range to set data on
tokenend number required the last token in the range to set data on
issuer boolean required if true issuer data set, otherwise holder data set
data string required data set as in either issuer or holder fields

Result:

"hash"  // (string) the hex-encoded transaction hash

Example:

$ omnicore-cli "omni_setnonfungibledata" 70 50 60 true "string data"

Sending NFTs

omni_sendnonfungible

Create and broadcast a non-fungible send transaction.

Arguments:

Name Type Presence Description
address string required the address to send from
toaddress string required the address of the receiver
propertyid number required the identifier of the tokens to send
tokenstart number required the first token in the range to send
tokenend number required the last token in the range to send
redeemaddress string optional an address that can spend the transaction dust (sender by default)
referenceamount string optional a feathercoin amount that is sent to the receiver (minimal by default)

Result:

"hash"  // (string) the hex-encoded transaction hash

Example:

$ omnicore-cli "omni_sendnonfungible" "3M9qvHKtgARhqcMtM5cRT9VaiDJ5PSfQGY" "37FaKponF7zqoMLUjEiko25pDiuVH5YLEa" 70 1 1000

RPC changes

existing modified rpcs:

  • omni_getproperty: includes additional field non-fungibletoken (bool) - whether the property contains non-fungible tokens
  • omni_sendissuancemanaged: new property type 5 denoting non-fungible
  • omni_sendgrant: additional argument grantdata, data set in all NFTs created in the grant

new rpcs:

omni_getnonfungibletokens omni_getnonfungibletokendata omni_getnonfungibletokenranges omni_createpayload_sendnonfungible omni_createpayload_setnonfungibledata

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment