Skip to content

Instantly share code, notes, and snippets.

@jdogresorg
Last active August 22, 2016 19:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jdogresorg/cd207753c249c3618ba3 to your computer and use it in GitHub Desktop.
Save jdogresorg/cd207753c249c3618ba3 to your computer and use it in GitHub Desktop.
Counterparty Subassets Proposal
    CIP: 4
    Title: Subassets
    Author: Jeremy Johnson (J-Dog)
    Status: Draft
    Type: Standards
    Created: 2016-01-29

Abstract

Establishes a protocol for issuing subassets

(ex. PIZZA, PIZZA.DOMINOS, PIZZA.DOMINOS.COUPON, PIZZA.Dominos.Coupon!)

Motivation

To enable named asset owners the ability and flexibility to issue new easily identified and related named assets.

Definitions

asset

A named asset which acts as PARENT to a subasset

subasset

A numeric asset which is a CHILD of a named asset

longname

A alphabetical string which indicates the full subasset name (_ex._ PIZZA.DOMINOS, PIZZA.dominos, PIZZA.DoMiNoS.Coupon )

Specifications

  1. Subasset names must meet following requirements :

    • 1 to 250 characters in length (ie. PIZZA.X or PIZZA.REALLY-long-VALID-Subasset-NAME)
    • Contain only characters : a-zA-Z0-9.-_@!
    • Cannot start or end with a period (.)
    • Cannot contain multiple consecutive periods (..)
  2. Subasset can only be issued from same address that owns the parent asset at the time of the issuance.

  3. Subasset can be transferred to a new owner address after initial issuance (if necessary)

  4. Subasset has issuance cost of 0.25 XCP (anti-spam)

Changes

Database

  1. Add asset_longname TEXT UNIQUE field to Assets table

Issuances

Given the example of asset PIZZA and subasset PIZZA.DOMINOS counterparty-lib would require the following changes:

  1. When validating a subasset issuance attempt (issuance.validate):

    • Verify that issuing address is owner of PIZZA asset.
    • Verify that PIZZA.DOMINOS does not already exist by checking asset_longname for PIZZA.DOMINOS
  2. When issuing a valid subasset (issuance.compose):

    • Issue random numeric asset and set description to EXISTING DESCRIPTION + 3b3b6C50495a5a412e444f4d494e4f53
    (hex) 3b3b6C50495a5a412e444f4d494e4f53
    (text) ;;lPIZZA.DOMINOS
    
    ;; = marks start of key/value pairs
    l  = longname
    
    PIZZA.DOMINOS = long asset name
    
  3. When parsing/reparsing issuance transactions (issuance.parse):

    • After block X, description.rsplit('3b3b',1) to get any name/value pairs.
    • Create issuance record
    • If name/value pairs are present
      • Decode name/value pairs from hex to text
      • Parse in longname
    • If longname is present
      • Verify that asset is numeric and this is first issuance.
      • Verify that issuing address is owner of PIZZA asset.
      • Verify that PIZZA.DOMINOS does not already exist by checking asset_longname for PIZZA.DOMINOS
    • If longname is valid
      • Update Assets table to set asset_longname to longname value

API

  1. When making requests to get asset information (get_issuances & get_asset_info):
    • return new asset_longname value (if any)

API Examples

Asset Issuances

Issue the named asset PIZZA.

payload = {
   "method": "create_issuance",
   "params": {
              "source": "1Mqn41zrgRKXRjwkT8MZ3ENhyrKy5nWJVW",
              "asset": "PIZZA",
              "quantity": 0,
              "divisible": true,
              "description": "Pizza is good",
             },
   "jsonrpc": "2.0",
   "id": 0,
}

Issue a random numeric asset with the asset_longname field set to PIZZA.DOMINOS

payload = {
   "method": "create_issuance",
   "params": {
              "source": "1Mqn41zrgRKXRjwkT8MZ3ENhyrKy5nWJVW",
              "asset": "PIZZA.DOMINOS",
              "quantity": 0,
              "divisible": true,
              "description": "Dominos pizza is really good"
             },
   "jsonrpc": "2.0",
   "id": 0,
}

Issue a random numeric asset with the asset_longname field set to PIZZA.DOMINOS.Coupon.Christmas.2016!

payload = {
   "method": "create_issuance",
   "params": {
              "source": "1Mqn41zrgRKXRjwkT8MZ3ENhyrKy5nWJVW",
              "asset": "PIZZA.DOMINOS.Coupon.Christmas.2016!",
              "quantity": 0,
              "divisible": true,
              "description": "Dominos pizza customer loyalty coupon"
             },
   "jsonrpc": "2.0",
   "id": 0,
}
@sull
Copy link

sull commented Aug 22, 2016

Is this the leading proposal?

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