Blockchain

Minting a token

Note

Unless specified otherwise, id refers to the Elements database id of the object.

First the smart contract must be deployed to the blockchain. Then, make sure that the contract is registered in Elements

PATCH /blockchain/neo/contract

See if the user has any wallet. Requires the Elements user id to filter by user.

GET /blockchain/neo/wallet

If the user does not have a wallet, create one for them.

POST /blockchain/neo/wallet

this will return the newly created wallet.

With the wallet info, you can now assign the public key in the "owner" field of any new token you create. The token will be assigned to the account of the "owner" when it is minted. If "owner" is not specified, it will be assigned to the account that is paying the mint transaction fee, and can be transferred later.

To mint a token, first a token definition (see NEP11TokenState below) must be created in the Elements database.

You can use

GET /blockchain/neo/token

GET /blockchain/neo/token/{tokenNameOrId}

to get all or a specific token respectively, or

POST /blockchain/neo/token

to create a new token definition.

With the id of the token definition, you can use

POST /blockchain/neo/contract/mint

{
  "tokenIds": [
    "string"
  ],
  "walletId": "string",
  "password": "string"
}

to mint the token. Included in this request is the option to specify a wallet id and password, which will use the first or default account in this wallet to cover any transaction (e.g. GAS) fees. This will override the default wallet, if one has been assigned to the contract.

Invoking Other Smart Contract Methods

POST /blockchain/neo/contract/invocation

{
  "contractId": "string",
  "walletId": "string",
  "password": "string",
  "methodName": "string",
  "parameters": [
    {}
  ]
}

The method name must match the name in the contract manifest.

The order of the parameters must match the order in the contract manifest.

Similar to the mint request, this request includes the option to specify a wallet id and password, which will use the first or default account in this wallet to cover any transaction (e.g. GAS) fees. This will override the default wallet, if one has been assigned to the contract.

NEP11TokenState

There are two token models that can be sent to the NEP11 contract: ElementsPurchaseToken : Ownership is completely transferred to the purchaser ElementsLicenseToken : The minter of the token retains ownership, but grants access to the purchaser

ElementsToken (This is the Token model in elements, and also the model used on the blockchain)

For all Elements tokens, these are the common properties.

  • Owner (UInt160)
    • The account address of the owner to be assigned when minting this token.
  • Name (string)
    • The name given to this token.
  • Description (string)
    • The description of this token.
  • Tags (List)
    • Any tags to assist in filtering/searching for this token.
  • TotalSupply (long)
    • The maximum number of copies of this token that can be owned (by any number of accounts) at any one time.
  • Usages (long)
    • The maximum number of usages this token has (if applicable) before it will be disabled/burned.
  • AccessOption (string)
    • Indicates whether or not this can be viewed publicly. Valid values are:
      • "private" : Only the token or contract owner can view the token properties
      • "preview" : If not the token or contract owner, the asset urls cannot be viewed.
      • "public" : Can be viewed by everyone
    • Note: Access Options are purely notational. The actual data is still potentially visible on the blockchain. Access Options alone should not be used for security but rather a convenience for programming. In order to secure data stored on the blockchain, it should be encrypted client side and then transmitted to the chain.
  • PreviewUrls (List)
    • The URL pointed at any preview of the contents of this token. Consider making any images at a width between 320 and 1080 pixels and aspect ratio between 1.91:1 and 4:5 inclusive.
  • AssetUrls (List)
    • The asset URLs of this token.
  • Ownership
    • see below for details
  • TransferOptions (string)
    • The transfer options of this token. Valid values are:
      • "none" : Cannot be transferred
      • "resale_only" : Can be resold, but not traded
      • "trades_only" : Can be traded, but not resold
      • "resale_and_trades" : Can be either resold or traded
  • Revocable (bool)
    • Indicates whether or not the license is revocable by the owner If revoked, will return a prorated fee to the licensee based on the time remaining in the current period.
  • Expiry (long)
    • The expiration date of the license
      • Recorded in seconds since Unix epoch (1970 UTC)
  • Renewable (bool)
    • If true, the licensee may pay a fee to extend the expiration date by the same difference between the original expiry and the time of minting. If the fee is not processed before the expiration, the token will be returned to the minter. (TBD)
  • Metadata (map)
    • Any metadata a user wants to attach to the nft

NeoElementsToken (This is the NeoToken model in elements)

  • Id (String)
    • The unique ID of the token in elements/mongo.
  • ElementsToken (Token)
    • The base token properties used by the blockchain. (See ElementsToken above)
  • ContractId (string)
    • The elements contract id to mint this token with
    • Only elements needs to be aware of this field, this does not need to be represented in the blockchain data.
  • TotalMintedQuantity (long)
    • The current amount of tokens that have been minted, not to exceed the total supply.
  • SeriesId (string)
    • The uuid of this token series.
  • Listed(boolean)
    • Whether or not this token/definition is listed for sale.
  • MintStatus (string)
    • The current mint status of the token.
      • NOT_MINTED
        • no mint transaction has yet been attempted
      • MINTED
        • the mint transaction was verified
      • MINT_FAILED
        • the transaction that was sent to the blockchain either failed to be verified or encountered an error
      • MINT_PENDING
        • the transaction has been sent to the blockchain but has not been verified

ElementsPurchaseToken

Represents additional properties related to a purchasable token. The purchased token will transfer ownership completely to the purchaser. This token can then be traded or sold in accordance with the TransferOptions. If the token is resold, royalties will be assessed in accordance with the Ownership table.

  • Ownership
    • See below
  • TransferOptions (string)
    • The transfer options of this token. Valid values are:
      • "none" : Cannot be transferred
      • "resale_only" : Can be resold, but not traded
      • "trades_only" : Can be traded, but not resold
      • "resale_and_trades" : Can be either resold or traded

ElementsLicenseToken

Represents additional properties related a licensable token. The account that minted the token will retain ownership of the token, but will grant access to the purchasing account. For the purposes of accessing the content, the owner and the licensee will have the same rights. If an expiration date is set, then Elements will create a task to remove the license holder from the token state. If Elements is not running or was not used for this, then access to the token by the licensee will be denied if the current time is greater than the expiry.

  • Revocable (bool)
    • Indicates whether or not the license is revocable by the owner
    • If revoked, will return a prorated fee to the licensee based on the time remaining in the current period.
  • Expiry (long)
    • The expiration date of the license
    • Recorded in seconds since Unix epoch (1970 UTC)
  • Renewable (bool)
    • If true, the licensee may pay a fee to extend the expiration date by the same difference between the original expiry and the time of minting. *If the fee is not processed before the expiration, the token will be returned to the minter. (TBD)

Ownership

The Ownership is a property of any Elements NEP11 Token. It represents the split ownership of the token, and ties into both royalties and voting mechanics.

Royalties will be assigned to each owner based on: sale price x (shares / capitalization)

For there to be a change in ownership, all voting members must agree to the proposed changes. (TBD)

There is always another “owner” of the token outside of the Ownership table. This account is considered to have any remaining shares for the purposes of royalties. However, this account does not have any voting rights. This allows for the token to be resold multiple times without affecting the Ownership table.

The Ownership model is structured as such:

  • StakeHolders (List)
    • Voting (bool)
      • If true, allows for voting on any proposed change
    • Owner (UInt160)
      • The address/public key of the Stakeholder
    • Shares (long)
      • The number of shares assigned to the Stakeholder
  • Capitalization (long)
    • The total number of shares allocated to this token