Progetto Scaffolded Go Token per ERC-1155

Blockchain App Builder prende l'input dal file di specifica del token e genera un progetto di codice concatenato impalcato completamente funzionale.

Il progetto genera automaticamente classi e funzioni del ciclo di vita dei token, inclusi i metodi CRUD e non CRUD. La convalida degli argomenti, il marshalling/unmarshalling e la capacità di persistenza trasparente sono tutti supportati automaticamente.

Per informazioni sul progetto impalcato e sui metodi non direttamente correlati ai token, vedere Progetto codice catena go impalcato.

Modello

La funzionalità di persistenza trasparente, o ORM semplificato, viene acquisita nella classe OchainModel. Il modello seguente mostra un token intero non fungibile.

package model

type ArtCollection struct {
	AssetType     string `json:"AssetType" final:"otoken"`
	TokenId       string `json:"TokenId" id:"true" mandatory:"true" validate:"regexp=^[A-Za-z0-9][A-Za-z0-9_-]*$,max=16"`
	TokenName     string `json:"TokenName" final:"artcollection"`
	TokenDesc     string `json:"TokenDesc" validate:"max=256"`
	TokenStandard string `json:"TokenStandard" final:"erc1155+"`
	TokenType     string `json:"TokenType" final:"nonfungible" validate:"regexp=^nonfungible$"`
	TokenUnit     string `json:"TokenUnit" final:"whole" validate:"regexp=^whole$"`

	Mintable map[string]interface{} `json:"Mintable" final:"{\"Max_mint_quantity\":20000}"`

	Behaviors []string `json:"Behaviors" final:"[\"indivisible\",\"singleton\",\"mintable\",\"transferable\",\"burnable\",\"roles\"]"`

	Roles map[string]interface{} `json:"Roles" final:"{\"minter_role_name\":\"minter\"}"`

	Owner           string `json:"Owner,omitempty" validate:"string"`
	CreatedBy       string `json:"CreatedBy,omitempty" validate:"string"`
	TransferredBy   string `json:"TransferredBy,omitempty" validate:"string"`
	CreationDate    string `json:"CreationDate,omitempty" validate:"string"`
	TransferredDate string `json:"TransferredDate,omitempty" validate:"string"`
	IsBurned        bool   `json:"IsBurned" validate:"bool"`
	BurnedBy        string `json:"BurnedBy,omitempty" validate:"string"`
	BurnedDate      string `json:"BurnedDate,omitempty" validate:"string"`
	TokenUri        string `json:"TokenUri" mandatory:"true" validate:"string,max=2000"`

	TokenMetadata ArtCollectionMetadata `json:"TokenMetadata"`

	Price        int  `json:"Price" validate:"int"`
	On_sale_flag bool `json:"On_sale_flag" validate:"bool"`
}

type ArtCollectionMetadata struct {
	Painting_name string `json:"Painting_name" validate:"string"`
	Description   string `json:"Description" validate:"string"`
	Image         string `json:"Image" validate:"string"`
	Painter_name  string `json:"Painter_name" validate:"string"`
}

type Loyalty struct {
	AssetType     string `json:"AssetType" final:"otoken"`
	TokenId       string `json:"TokenId" id:"true" mandatory:"true" validate:"regexp=^[A-Za-z0-9][A-Za-z0-9_-]*$,max=16"`
	TokenName     string `json:"TokenName" final:"loyalty"`
	TokenDesc     string `json:"TokenDesc" validate:"max=256"`
	TokenStandard string `json:"TokenStandard" final:"erc1155+"`
	TokenType     string `json:"TokenType" final:"fungible" validate:"regexp=^fungible$"`
	TokenUnit     string `json:"TokenUnit" final:"fractional" validate:"regexp=^fractional$"`

	Mintable map[string]interface{} `json:"Mintable" final:"{\"Max_mint_quantity\":10000}"`

	Divisible map[string]interface{} `json:"Divisible" final:"{\"Decimal\":2}"`

	Behaviors []string `json:"Behaviors" final:"[\"divisible\",\"mintable\",\"transferable\",\"burnable\",\"roles\"]"`

	Roles map[string]interface{} `json:"Roles" final:"{\"minter_role_name\":\"minter\"}"`

	Currency_name           string      `json:"Currency_name" validate:"string"`
	Token_to_currency_ratio int         `json:"Token_to_currency_ratio" validate:"int"`
	Metadata                interface{} `json:"Metadata,omitempty"`
}
Il modello seguente mostra un token non fungibile frazionario.
type RealEstateProperty struct {
      AssetType string `json:"AssetType" final:"otoken"`
      TokenId string `json:"TokenId" id:"true" mandatory:"true" validate:"regexp=^[A-Za-z0-9][A-Za-z0-9_-]*$,max=16"`
      TokenName string `json:"TokenName" final:"realestateproperty"`
      TokenDesc string `json:"TokenDesc" validate:"max=256"`
      TokenStandard string `json:"TokenStandard" final:"erc1155+"`
      TokenType string `json:"TokenType" final:"nonfungible" validate:"regexp=^nonfungible$"`
      TokenUnit string `json:"TokenUnit" final:"fractional" validate:"regexp=^fractional$"`

      Mintable map[string]interface{} `json:"Mintable" final:"{\"Max_mint_quantity\":0}"`
      Behaviors []string `json:"Behaviors" final:"[\"divisible\",\"mintable\",\"transferable\",\"roles\"]"`

      Divisible map[string]interface{} `json:"Divisible" final:"{\"Decimal\":0}"`

      Roles map[string]interface{} `json:"Roles" final:"{\"minter_role_name\":\"minter\"}"`

      CreatedBy string `json:"CreatedBy,omitempty" validate:"string"`
      CreationDate string `json:"CreationDate,omitempty" validate:"string"`
      IsBurned bool `json:"IsBurned" validate:"bool"`
      TokenUri string `json:"TokenUri" mandatory:"true" validate:"string,max=2000"`
      Quantity float64 `json:"Quantity,omitempty"`
      TokenMetadata RealEstatePropertyMetadata `json:"TokenMetadata"`

      PropertySellingPrice int `json:"PropertySellingPrice" validate:"int"`
      PropertyRentingPrice int `json:"PropertyRentingPrice" validate:"int"`
}

type RealEstatePropertyMetadata struct {
      PropertyType string `json:"PropertyType" validate:"string"`
      PropertyName string `json:"PropertyName" validate:"string"`
      PropertyAddress string `json:"PropertyAddress" validate:"string"`
      PropertyImage string `json:"PropertyImage" validate:"string"`
}

Controller

C'è solo un controller principale.

type Controller struct {
    Ctx trxcontext.TrxContext
}

È possibile creare un numero qualsiasi di classi, funzioni o file, ma solo i metodi definiti nella classe controller principale sono richiamabili. Gli altri metodi sono nascosti.

È possibile utilizzare i metodi SDK token per scrivere metodi personalizzati per l'applicazione business.

Metodi token generati automaticamente

Blockchain App Builder genera automaticamente metodi per supportare token e cicli di vita dei token. È possibile utilizzare questi metodi per inizializzare i token, gestire ruoli e account e completare altri task del ciclo di vita dei token senza alcuna codifica aggiuntiva. I metodi controller devono essere pubblici per poter essere richiamati. I nomi dei metodi pubblici iniziano con un carattere maiuscolo. I nomi dei metodi che iniziano con un carattere minuscolo sono privati.

Metodi per la gestione del controllo degli accessi

IsTokenAdmin
Questo metodo restituisce il valore booleano true se il chiamante della funzione è Token Admin, altrimenti restituisce false. Questo metodo può essere chiamato solo dal Token Admin del codice concatenato.
func (t *Controller) IsTokenAdmin(orgId string, userId string) (interface{}, error) {
            auth, err := t.Ctx.ERC1155Auth.CheckAuthorization("ERC1155Admin.IsUserTokenAdmin", "TOKEN", map[string]string{"orgId": orgId, "userId": userId})
            if err != nil || !auth {
                  return false, fmt.Errorf("error in authorizing the caller %s", err.Error())
            }
            return t.Ctx.ERC1155Auth.IsUserTokenAdmin(orgId, userId)
      }
Parametri:
  • orgId: string - L'ID MSP (Membership Service Provider) dell'utente nell'organizzazione corrente.
  • userId: string: il nome utente o l'ID e-mail dell'utente.
Restituisce:
  • Il metodo restituisce true se il chiamante è Token Admin, altrimenti restituisce false.
Esempio di valore restituito:
{"result": true}
AddTokenAdmin
Questo metodo aggiunge un utente come Token Admin del codice concatenato. Questo metodo può essere chiamato solo da un Token Admin del codice concatenato.
func (t *Controller) AddTokenAdmin(orgId string, userId string) (interface{}, error) {
            auth, err := t.Ctx.ERC1155Auth.CheckAuthorization("ERC1155Admin.AddAdmin", "TOKEN")
            if err != nil && !auth {
                  return nil, fmt.Errorf("error in authorizing the caller %s", err.Error())
            }
            return t.Ctx.ERC1155Admin.AddAdmin(orgId, userId)
      }
Parametri:
  • orgId: string - L'ID MSP (Membership Service Provider) dell'utente nell'organizzazione corrente.
  • userId: string: il nome utente o l'ID e-mail dell'utente.
Restituisce:
  • In caso di operazione riuscita, un messaggio che include i dettagli dell'utente aggiunto come Token Admin del codice concatenato.
Valore restituito
{"msg":"Successfully added Admin (orgId: appDev, userId: user1)"}
RemoveTokenAdmin
Questo metodo rimuove un utente come Token Admin del codice concatenato. Questo metodo può essere chiamato solo da un Token Admin del codice concatenato. Non è possibile rimuovere se stessi come Token Admin.
func (t *Controller) RemoveTokenAdmin(orgId string, userId string) (interface{}, error) {
            auth, err := t.Ctx.ERC1155Auth.CheckAuthorization("ERC1155Admin.RemoveAdmin", "TOKEN")
            if err != nil && !auth {
                  return nil, fmt.Errorf("error in authorizing the caller %s", err.Error())
            }
            return t.Ctx.ERC1155Admin.RemoveAdmin(orgId, userId)
      }
Parametri:
  • orgId: string - L'ID MSP (Membership Service Provider) dell'utente nell'organizzazione corrente.
  • userId: string: il nome utente o l'ID e-mail dell'utente.
Restituisce:
  • In caso di operazione riuscita, un messaggio che include i dettagli dell'utente rimosso come Token Admin del codice concatenato.
Valore restituito
{
    "msg": "Successfully removed Admin (orgId appdev userId user1)"
}
GetAllTokenAdmins
Questo metodo restituisce un elenco di tutti gli utenti che sono un Token Admin del codice concatenato. Questo metodo può essere chiamato solo dal Token Admin del codice concatenato.
func (t *Controller) GetAllTokenAdmins() (interface{}, error) {
            auth, err := t.Ctx.ERC1155Auth.CheckAuthorization("ERC1155Admin.GetAllAdmins", "TOKEN")
            if err != nil && !auth {
                  return nil, fmt.Errorf("error in authorizing the caller %s", err.Error())
            }
            return t.Ctx.ERC1155Admin.GetAllAdminUsers()
      }
Parametri:
  • nessuno
Restituisce:
  • In caso di operazione riuscita, un array admins in formato JSON.
Valore restituito
{
  "admins": [
    {
      "OrgId": "appdev",
      "UserId": "idcqa"
    },
    {
      "OrgId": "appdev",
      "UserId": "user1"
    }
  ]
}

Metodi per la gestione della configurazione token

Init
Questo metodo viene richiamato quando viene creata un'istanza del codice concatenato. Ogni Token Admin è identificato dalle informazioni userId e orgId nel parametro adminList. userId è il nome utente o l'ID e-mail del proprietario dell'istanza o dell'utente che ha eseguito il login all'istanza. orgId è l'ID MSP (Membership Service Provider) dell'utente nell'organizzazione di rete corrente. Il parametro adminList è obbligatorio alla prima distribuzione del codice concatenato. Se si sta aggiornando il codice concatenato, passare un elenco vuoto ([]). Se si è l'utente che ha inizialmente distribuito il codice concatenato, è anche possibile specificare nuovi amministratori nel parametro adminList durante l'aggiornamento del codice concatenato. Qualsiasi altra informazione nel parametro adminList viene ignorata durante gli aggiornamenti.
func (t *Controller) Init(adminList []erc1155Admin.ERC1155TokenAdminAsset) (interface{}, error) {
      list, err := t.Ctx.ERC1155Admin.InitAdmin(adminList)
      if err != nil {
            return nil, fmt.Errorf("initialising admin list failed %s", err.Error())
      }
      <1st Token Name> := <1st TokenClassName>{}
      _, err = t.Ctx.ERC1155Token.SaveClassInfo(&<1st Token Name>)
      if err != nil {
            return nil, err
      }
         .
         .
      <nth Token Name> := <nth TokenClassName>{}
      _, err = t.Ctx.ERC1155Token.SaveClassInfo(&<nth Token Name>)
      if err != nil {
            return nil, err
      }
      _, err = t.Ctx.ERC1155Token.SaveDeleteTransactionInfo()
      if err != nil {
            fmt.Println("error: ", err)
      }
      return list, err
}
Parametri:
  • adminList array: array di informazioni {OrgId, UserId} che specifica la lista di amministratori di token. L'array adminList è un parametro obbligatorio.
Create<Token Name>Token
Questo metodo crea i token. Ogni token definito ha il proprio metodo di creazione. Per i token fungibili, questo metodo può essere chiamato solo da un Token Admin del codice concatenato. Per i token non fungibili, se il ruolo minter è definito nel file di specifica, qualsiasi utente con il ruolo minter può chiamare questo metodo per creare un NFT. Se il ruolo minter non è definito, qualsiasi utente può utilizzare questo metodo per creare (mint) NFT. L'utente che chiama questo metodo diventa il proprietario del NFT.
Token fungibili:
func (t *Controller) Create<Token Name>Token(tokenAsset <Token Class>) (interface{}, error) {
            auth, err := t.Ctx.ERC1155Auth.CheckAuthorization("ERC1155Token.Save", "TOKEN")
            if err != nil && !auth {
                  return nil, fmt.Errorf("error in authorizing the caller %s", err.Error())
            }
            return t.Ctx.ERC1155Token.Save(&tokenAsset)
    }
Token non fungibili:
func (t *Controller) Create<Token Name>Token(tokenAsset <Token Class>, quantity float64) (interface{}, error) {
         quantityToPass := []float64{quantity}
          return t.Ctx.ERC1155Token.Save(&tokenAsset, quantityToPass...)
    }
Parametri:
  • tokenAsset: <Token Class>: asset del token. Le proprietà dell'asset sono definite nel file del modello.
  • quantity: number – Solo per i token non fungibili, il numero di token da mint. L'unico valore supportato per questo parametro è 1.
Restituisce:
  • In caso di operazione riuscita, l'asset token in formato JSON, che include le informazioni riportate di seguito, a seconda del tipo di token.
  • Behaviors: una lista di comportamenti token. Proprietà non modificabile.
  • CreatedBy – L'ID account del chiamante, che è l'utente che sta usando il token. Proprietà non modificabile.
  • CreationDate – Il timestamp della transazione di conio. Proprietà non modificabile.
  • IsBurned: questa proprietà indica se il token viene masterizzato. Proprietà non modificabile.
  • Mintable – Le proprietà relative al minting. Il valore max_mint_quantity definisce il numero massimo di token che è possibile creare per la classe di token.
  • Owner – L'ID account del proprietario corrente, che è il chiamante del metodo.
  • Symbol: il simbolo del token. Proprietà non modificabile.
  • TokenDesc: la descrizione del token.
  • TokenMetadata: informazioni JSON che descrivono il token.
  • TokenName: il nome del token. Proprietà non modificabile.
  • TokenStandard: lo standard del token. Proprietà non modificabile.
  • TokenType – Il tipo di token (fungibile o non fungibile). Proprietà non modificabile.
  • TokenUnit – L'unità del token (intero o frazionario). Proprietà non modificabile.
  • TokenUri: l'URI del token.
  • Quantity: la quantità del token.
Esempio di valore restituito (NFT intero):
{
    "AssetType": "otoken",
    "Behaviors": [
        "indivisible",
        "singleton",
        "mintable",
        "transferable",
        "burnable",
        "roles"
    ],
    "CreatedBy": "oaccount~42e89f4c72dfde9502814876423c6da630d466e87436dd1aae201d347ad1288d",
    "CreationDate": "2022-12-29T09:57:03+05:30",
    "IsBurned": false,
    "Mintable": {
        "Max_mint_quantity": 500
    },
    "OnSaleFlag": false,
    "Owner": "oaccount~42e89f4c72dfde9502814876423c6da630d466e87436dd1aae201d347ad1288d",
    "Price": 100,
    "Quantity": 1,
    "Roles": {
        "burner_role_name": "burner",
        "minter_role_name": "minter"
    },
    "TokenDesc": "token description",
    "TokenId": "monalisa",
    "TokenMetadata": {
        "Description": "Mona Lisa Painting",
        "Image": "monalisa.jpeg",
        "PainterName": "Leonardo_da_Vinci",
        "PaintingName": "Mona_Lisa"
    },
    "TokenName": "artcollection",
    "TokenStandard": "erc1155+",
    "TokenType": "nonfungible",
    "TokenUnit": "whole",
    "TokenUri": "https://bafybeid6pmpp62bongoip5iy2skosvyxh3gr7r2e35x3ctvawjco6ddmsq\\\\ .ipfs.infura-ipfs.io/?filename=MonaLisa.jpeg"
}
Esempio di valore restituito (token fungibile):
{
    "AssetType": "otoken",
    "Behaviors": [
        "divisible",
        "mintable",
        "transferable",
        "burnable",
        "roles"
    ],
    "Currency_name": "Dollar",
    "Divisible": {
        "Decimal": 2
    },
    "Mintable": {
        "Max_mint_quantity": 10000
    },
    "Roles": {
        "burner_role_name": "burner",
        "minter_role_name": "minter"
    },
    "TokenDesc": "Token Description",
    "TokenId": "Loyalty",
    "TokenName": "loyalty",
    "TokenStandard": "erc1155+",
    "TokenType": "fungible",
    "TokenUnit": "fractional",
    "Token_to_currency_ratio": 0
}
Esempio di valore restituito (NFT frazionale):
{
    "AssetType": "otoken",
    "Behaviors": [
        "divisible",
        "mintable",
        "transferable",
        "burnable",
        "roles"
    ],
    "CreatedBy": "oaccount~42e89f4c72dfde9502814876423c6da630d466e87436dd1aae201d347ad1288d",
    "CreationDate": "2023-06-14T09:53:53+05:30",
    "Divisible": {
        "Decimal": 2
    },
    "IsBurned": false,
    "Mintable": {
        "Max_mint_quantity": 20000
    },
    "On_sale_flag": false,
    "Price": 1000,
    "Quantity": 100,
    "Roles": {
        "burner_role_name": "burner",
        "minter_role_name": "minter"
    },
    "TokenDesc": "Token Description",
    "TokenId": "realEstate",
    "TokenMetadata": {
        "Description": "Painting Description",
        "Image": "",
        "Painter_name": "",
        "Painting_name": "Paint"
    },
    "TokenName": "realestate",
    "TokenStandard": "erc1155+",
    "TokenType": "nonfungible",
    "TokenUnit": "fractional",
    "TokenUri": "www.realestate.example.com"
}
Update<Token Name>Token
Questo metodo aggiorna i token. Ogni token definito ha il proprio metodo di aggiornamento. Impossibile aggiornare i metadati del token o l'URI del token di token non fungibili. Per i token fungibili, questo metodo può essere chiamato solo da un Token Admin del codice concatenato. Per i token non fungibili, questo metodo può essere chiamato solo dal proprietario del token.
Token fungibili:
func (t *Controller) Update<%=tokenModelName%>Token(tokenAsset <%=tokenModelName%>) (interface{}, error) {
        auth, err := t.Ctx.ERC1155Auth.CheckAuthorization("ERC1155Token.Update", "TOKEN")
            if err != nil && !auth {
                  return nil, fmt.Errorf("error in authorizing the caller %s", err.Error())
            }
            return t.Ctx.ERC1155Token.Update(&tokenAsset)
    }
Token non fungibili:
func (t *Controller) Update<%=tokenModelName%>Token(tokenAsset <%=tokenModelName%>) (interface{}, error) {
            return t.Ctx.ERC1155Token.Update(&tokenAsset)
    }
Parametri:
  • tokenAsset: <Token Class>: asset del token. Le proprietà dell'asset sono definite nel file del modello.
Restituisce:
  • In caso di operazione riuscita, l'asset token aggiornato in formato JSON.
Esempio di valore restituito (NFT intero):
{
    "AssetType": "otoken",
    "Behaviors": [
        "indivisible",
        "singleton",
        "mintable",
        "transferable",
        "burnable",
        "roles"
    ],
    "CreatedBy": "oaccount~42e89f4c72dfde9502814876423c6da630d466e87436dd1aae201d347ad1288d",
    "CreationDate": "2022-12-29T09:57:03+05:30",
    "IsBurned": false,
    "Mintable": {
        "Max_mint_quantity": 500
    },
    "OnSaleFlag": false,
    "Owner": "oaccount~42e89f4c72dfde9502814876423c6da630d466e87436dd1aae201d347ad1288d",
    "Price": 100,
    "Quantity": 1,
    "Roles": {
        "burner_role_name": "burner",
        "minter_role_name": "minter"
    },
    "TokenDesc": "token description",
    "TokenId": "monalisa",
    "TokenMetadata": {
        "Description": "Mona Lisa Painting",
        "Image": "monalisa.jpeg",
        "PainterName": "Leonardo_da_Vinci",
        "PaintingName": "Mona_Lisa"
    },
    "TokenName": "artcollection",
    "TokenStandard": "erc1155+",
    "TokenType": "nonfungible",
    "TokenUnit": "whole",
    "TokenUri": "https://bafybeid6pmpp62bongoip5iy2skosvyxh3gr7r2e35x3ctvawjco6ddmsq\\\\ .ipfs.infura-ipfs.io/?filename=MonaLisa.jpeg"
}
GetTokenHistory
Questo metodo restituisce la cronologia per un ID token specificato. Chiunque può chiamare questo metodo.
func (t *Controller) GetTokenHistory(tokenId string) (interface{}, error) {
            return t.Ctx.ERC1155Token.GetTokenHistory(tokenId)
      }
Parametri:
  • tokenId: string: l'ID del token.
Restituisce:
  • In caso di operazione riuscita, un array JSON contenente la cronologia dei token.
Esempio di valore restituito (token fungibile):
[
  {
    "IsDelete": "false",
    "Timestamp": "2022-12-08T09:54:11Z",
    "TxId": "823sa7c7a00941c62285c86f922bc4d3f5326a20f4bf2f82daa5bc661e4682e8",
    "Value": {
      "AssetType": "otoken",
      "Behaviors": [
        "divisible",
        "mintable",
        "transferable",
        "roles"
      ],
      "Currency_name": "Rupees",
      "Divisible": {
        "Decimal": 2
      },
      "Mintable": {
        "Max_mint_quantity": 1000
      },
      "Roles": {
        "burner_role_name": "burner",
        "minter_role_name": "minter"
      },
      "TokenDesc": "Updated Token Description",
      "TokenId": "tokenOne",
      "TokenName": "moneytok",
      "TokenStandard": "erc1155+",
      "TokenType": "fungible",
      "TokenUnit": "fractional",
      "Token_to_currency_ratio": 0
    }
  },
  {
    "IsDelete": "false",
    "Timestamp": "2022-12-08T09:54:11Z",
    "TxId": "711bb7c7a00941c62285c86f922bc3b3f5326a20f4bf2f82daa5bc661e4682e8",
    "Value": {
      "AssetType": "otoken",
      "Behaviors": [
        "divisible",
        "mintable",
        "transferable",
        "roles"
      ],
      "Currency_name": "Dollar",
      "Divisible": {
        "Decimal": 2
      },
      "Mintable": {
        "Max_mint_quantity": 1000
      },
      "Roles": {
        "burner_role_name": "burner",
        "minter_role_name": "minter"
      },
      "TokenDesc": "",
      "TokenId": "tokenOne",
      "TokenName": "moneytok",
      "TokenStandard": "erc1155+",
      "TokenType": "fungible",
      "TokenUnit": "fractional",
      "Token_to_currency_ratio": 0
    }
  }
]
Esempio di valore restituito (NFT frazionale):
[
    {
        "Timestamp": "2023-06-20T01:06:33Z",
        "TrxId": "16e53db4f8107f9634b7c3a0a2a81a00f69b634f2a52902b809e544d07f272b1",
        "Value": {
            "AssetType": "otoken",
            "Behaviors": [
                "divisible",
                "mintable",
                "transferable",
                "burnable",
                "roles"
            ],
            "CreatedBy": "oaccount~87bcb699d507368ee3966cd03ee6d7736ffc55dde8c0f0e16b14866334ac504a",
            "CreationDate": "2023-06-20T01:02:27Z",
            "Divisible": {
                "Decimal": 2
            },
            "IsBurned": false,
            "Mintable": {
                "Max_mint_quantity": 20000
            },
            "On_sale_flag": true,
            "Owners": [
                {
                    "AccountId": "oaccount~87bcb699d507368ee3966cd03ee6d7736ffc55dde8c0f0e16b14866334ac504a",
                    "TokenShare": 10
                },
                {
                    "AccountId": "oaccount~3cddfdaa855900579d963aa6f755a4aed1f3a474a2462c1b45bd7f36df673224",
                    "TokenShare": 10
                }
            ],
            "Price": 2000,
            "Quantity": 20,
            "Roles": {
                "burner_role_name": "burner",
                "minter_role_name": "minter"
            },
            "TokenDesc": "",
            "TokenId": "FNFT",
            "TokenMetadata": {
                "Description": "",
                "Image": "",
                "Painter_name": "",
                "Painting_name": ""
            },
            "TokenName": "realestate",
            "TokenStandard": "erc1155+",
            "TokenType": "nonfungible",
            "TokenUnit": "fractional",
            "TokenUri": "www.FNFT.example.com"
        }
    },
    {
        "Timestamp": "2023-06-20T01:02:27Z",
        "TrxId": "cec80910d087682554048f911d2cf98b66382bbcf1615483fa1c96c7ea08077c",
        "Value": {
            "AssetType": "otoken",
            "Behaviors": [
                "divisible",
                "mintable",
                "transferable",
                "burnable",
                "roles"
            ],
            "CreatedBy": "oaccount~87bcb699d507368ee3966cd03ee6d7736ffc55dde8c0f0e16b14866334ac504a",
            "CreationDate": "2023-06-20T01:02:27Z",
            "Divisible": {
                "Decimal": 2
            },
            "IsBurned": false,
            "Mintable": {
                "Max_mint_quantity": 20000
            },
            "On_sale_flag": true,
            "Owners": [
                {
                    "AccountId": "oaccount~87bcb699d507368ee3966cd03ee6d7736ffc55dde8c0f0e16b14866334ac504a",
                    "TokenShare": 20
                }
            ],
            "Price": 2000,
            "Quantity": 20,
            "Roles": {
                "burner_role_name": "burner",
                "minter_role_name": "minter"
            },
            "TokenDesc": "",
            "TokenId": "FNFT",
            "TokenMetadata": {
                "Description": "",
                "Image": "",
                "Painter_name": "",
                "Painting_name": ""
            },
            "TokenName": "realestate",
            "TokenStandard": "erc1155+",
            "TokenType": "nonfungible",
            "TokenUnit": "fractional",
            "TokenUri": "www.FNFT.example.com"
        }
    }
]
Esempio di valore restituito (NFT intero):
[
    {
        "IsDelete": "false",
        "Timestamp": "2023-06-20T01:15:56Z",
        "TxId": "89a3df3ebbe6dca2bcfbd51fc7dca9aab818a2af746b79a92dc8155b729ab22d",
        "Value": {
            "AssetType": "otoken",
            "Behaviors": [
                "indivisible",
                "singleton",
                "mintable",
                "transferable",
                "roles"
            ],
            "CreatedBy": "oaccount~87bcb699d507368ee3966cd03ee6d7736ffc55dde8c0f0e16b14866334ac504a",
            "CreationDate": "2023-06-20T01:15:56Z",
            "IsBurned": false,
            "Mintable": {
                "Max_mint_quantity": 20000
            },
            "On_sale_flag": true,
            "Owner": "oaccount~87bcb699d507368ee3966cd03ee6d7736ffc55dde8c0f0e16b14866334ac504a",
            "Price": 2000,
            "Quantity": 1,
            "Roles": {
                "burner_role_name": "burner",
                "minter_role_name": "minter"
            },
            "TokenDesc": "Updated Token Description",
            "TokenId": "NFT",
            "TokenMetadata": {
                "Description": "",
                "Image": "",
                "Painter_name": "",
                "Painting_name": ""
            },
            "TokenName": "artcollection",
            "TokenStandard": "erc1155+",
            "TokenType": "nonfungible",
            "TokenUnit": "whole",
            "TokenUri": "www.NFT.example.com"
        }
    },
    {
        "IsDelete": "false",
        "Timestamp": "2023-06-20T01:15:56Z",
        "TxId": "90d6af3ebbe6dca2bcfbd51fc7dca9aab818a2af746b79a92dc8155b729ab22d",
        "Value": {
            "AssetType": "otoken",
            "Behaviors": [
                "indivisible",
                "singleton",
                "mintable",
                "transferable",
                "roles"
            ],
            "CreatedBy": "oaccount~87bcb699d507368ee3966cd03ee6d7736ffc55dde8c0f0e16b14866334ac504a",
            "CreationDate": "2023-06-20T01:15:56Z",
            "IsBurned": false,
            "Mintable": {
                "Max_mint_quantity": 20000
            },
            "On_sale_flag": true,
            "Owner": "oaccount~87bcb699d507368ee3966cd03ee6d7736ffc55dde8c0f0e16b14866334ac504a",
            "Price": 2000,
            "Quantity": 1,
            "Roles": {
                "burner_role_name": "burner",
                "minter_role_name": "minter"
            },
            "TokenDesc": "",
            "TokenId": "NFT",
            "TokenMetadata": {
                "Description": "",
                "Image": "",
                "Painter_name": "",
                "Painting_name": ""
            },
            "TokenName": "artcollection",
            "TokenStandard": "erc1155+",
            "TokenType": "nonfungible",
            "TokenUnit": "whole",
            "TokenUri": "www.NFT.example.com"
        }
    }
]
GetAllTokens
Questo metodo restituisce tutti gli asset token salvati nel database di stato. Questo metodo può essere chiamato solo da un Token Admin del codice concatenato. Questo metodo utilizza query avanzate SQL DB Berkeley e può essere richiamato solo quando si è connessi alla rete remota di Oracle Blockchain Platform.
func (t *Controller) GetAllTokens() (interface{}, error) {
            auth, err := t.Ctx.ERC1155Auth.CheckAuthorization("ERC1155Token.GetAllTokens", "TOKEN")
            if err != nil && !auth {
                  return nil, fmt.Errorf("error in authorizing the caller %s", err.Error())
            }
            return t.Ctx.ERC1155Token.GetAllTokens()
      }
Parametri:
  • nessuno
Restituisce:
  • Lista di tutti gli asset token in formato JSON.
Valore restituito
[
  {
    "key": "tokenOne",
    "valueJson": {
      "AssetType": "otoken",
      "Behaviors": [
        "divisible",
        "mintable",
        "transferable",
        "roles"
      ],
      "Currency_name": "",
      "Divisible": {
        "Decimal": 2
      },
      "Mintable": {
        "Max_mint_quantity": 1000
      },
      "Roles": {
        "burner_role_name": "burner",
        "minter_role_name": "minter"
      },
      "TokenDesc": "",
      "TokenId": "tokenOne",
      "TokenName": "moneytok",
      "TokenStandard": "erc1155+",
      "TokenType": "fungible",
      "TokenUnit": "fractional",
      "Token_to_currency_ratio": 0
    }
  },
  {
    "key": "tokenTwo",
    "valueJson": {
      "AssetType": "otoken",
      "Behaviors": [
        "divisible",
        "mintable",
        "transferable",
        "roles"
      ],
      "Currency_name": "",
      "Divisible": {
        "Decimal": 2
      },
      "Mintable": {
        "Max_mint_quantity": 1000
      },
      "Roles": {
        "burner_role_name": "burner",
        "minter_role_name": "minter"
      },
      "TokenDesc": "",
      "TokenId": "tokenTwo",
      "TokenName": "moneytok",
      "TokenStandard": "erc1155+",
      "TokenType": "fungible",
      "TokenUnit": "fractional",
      "Token_to_currency_ratio": 0
    }
  },
  {
    "key": "art",
    "valueJson": {
      "AssetType": "otoken",
      "Behaviors": [
        "indivisible",
        "singleton",
        "mintable",
        "transferable",
        "burnable",
        "roles"
      ],
      "BurnedBy": "oaccount~76cb672eeb1bd535899562a840d0c15a356db89e24bc8b43ac1dba845a4282c6",
      "BurnedDate": "2022-12-08T10:49:37Z",
      "CreatedBy": "oaccount~76cb672eeb1bd535899562a840d0c15a356db89e24bc8b43ac1dba845a4282c6",
      "CreationDate": "2022-12-08T10:45:10Z",
      "IsBurned": true,
      "Mintable": {
        "Max_mint_quantity": 20000
      },
      "OnSaleFlag": false,
      "Owner": "",
      "Price": 0,
      "Roles": {
        "minter_role_name": "minter"
      },
      "TokenDesc": "",
      "TokenId": "art",
      "TokenMetadata": {
        "Description": "",
        "Image": "",
        "PainterName": "",
        "PaintingName": ""
      },
      "TokenName": "artcollection",
      "TokenStandard": "erc1155+",
      "TokenType": "nonfungible",
      "TokenUnit": "whole",
      "TokenUri": "art.example.com",
      "TransferredBy": "ouaccount~24ffd4d32a028a85b4b960f5d55536c837b5429bc7f346150adfa904ec2937cc",
      "TransferredDate": "2022-12-08T10:47:04Z"
    }
  },
  {
    "key": "FNFT",
    "valueJson": {
        "AssetType": "otoken",
        "Behaviors": [
            "divisible",
            "mintable",
            "transferable",
            "burnable",
            "roles"
        ],
        "CreatedBy": "oaccount~87bcb699d507368ee3966cd03ee6d7736ffc55dde8c0f0e16b14866334ac504a",
        "CreationDate": "2023-06-20T01:02:27Z",
        "Divisible": {
            "Decimal": 2
        },
        "IsBurned": false,
        "Mintable": {
            "Max_mint_quantity": 20000
        },
        "On_sale_flag": true,
        "Price": 2000,
        "Quantity": 20,
        "Roles": {
            "burner_role_name": "burner",
            "minter_role_name": "minter"
        },
        "TokenDesc": "",
        "TokenId": "FNFT",
        "TokenMetadata": {
            "Description": "",
            "Image": "",
            "Painter_name": "",
            "Painting_name": ""
        },
        "TokenName": "realestate",
        "TokenStandard": "erc1155+",
        "TokenType": "nonfungible",
        "TokenUnit": "fractional",
        "TokenUri": "www.FNFT.example.com"
    }
  },
  {
    "key": "FNFT",
    "valueJson": {
        "AssetType": "otoken",
        "Behaviors": [
            "divisible",
            "mintable",
            "transferable",
            "burnable",
            "roles"
        ],
        "CreatedBy": "oaccount~87bcb699d507368ee3966cd03ee6d7736ffc55dde8c0f0e16b14866334ac504a",
        "CreationDate": "2023-06-20T01:02:27Z",
        "Divisible": {
            "Decimal": 2
        },
        "IsBurned": false,
        "Mintable": {
            "Max_mint_quantity": 20000
        },
        "On_sale_flag": true,
        "Price": 2000,
        "Quantity": 20,
        "Roles": {
            "burner_role_name": "burner",
            "minter_role_name": "minter"
        },
        "TokenDesc": "",
        "TokenId": "FNFT",
        "TokenMetadata": {
            "Description": "",
            "Image": "",
            "Painter_name": "",
            "Painting_name": ""
        },
        "TokenName": "realestate",
        "TokenStandard": "erc1155+",
        "TokenType": "nonfungible",
        "TokenUnit": "fractional",
        "TokenUri": "www.FNFT.example.com"
    }
  }
]
GetTokenById
Questo metodo restituisce un oggetto token se il token è presente nel database di stato. Per i NFT frazionari, viene restituito anche l'elenco dei proprietari. Questo metodo può essere chiamato solo da un Token Admin del codice concatenato o dal proprietario del token.
func (t *Controller) GetTokenById(tokenId string) (interface{}, error) {
            auth, err := t.Ctx.ERC1155Auth.CheckAuthorization("ERC1155Token.Get", "TOKEN", map[string]string{"tokenId": tokenId})
            if err != nil && !auth {
                  return nil, fmt.Errorf("error in authorizing the caller %s", err.Error())
            }
            return t.Ctx.ERC1155Token.GetTokenById(tokenId)
      }
Parametri:
  • tokenId string: l'ID del token da ottenere.
Esempio di valore restituito (NFT intero):
{
  "AssetType": "otoken",
  "Behaviors": [
    "indivisible",
    "singleton",
    "mintable",
    "transferable",
    "burnable",
    "roles"
  ],
  "CreatedBy": "oaccount~76cb672eeb1bd535899562a840d0c15a356db89e24bc8b43ac1dba845a4282c6",
  "CreationDate": "2022-12-08T10:55:29Z",
  "IsBurned": false,
  "Mintable": {
    "Max_mint_quantity": 20000
  },
  "OnSaleFlag": false,
  "Owner": "oaccount~76cb672eeb1bd535899562a840d0c15a356db89e24bc8b43ac1dba845a4282c6",
  "Price": 0,
  "Quantity": 1,
  "Roles": {
    "minter_role_name": "minter"
  },
  "TokenDesc": "",
  "TokenId": "nftToken",
  "TokenMetadata": {
    "Description": "",
    "Image": "",
    "PainterName": "",
    "PaintingName": ""
  },
  "TokenName": "artcollection",
  "TokenStandard": "erc1155+",
  "TokenType": "nonfungible",
  "TokenUnit": "whole",
  "TokenUri": "nftToken.example.com"
}
Esempio di valore restituito (token fungibile):
{
    "AssetType": "otoken",
    "Behaviors": [
        "divisible",
        "mintable",
        "transferable",
        "burnable",
        "roles"
    ],
    "Currency_name": "Dollar",
    "Divisible": {
        "Decimal": 2
    },
    "Mintable": {
        "Max_mint_quantity": 10000
    },
    "Roles": {
        "burner_role_name": "burner",
        "minter_role_name": "minter"
    },
    "TokenDesc": "Token Description",
    "TokenId": "Loyalty",
    "TokenName": "loyalty",
    "TokenStandard": "erc1155+",
    "TokenType": "fungible",
    "TokenUnit": "fractional",
    "Token_to_currency_ratio": 0
}
Esempio di valore restituito (NFT frazionale):
{
    "AssetType": "otoken",
    "Behaviors": [
        "divisible",
        "mintable",
        "transferable",
        "burnable",
        "roles"
    ],
    "CreatedBy": "oaccount~42e89f4c72dfde9502814876423c6da630d466e87436dd1aae201d347ad1288d",
    "CreationDate": "2023-06-14T09:53:53+05:30",
    "Divisible": {
        "Decimal": 2
    },
    "IsBurned": false,
    "Mintable": {
        "Max_mint_quantity": 20000
    },
    "On_sale_flag": false,
    "Owners": [
        {
            "AccountId": "oaccount~42e89f4c72dfde9502814876423c6da630d466e87436dd1aae201d347ad1288d",
            "TokenShare": 100
        }
    ],
    "Price": 1000,
    "Quantity": 100,
    "Roles": {
        "burner_role_name": "burner",
        "minter_role_name": "minter"
    },
    "TokenDesc": "Token Description",
    "TokenId": "realEstate",
    "TokenMetadata": {
        "Description": "Painting Description",
        "Image": "",
        "Painter_name": "",
        "Painting_name": "Paint"
    },
    "TokenName": "realestate",
    "TokenStandard": "erc1155+",
    "TokenType": "nonfungible",
    "TokenUnit": "fractional",
    "TokenUri": "www.realestate.example.com"
}
GetAllTokensByUser
Questo metodo restituisce tutti gli asset token di proprietà di un utente specificato. Questo metodo utilizza query avanzate SQL DB Berkeley e può essere richiamato solo quando si è connessi alla rete remota di Oracle Blockchain Platform. Questo metodo può essere chiamato solo da un Token Admin del codice concatenato o dal proprietario dell'account.
func (t *Controller) GetAllTokensByUser(orgId string, userId string) (interface{}, error) {
            accountId, err := t.Ctx.ERC1155Account.GenerateAccountId(orgId, userId, constants.UserAccount)
            if err != nil {
                  return nil, fmt.Errorf("error in GetAllTokensByUser. Error: %s", err)
            }
            auth, err := t.Ctx.ERC1155Auth.CheckAuthorization("ERC1155Token.GetAllTokensByUser", "TOKEN", map[string]string{"accountId": accountId})
            if err != nil && !auth {
                  return nil, fmt.Errorf("error in authorizing the caller %s", err.Error())
            }
            return t.Ctx.ERC1155Token.GetAllTokensByUser(accountId)
      }
Parametri:
  • orgId string - L'ID MSP (Membership Service Provider) dell'utente nell'organizzazione corrente.
  • userId string: il nome utente o l'ID e-mail dell'utente.
Valore restituito
[
  {
    "key": "tokenOne",
    "valueJson": {
      "AssetType": "otoken",
      "Behaviors": [
        "divisible",
        "mintable",
        "transferable",
        "roles"
      ],
      "Currency_name": "",
      "Divisible": {
        "Decimal": 2
      },
      "Mintable": {
        "Max_mint_quantity": 1000
      },
      "Roles": {
        "burner_role_name": "burner",
        "minter_role_name": "minter"
      },
      "TokenDesc": "",
      "TokenId": "tokenOne",
      "TokenName": "moneytok",
      "TokenStandard": "erc1155+",
      "TokenType": "fungible",
      "TokenUnit": "fractional",
      "Token_to_currency_ratio": 0
    }
  },
  {
    "key": "nftToken",
    "valueJson": {
      "AssetType": "otoken",
      "Behaviors": [
        "indivisible",
        "singleton",
        "mintable",
        "transferable",
        "burnable",
        "roles"
      ],
      "CreatedBy": "oaccount~76cb672eeb1bd535899562a840d0c15a356db89e24bc8b43ac1dba845a4282c6",
      "CreationDate": "2022-12-08T10:55:29Z",
      "IsBurned": false,
      "Mintable": {
        "Max_mint_quantity": 20000
      },
      "OnSaleFlag": false,
      "Owner": "oaccount~76cb672eeb1bd535899562a840d0c15a356db89e24bc8b43ac1dba845a4282c6",
      "Price": 0,
      "Quantity": 1,
      "Roles": {
        "minter_role_name": "minter"
      },
      "TokenDesc": "",
      "TokenId": "nftToken",
      "TokenMetadata": {
        "Description": "",
        "Image": "",
        "PainterName": "",
        "PaintingName": ""
      },
      "TokenName": "artcollection",
      "TokenStandard": "erc1155+",
      "TokenType": "nonfungible",
      "TokenUnit": "whole",
      "TokenUri": "example.com"
    }
  }
]
OwnerOf
Questo metodo restituisce l'ID account, l'ID organizzazione e l'ID utente del proprietario dell'ID token specificato. Chiunque può chiamare questo metodo.
func (t *Controller) OwnerOf(tokenId string) (interface{}, error) {
            return t.Ctx.ERC1155Token.OwnerOf(tokenId)
      }
Parametri:
  • tokenId string: l'ID del token.
Esempio di valore restituito (NFT intero):
{
  "AccountId": "oaccount~76cb672eeb1bd535899562a840d0c15a356db89e24bc8b43ac1dba845a4282c6",
  "OrgId": "appdev",
  "UserId": "idcqa"
}
Esempio di valore restituito (NFT frazionale):
[
    {
        "AccountId": "oaccount~42e89f4c72dfde9502814876423c6da630d466e87436dd1aae201d347ad1288d",
        "OrgId": "Org1MSP",
        "UserId": "admin"
    },
    {
        "AccountId": "oaccount~74108eca702bab6d8548e740254f2cc7955d886885251d52d065042172a59db0",
        "OrgId": "Org1MSP",
        "UserId": "user"
    }
]
URI
Questo metodo restituisce l'URI di un token specificato. Chiunque può chiamare questo metodo.
func (t *Controller) URI(tokenId string) (interface{}, error) {
            return t.Ctx.ERC1155Token.TokenURI(tokenId)
      }
Parametri:
  • tokenId string: l'ID del token.
Valore restituito
{
    "TokenUri": "example.com"
}
Name
Questo metodo restituisce il nome della classe token. Chiunque può chiamare questo metodo.
func (t *Controller) Name(tokenId string) (interface{}, error) {
            return t.Ctx.ERC1155Token.Name(tokenId)
      }
Parametri:
  • tokenId string: l'ID del token.
Valore restituito
{"TokenName": "artcollection"}
TotalSupply
Questo metodo restituisce il numero totale di token coniati. I token fungibili vengono specificati dall'ID token. I token non fungibili sono specificati dal nome token. Questo metodo può essere chiamato solo da un Token Admin del codice concatenato.
func (t *Controller) TotalSupply(tokenDetail erc1155Role.TokenDetail) (interface{}, error) {
            auth, err := t.Ctx.ERC1155Auth.CheckAuthorization("ERC1155Token.TotalSupply", "TOKEN")
            if err != nil && !auth {
                  return nil, fmt.Errorf("error in authorizing the caller %s", err.Error())
            }
            token, err := t.Ctx.ERC1155Token.GetTokenByIdOrName(tokenDetail)
            if err != nil {
                  return nil, err
            }
            return t.Ctx.ERC1155Token.TotalSupply(token)
      }
Parametri:
  • tokenDetails erc1155Role.TokenDetail: i dettagli che specificano il token. Per i token fungibili, utilizzare il seguente formato:
    {"TokenId":"token1"}
    Per i token non fungibili, utilizzare il seguente formato:
    {"TokenName":"artCollection"}
Valore restituito
{
    "TotalSupply": 100
}
TotalNetSupply
Questo metodo restituisce il numero totale di token coniati meno il numero di token bruciati. I token fungibili vengono specificati dall'ID token. I token non fungibili sono specificati dal nome token. Questo metodo può essere chiamato solo da un Token Admin del codice concatenato.
func (t *Controller) TotalNetSupply(tokenDetail erc1155Role.TokenDetail) (interface{}, error) {
            auth, err := t.Ctx.ERC1155Auth.CheckAuthorization("ERC1155Token.TotalNetSupply", "TOKEN")
            if err != nil && !auth {
                  return nil, fmt.Errorf("error in authorizing the caller %s", err.Error())
            }
            token, err := t.Ctx.ERC1155Token.GetTokenByIdOrName(tokenDetail)
            if err != nil {
                  return nil, err
            }
            return t.Ctx.ERC1155Token.TotalNetSupply(token)
      }
Parametri:
  • tokenDetails erc1155Role.TokenDetail: i dettagli che specificano il token. Per i token fungibili, utilizzare il seguente formato:
    {"TokenId":"token1"}
    Per i token non fungibili, utilizzare il seguente formato:
    {"TokenName":"artCollection"}
Valore restituito
{
   "TotalNetSupply": 900
}
GetTokensByName
Questo metodo restituisce tutti gli asset token per un nome token specificato. Questo metodo utilizza query avanzate SQL DB Berkeley e può essere richiamato solo quando si è connessi alla rete remota di Oracle Blockchain Platform. Questo metodo può essere chiamato solo da un Token Admin del codice concatenato.
func (t *Controller) GetTokensByName(tokenName string) (interface{}, error) {
            auth, err := t.Ctx.ERC1155Auth.CheckAuthorization("ERC1155Token.GetTokensByName", "TOKEN")
            if err != nil && !auth {
                  return nil, fmt.Errorf("error in authorizing the caller %s", err.Error())
            }
            return t.Ctx.ERC1155Token.GetTokensByName(tokenName)
      }
Parametri:
  • tokenName: string: il nome del token.
Valore restituito
[
  {
    "key": "tokenOne",
    "valueJson": {
      "AssetType": "otoken",
      "Behaviors": [
        "divisible",
        "mintable",
        "transferable",
        "roles"
      ],
      "Currency_name": "",
      "Divisible": {
        "Decimal": 2
      },
      "Mintable": {
        "Max_mint_quantity": 1000
      },
      "Roles": {
        "burner_role_name": "burner",
        "minter_role_name": "minter"
      },
      "TokenDesc": "",
      "TokenId": "tokenOne",
      "TokenName": "moneytok",
      "TokenStandard": "erc1155+",
      "TokenType": "fungible",
      "TokenUnit": "fractional",
      "Token_to_currency_ratio": 0
    }
  },
  {
    "key": "tokenTwo",
    "valueJson": {
      "AssetType": "otoken",
      "Behaviors": [
        "divisible",
        "mintable",
        "transferable",
        "roles"
      ],
      "Currency_name": "",
      "Divisible": {
        "Decimal": 2
      },
      "Mintable": {
        "Max_mint_quantity": 1000
      },
      "Roles": {
        "burner_role_name": "burner",
        "minter_role_name": "minter"
      },
      "TokenDesc": "",
      "TokenId": "tokenTwo",
      "TokenName": "moneytok",
      "TokenStandard": "erc1155+",
      "TokenType": "fungible",
      "TokenUnit": "fractional",
      "Token_to_currency_ratio": 0
    }
  }
]
GetTokenDecimal
Questo metodo restituisce il numero di posizioni decimali per un token specificato. Questo metodo può essere chiamato solo da un Token Admin del codice concatenato.
func (t *Controller) GetTokenDecimal(tokenId string) (interface{}, error) {
            auth, err := t.Ctx.ERC1155Auth.CheckAuthorization("ERC1155Token.GetTokenDecimal", "TOKEN")
            if err != nil && !auth {
                  return nil, fmt.Errorf("error in authorizing the caller %s", err.Error())
            }
            tokenDecimal, err := t.Ctx.ERC1155Token.GetDecimals(tokenId)
            if err != nil {
                  return nil, fmt.Errorf("error in GetTokenDecimal: %s", err.Error())
            }
            response := make(map[string]interface{})
            response["msg"] = fmt.Sprintf("Token Id: %s has %d decimal places.", tokenId, tokenDecimal)
            return response, nil
      }
Parametri:
  • tokenId string: l'ID del token.
Valore restituito
{
    "msg": "Token Id: tokenOne has 2 decimal places."
}

Metodi per la gestione degli account

CreateAccount
Questo metodo crea un account per un utente specificato e account token associati per token fungibili o non fungibili. È necessario creare un account per qualsiasi utente che avrà token in qualsiasi momento. L'account utente tiene traccia dell'account NFT e degli account token fungibili di cui dispone un utente. Gli utenti devono disporre di account nella rete per completare le operazioni correlate al token. Questo metodo può essere chiamato solo da un Token Admin del codice concatenato.

Un account utente ha un ID univoco, formato da un hash SHA-256 del parametro orgId e del parametro userId.

Un utente può avere più account token fungibili con ID account univoci. Gli ID account token fungibili sono formati da un hash SHA-256 del parametro orgId, il parametro userId, la stringa costante ft separata dal simbolo tilde (~) e un numero contatore che indica l'indice del conto fungibile che viene creato separato dal simbolo tilde (~).

Un utente può avere un solo account token non fungibile. Gli ID account token non fungibili sono univoci e sono formati da un hash SHA-256 del parametro orgId, del parametro userId e della stringa costante nft separati dal simbolo tilde (~). Tutti i token non fungibili di proprietà di un utente, siano essi interi o frazionari, sono collegati a questo account.

Gli ID account utente iniziano con ouaccount~. Gli ID account token iniziano con oaccount~.

func (t *Controller) CreateAccount(orgId string, userId string, ftAccount bool, nftAccount bool) (interface{}, error) {
            auth, err := t.Ctx.ERC1155Auth.CheckAuthorization("ERC1155Account.CreateAccount", "TOKEN")
            if err != nil && !auth {
                  return nil, fmt.Errorf("error in authorizing the caller %s", err.Error())
            }
            return t.Ctx.ERC1155Account.CreateAccount(orgId, userId, ftAccount, nftAccount)
      }
Parametri:
  • orgId string - L'ID MSP (Membership Service Provider) dell'utente nell'organizzazione corrente.
  • userId string: il nome utente o l'ID e-mail dell'utente.
  • ftAccount bool: se true, viene creato un account token fungibile associato all'account utente.
  • nftAccount bool – Se true, viene creato un account token non fungibile e associato all'account utente.
Restituisce:
  • In caso di operazione riuscita, un oggetto JSON dell'account creato.
Valore restituito
{
  "AssetType": "ouaccount",
  "AccountId": "ouaccount~cf20877546f52687f387e7c91d88b9722c97e1a456cc0484f40c747f7804feae",
  "UserId": "user1",
  "OrgId": "appdev",
  "TotalAccounts": 2,
  "TotalFtAccounts": 1,
  "AssociatedFtAccounts": [
    {
      "AccountId": "oaccount~60bb20c14a83f6e426e1437c479c5891e1c6477dfd7ad18b73acac5d80bc504b",
      "TokenId": ""
    }
  ],
  "AssociatedNftAccount": "oaccount~73c3e835dac6d0a56ca9d8def08269f83cefd59b9d297fe2cdc5a9083828fa58"
}
CreateUserAccount
Questo metodo crea un account per un utente specificato. È necessario creare un account per qualsiasi utente che avrà token in qualsiasi momento. L'account utente tiene traccia dell'account NFT e degli account token fungibili di cui dispone un utente. Gli utenti devono disporre di account nella rete per completare le operazioni correlate al token.

Un ID account è un hash SHA-256 del parametro orgId e del parametro userId. Questo metodo può essere chiamato solo da un Token Admin del codice concatenato.

func (t *Controller) CreateUserAccount(orgId string, userId string) (interface{}, error) {
            auth, err := t.Ctx.ERC1155Auth.CheckAuthorization("ERC1155Account.CreateUserAccount", "TOKEN")
            if err != nil && !auth {
                  return nil, fmt.Errorf("error in authorizing the caller %s", err.Error())
            }
            return t.Ctx.ERC1155Account.CreateUserAccount(orgId, userId)
      }
Parametri:
  • orgId string - L'ID MSP (Membership Service Provider) dell'utente nell'organizzazione corrente.
  • userId string: il nome utente o l'ID e-mail dell'utente.
Restituisce:
  • In caso di operazione riuscita, un oggetto JSON dell'account utente creato.
Valore restituito
{
  "AssetType": "ouaccount",
  "AccountId": "ouaccount~24ffd4d32a028a85b4b960f5d55536c837b5429bc7f346150adfa904ec2937cc",
  "UserId": "idcqa",
  "OrgId": "appdev",
  "TotalAccounts": 0,
  "TotalFtAccounts": 0,
  "AssociatedFtAccounts": [],
  "AssociatedNftAccount": ""
}
CreateTokenAccount
Questo metodo crea un account token fungibile o non fungibile da associare a un account utente.

Un utente può avere più account token fungibili con ID account univoci. Gli ID account token fungibili sono formati da un hash SHA-256 del parametro orgId, il parametro userId, la stringa costante ft separata dal simbolo tilde (~) e un numero contatore che indica l'indice del conto fungibile che viene creato separato dal simbolo tilde (~).

Un utente può avere un solo account token non fungibile. Gli ID account token non fungibili sono univoci e sono formati da un hash SHA-256 del parametro orgId, del parametro userId e della stringa costante nft separati dal simbolo tilde (~). Tutti i token non fungibili di proprietà di un utente, siano essi interi o frazionari, sono collegati a questo account.

Questo metodo può essere chiamato solo da un Token Admin del codice concatenato.

func (t *Controller) CreateTokenAccount(orgId string, userId string, tokenType erc1155Token.TokenType) (interface{}, error) {
            auth, err := t.Ctx.ERC1155Auth.CheckAuthorization("ERC1155Account.CreateTokenAccount", "TOKEN")
            if err != nil && !auth {
                  return nil, fmt.Errorf("error in authorizing the caller %s", err.Error())
            }
            typeOfToken, err := tokenType.GetTokenType()
          if err != nil {
                  return nil, err
            }
            return t.Ctx.ERC1155Account.CreateTokenAccount(orgId, userId, typeOfToken)
      }
Parametri:
  • orgId string - L'ID MSP (Membership Service Provider) dell'utente nell'organizzazione corrente.
  • userId string: il nome utente o l'ID e-mail dell'utente.
  • tokenType erc1155Token.TokenType: il tipo di account token da creare. Gli unici tipi di token supportati sono nonfungible e fungible.
Restituisce:
  • In caso di operazione riuscita, un oggetto JSON dell'account token creato.
Valore restituito
{
    "AssetType": "ouaccount",
    "AccountId": "ouaccount~24ffd4d32a028a85b4b960f5d55536c837b5429bc7f346150adfa904ec2937cc",
    "UserId": "idcqa",
    "OrgId": "appdev",
    "TotalAccounts": 1,
    "TotalFtAccounts": 1,
    "AssociatedFtAccounts": [
        {
            "AccountId": "oaccount~1422a74d262a3a55a37cd9023ef8836f765d0be7b49d397696b9961d7434d22a",
            "TokenId": ""
        }
    ],
    "AssociatedNftAccount": ""
}
AssociateFungibleTokenAccount
Questo metodo associa l'account token fungibile di un utente a un token fungibile particolare.

Questo metodo può essere chiamato solo dal Token Admin del codice concatenato.

func (t *Controller) AssociateFungibleTokenToAccount(orgId string, userId string, tokenId string) (interface{}, error) {
            accountId, err := t.Ctx.ERC1155Account.GenerateAccountId(orgId, userId, constants.UserAccount)
            if err != nil {
                  return nil, fmt.Errorf("error in generating accountId. Error: %s", err)
            }
            auth, err := t.Ctx.ERC1155Auth.CheckAuthorization("ERC1155Account.AssociateFungibleTokenToAccount", "TOKEN", map[string]string{"accountId": accountId})
            if err != nil && !auth {
                  return nil, fmt.Errorf("error in authorizing the caller %s", err.Error())
            }
            return t.Ctx.ERC1155Account.AssociateTokenToToken(accountId, tokenId)
      }
Parametri:
  • orgId string - L'ID MSP (Membership Service Provider) dell'utente nell'organizzazione corrente.
  • userId string: il nome utente o l'ID e-mail dell'utente.
  • tokenId string: l'ID del token.
Restituisce:
  • In caso di operazione riuscita, un oggetto JSON dell'account utente, che mostra che il token fungibile è stato associato all'account token. Ad esempio, nell'esempio seguente, il primo oggetto nell'array associatedFtAccounts mostra che l'ID account token fungibile e l'ID token sono associati.
Valore restituito
{
    "AssetType": "ouaccount",
    "AccountId": "ouaccount~24ffd4d32a028a85b4b960f5d55536c837b5429bc7f346150adfa904ec2937cc",
    "UserId": "idcqa",
    "OrgId": "appdev",
    "TotalAccounts": 1,
    "TotalFtAccounts": 1,
    "AssociatedFtAccounts": [
        {
            "AccountId": "oaccount~1422a74d262a3a55a37cd9023ef8836f765d0be7b49d397696b9961d7434d22a",
            "TokenId": "tokenOne"
        }
    ],
    "AssociatedNftAccount": ""
}
GetAccountHistory
Questo metodo restituisce la cronologia per un account token specificato. Questo è un metodo asincrono. Questo metodo può essere chiamato solo dal Token Admin del codice concatenato o dal proprietario dell'account.
func (t *Controller) GetAccountHistory(orgId string, userId string, tokenId ...string) (interface{}, error) {
            userAccountId, err := t.Ctx.ERC1155Account.GenerateAccountId(orgId, userId, constants.UserAccount)
            if err != nil {
                  return nil, fmt.Errorf("error in GetAccountHistory. Error: %s", err)
            }
            _, err = t.Ctx.ERC1155Auth.CheckAuthorization("ERC1155Account.History", "TOKEN", map[string]string{"accountId": userAccountId})
            if err != nil {
                  return nil, fmt.Errorf("error in GetAccountHistory. Error: %s", err)
            }
            tokenAccount, err := t.Ctx.ERC1155Account.Get(userAccountId, tokenId...)
            if err != nil {
                  return nil, fmt.Errorf("error in GetAccountHistory. Error: %s", err)
            }
            tokenAccountId, err := util.GetAccountProperty(tokenAccount, constants.AccountId)
            if err != nil {
                  return nil, fmt.Errorf("error in GetAccountHistory. Error: %s", err)
            }
            return t.Ctx.ERC1155Account.GetAccountHistory(tokenAccountId)
      }
Parametri:
  • orgId string - L'ID MSP (Membership Service Provider) dell'utente nell'organizzazione corrente.
  • userId string: il nome utente o l'ID e-mail dell'utente.
  • tokenId ...string – Per un account token non fungibile, una stringa vuota. Per un account token fungibile, l'ID token.
Restituisce:
  • In caso di operazione riuscita, un array di oggetti JSON che descrive la cronologia dell'account.
Valore restituito
[
    {
        "IsDelete": "false",
        "Timestamp": "2023-06-06T11:03:48Z",
        "TxId": "c5180f3be3d9130f25a4b4e866f38a4283117dcbfbffb4f55e2c5b03dba0dd29",
        "Value": {
            "AccountCategory": "",
            "AccountId": "oaccount~21206f309941a2a23c4f158a0fe1b8f12bb8e2b0c9a2e1358f5efebc0c7d410e",
            "AssetType": "oaccount",
            "Balance": 100,
            "BapAccountVersion": 1
            "OrgId": "appdev",
            "TokenId": "loy1",
            "TokenName": "loyalty",
            "TokenType": "fungible",
            "UserId": "idcqa"
        }
    },
    {
        "IsDelete": "false",
        "Timestamp": "2023-06-06T11:02:39Z",
        "TxId": "6f81b0c94b451d375a3892446aefbdf78d9fd1ac43699daa89f0dff10db5fd22",
        "Value": {
            "AccountCategory": "",
            "AccountId": "oaccount~21206f309941a2a23c4f158a0fe1b8f12bb8e2b0c9a2e1358f5efebc0c7d410e",
            "AssetType": "oaccount",
            "Balance": 0,
            "BapAccountVersion": 0
            "OrgId": "appdev",
            "TokenId": "loy1",
            "TokenName": "loyalty",
            "TokenType": "fungible",
            "UserId": "idcqa"
        }
    },
    {
        "IsDelete": "false",
        "Timestamp": "2023-06-05T16:28:46Z",
        "TxId": "8185af648546e909488e72149be497b210f74f95ada252c42da9c35cb9d98691",
        "Value": {
            "AccountCategory": "",
            "AccountId": "oaccount~21206f309941a2a23c4f158a0fe1b8f12bb8e2b0c9a2e1358f5efebc0c7d410e",
            "AssetType": "oaccount",
            "Balance": 0,
            "BapAccountVersion": 0
            "OrgId": "appdev",
            "TokenId": "",
            "TokenName": "",
            "TokenType": "fungible",
            "UserId": "idcqa"
        }
    }
]
GetAccount
Questo metodo restituisce i dettagli dell'account token per un utente specificato. Questo metodo può essere chiamato solo da un Token Admin del codice concatenato o dal Account Owner dell'account.
func (t *Controller) GetAccount(orgId string, userId string, tokenId ...string) (interface{}, error) {
            accountId, err := t.Ctx.ERC1155Account.GenerateAccountId(orgId, userId, constants.UserAccount)
            if err != nil {
                  return nil, err
            }
            auth, err := t.Ctx.ERC1155Auth.CheckAuthorization("ERC1155Account.GetAccount", "TOKEN", map[string]string{"accountId": accountId})
            if err != nil && !auth {
                  return nil, fmt.Errorf("error in authorizing the caller %s", err.Error())
            }
            return t.Ctx.ERC1155Account.GetAccountWithStatus(accountId, tokenId...)
      }
Parametri:
  • orgId string - L'ID MSP (Membership Service Provider) dell'utente nell'organizzazione corrente.
  • userId string: il nome utente o l'ID e-mail dell'utente.
  • tokenId ...string – Per un account token non fungibile, una stringa vuota. Per un account token fungibile, l'ID token.
Restituisce:
  • In caso di operazione riuscita, un oggetto JSON che include i dettagli dell'account token. I parametri BapAccountVersion e AccountCategory sono definiti nell'oggetto account per uso interno.
Esempio di valore restituito (conto token non fungibile):
{
  "AccountId": "oaccount~cc301bee057f14236a97d434909ec1084970921b008f6baab09c2a0f5f419a9a",
  "AssetType": "oaccount",
  "BapAccountVersion": 1,
  "NoOfNfts": 1,
  "OrgId": "appdev",
  "Status": "active",
  "TokenType": "nonfungible",
  "UserId": "idcqa"
}
Esempio di valore restituito (account token fungibile):
{
  "AccountCategory": "",
  "AccountId": "oaccount~2de8db6b91964f8c9009136831126d3cfa94e1d00c4285c1ea3e6d1f36479ed4",
  "AssetType": "oaccount",
  "Balance": 0,
  "BapAccountVersion": 0,
  "OrgId": "appdev",
  "Status": "active",
  "TokenId": "t1",
  "TokenName": "loyalty",
  "TokenType": "fungible",
  "UserId": "idcqa"
}
GetAllAccounts
Questo metodo restituisce i dettagli di tutti gli account utente. Questo metodo può essere chiamato solo da un Token Admin del codice concatenato.
func (t *Controller) GetAllAccounts() (interface{}, error) {
            auth, err := t.Ctx.ERC1155Auth.CheckAuthorization("ERC1155Account.GetAllAccounts", "TOKEN")
            if err != nil && !auth {
                  return nil, fmt.Errorf("error in authorizing the caller %s", err.Error())
            }
            return t.Ctx.ERC1155Account.GetAllAccounts()
      }
Parametri:
  • nessuno
Restituisce:
  • Al successo, un array JSON di tutti gli account.
Valore restituito
[
    {
        "AssetType": "ouaccount",
        "AccountId": "ouaccount~412de5e3998dcd100973e1bad6e8729fddc1c7ff610beab8376d733a35c51f38",
        "UserId": "idcqa",
        "OrgId": "appdev",
        "TotalAccounts": 3,
        "TotalFtAccounts": 2,
        "AssociatedFtAccounts": [
            {
                "AccountId": "oaccount~21206f309941a2a23c4f158a0fe1b8f12bb8e2b0c9a2e1358f5efebc0c7d410e",
                "TokenId": "loy1"
            },
            {
                "AccountId": "oaccount~58c5a6b09a41befca2a9ea2550439838c4dcf4d8a2a4f7c98e9319cf8479bfc4",
                "TokenId": ""
            }
        ],
        "AssociatedNftAccount": "oaccount~e88276a3be547e31b567346bdddde52d37734da4d5fae83ab2e5c98a10097371"
    },
    {
        "AssetType": "ouaccount",
        "AccountId": "ouaccount~9501bb774c156eb8354dfe489250ea91f757523d70f08ee494bda98bb352003b",
        "UserId": "user1_minter",
        "OrgId": "appdev",
        "TotalAccounts": 2,
        "TotalFtAccounts": 1,
        "AssociatedFtAccounts": [
            {
                "AccountId": "oaccount~1089ee5122f367ee0ca38c6660298f4b81f199627e4f67f3691c0f628237974c",
                "TokenId": "loy1"
            }
        ],
        "AssociatedNftAccount": "oaccount~dcee860665db8740cb77b846e823752185a1e9a185814d0acb305890f5903446"
    },
]
GetAccountDetailsByUser
Questo metodo restituisce un riepilogo dell'account per un utente specificato e i dettagli dei token fungibili e non fungibili associati all'utente. Questo metodo può essere chiamato solo da un Token Admin del codice concatenato o dal Account Owner dell'account.
func (t *Controller) GetAccountDetailsByUser(orgId string, userId string) (interface{}, error) {
            accountId, err := t.Ctx.ERC1155Account.GenerateAccountId(orgId, userId, constants.UserAccount)
            if err != nil {
                  return nil, err
            }
            auth, err := t.Ctx.ERC1155Auth.CheckAuthorization("ERC1155Account.GetAccountDetailsByUser", "TOKEN", map[string]string{"accountId": accountId})
            if err != nil && !auth {
                  return nil, fmt.Errorf("error in authorizing the caller %s", err.Error())
            }
            return t.Ctx.ERC1155Account.GetAccountDetailsByUser(orgId, userId)
      }
Parametri:
  • orgId string - L'ID MSP (Membership Service Provider) dell'utente nell'organizzazione corrente.
  • userId string: il nome utente o l'ID e-mail dell'utente.
Restituisce:
  • In caso di operazione riuscita, un oggetto account JSON che include e il riepilogo dell'account per l'utente specificato e i dettagli dei token fungibili e non fungibili associati all'utente. Per i token non fungibili frazionari, la proprietà TokenShare nella sezione AssociatedNFTs mostra la condivisione di proprietà dell'utente.
Valore restituito
{
    "AssociatedFTAccounts": [
        {
            "AccountId": "oaccount~21206f309941a2a23c4f158a0fe1b8f12bb8e2b0c9a2e1358f5efebc0c7d410e",
            "Balance": 90,
          "TokenId": "FT"
        },
    ],
    "AssociatedNFTAccount": {
        "AccountId": "oaccount~e88276a3be547e31b567346bdddde52d37734da4d5fae83ab2e5c98a10097371",
        "AssociatedNFTs": [
            {
              "NFTTokenId": "FNFT",
                "TokenShare": 230
            },
            {
              "NFTTokenId": "NFT"
            },
            {
              "NFTTokenId": "NFT2"
            }
        ]
    },
    "UserAccountId": "ouaccount~412de5e3998dcd100973e1bad6e8729fddc1c7ff610beab8376d733a35c51f38"
}
GetUserByAccountId
Questo metodo restituisce i dettagli utente di un ID account specificato. Questo metodo può essere chiamato da qualsiasi utente.
func (t *Controller) GetUserByAccountId(accountId string) (interface{}, error) {
            return t.Ctx.ERC1155Account.GetUserByAccountById(accountId)
      }
Parametri:
  • accountId string – L'ID dell'account.
Restituisce:
  • In caso di operazione riuscita, un oggetto JSON dei dettagli utente (orgId e userId).
Valore restituito
{
    "OrgId": "appdev",
    "UserId": "user2"
}

Metodi per gestione ruoli

AddRole
Questo metodo aggiunge un ruolo a un utente e a un token specificati. Questo metodo può essere chiamato solo da un Token Admin del codice concatenato. I token fungibili vengono specificati dall'ID token. I token non fungibili sono specificati dal nome token. L'utente specificato deve disporre di un account token associato al token fungibile o di un account token non fungibile per i ruoli NFT. Il ruolo specificato deve esistere nel file di specifica per il token.
func (t *Controller) AddRole(orgId string, userId string, role string, tokenDetail erc1155Role.TokenDetail) (interface{}, error) {
            userAccountId, err := t.Ctx.ERC1155Account.GenerateAccountId(orgId, userId, constants.UserAccount)
            if err != nil {
                  return nil, err
            }
            auth, err := t.Ctx.ERC1155Auth.CheckAuthorization("ERC1155Token.AddRoleMember", "TOKEN", map[string]string{"accountId": userAccountId})
            if err != nil && !auth {
                  return nil, fmt.Errorf("error in authorizing the caller %s", err.Error())
            }
            token, err := t.Ctx.ERC1155Token.GetTokenByIdOrName(tokenDetail)
            if err != nil {
                  return nil, err
            }
            return t.Ctx.ERC1155Token.AddRoleMember(role, userAccountId, token)
      }
Parametri:
  • orgId string - L'ID MSP (Membership Service Provider) dell'utente nell'organizzazione corrente.
  • userId string: il nome utente o l'ID e-mail dell'utente.
  • role: string: il nome del ruolo da aggiungere all'utente specificato.
  • tokenDetails erc1155Role.TokenDetail: i dettagli che specificano il token. Per i token fungibili, utilizzare il seguente formato:
    {"TokenId":"token1"}
    Per i token non fungibili, utilizzare il seguente formato:
    {"TokenName":"artCollection"}
Restituisce:
  • In caso di successo, un messaggio con i dettagli dell'account.
Valore restituito
{
    "msg": "Successfully added role minter to oaccount~1422a74d262a3a55a37cd9023ef8836f765d0be7b49d397696b9961d7434d22a (orgId : appdev, userId : idcqa)"
}
IsInRole
Questo metodo restituisce un valore booleano per indicare se un utente dispone di un ruolo specificato. I token fungibili vengono specificati dall'ID token. I token non fungibili sono specificati dal nome token. Questo metodo può essere chiamato solo dal Token Admin del codice concatenato o dal Account Owner dell'account. L'utente specificato deve disporre di un account token associato al token fungibile o di un account token non fungibile per i ruoli NFT. Il ruolo specificato deve esistere nel file di specifica per il token.
func (t *Controller) IsInRole(orgId string, userId string, role string, tokenDetail erc1155Role.TokenDetail) (interface{}, error) {
            userAccountId, err := t.Ctx.ERC1155Account.GenerateAccountId(orgId, userId, constants.UserAccount)
            if err != nil {
                  return nil, err
            }
            auth, err := t.Ctx.ERC1155Auth.CheckAuthorization("ERC1155Token.IsInRole", "TOKEN")
            if err != nil && !auth {
                  return nil, fmt.Errorf("error in authorizing the caller %s", err.Error())
            }
            token, err := t.Ctx.ERC1155Token.GetTokenByIdOrName(tokenDetail)
            if err != nil {
                  return nil, err
            }
            var result bool
            result, err = t.Ctx.ERC1155Token.IsInRole(role, userAccountId, token)
            if err != nil {
                  return nil, fmt.Errorf("error in IsInRole %s", err.Error())
            }
            response := make(map[string]interface{})
            response["result"] = result
            return response, nil
      }
Parametri:
  • orgId string - L'ID MSP (Membership Service Provider) dell'utente nell'organizzazione corrente.
  • userId string: il nome utente o l'ID e-mail dell'utente.
  • role: string: il nome del ruolo da cercare.
  • tokenDetails erc1155Role.TokenDetail: i dettagli che specificano il token. Per i token fungibili, utilizzare il seguente formato:
    {"TokenId":"token1"}
    Per i token non fungibili, utilizzare il seguente formato:
    {"TokenName":"artCollection"}
Valore restituito
{
    "result": true
}
RemoveRole
Questo metodo rimuove un ruolo da un utente e da un token specificati. I token fungibili vengono specificati dall'ID token. I token non fungibili sono specificati dal nome token. Questo metodo può essere chiamato solo dal Token Admin del codice concatenato. L'utente specificato deve disporre di un account token associato al token fungibile o di un account token non fungibile per i ruoli NFT. Il ruolo specificato deve esistere nel file di specifica per il token.
func (t *Controller) RemoveRole(orgId string, userId string, role string, tokenDetail erc1155Role.TokenDetail) (interface{}, error) {
            userAccountId, err := t.Ctx.ERC1155Account.GenerateAccountId(orgId, userId, constants.UserAccount)
            if err != nil {
                  return nil, err
            }
            auth, err := t.Ctx.ERC1155Auth.CheckAuthorization("ERC1155Token.RemoveRoleMember", "TOKEN")
            if err != nil && !auth {
                  return nil, fmt.Errorf("error in authorizing the caller %s", err.Error())
            }
            token, err := t.Ctx.ERC1155Token.GetTokenByIdOrName(tokenDetail)
            if err != nil {
                  return nil, err
            }
            return t.Ctx.ERC1155Token.RemoveRoleMember(role, userAccountId, token)
      }
Parametri:
  • orgId string - L'ID MSP (Membership Service Provider) dell'utente nell'organizzazione corrente.
  • userId string: il nome utente o l'ID e-mail dell'utente.
  • role: string: il nome del ruolo da rimuovere dall'utente specificato.
  • tokenDetails erc1155Role.TokenDetail: i dettagli che specificano il token. Per i token fungibili, utilizzare il seguente formato:
    {"TokenId":"token1"}
    Per i token non fungibili, utilizzare il seguente formato:
    {"TokenName":"artCollection"}
Valore restituito
{
    "msg": "Successfully removed role 'minter' from Account Id: oaccount~ec7e4de2f81e3ea071710e07b6ff7d9346e84ef665ca4650885dbe8c3e2bd4c0 (Org-Id: appdev, User-Id: idcqa)"
}
GetAccountsByRole
Questo metodo restituisce un elenco di tutti gli ID account per un ruolo e un token specificati. I token fungibili vengono specificati dall'ID token. I token non fungibili sono specificati dal nome token. Questo metodo può essere chiamato solo dal Token Admin del codice concatenato.
func (t *Controller) GetAccountsByRole(role string, tokenDetail erc1155Role.TokenDetail) (interface{}, error) {
            auth, err := t.Ctx.ERC1155Auth.CheckAuthorization("ERC1155Role.GetAccountsByRole", "TOKEN")
            if err != nil && !auth {
                  return nil, fmt.Errorf("error in authorizing the caller %s", err.Error())
            }
            token, err := t.Ctx.ERC1155Token.GetTokenByIdOrName(tokenDetail)
            if err != nil {
                  return nil, err
            }
            return t.Ctx.ERC1155Role.GetAccountsByRole(role, token)
      }
Parametri:
  • role: string: il nome del ruolo da cercare.
  • tokenDetails erc1155Role.TokenDetail: i dettagli che specificano il token. Per i token fungibili, utilizzare il seguente formato:
    {"TokenId":"token1"}
    Per i token non fungibili, utilizzare il seguente formato:
    {"TokenName":"artCollection"}
Valore restituito
{
    "accounts": [
        "oaccount~1422a74d262a3a55a37cd9023ef8836f765d0be7b49d397696b9961d7434d22a",
        "oaccount~60bb20c14a83f6e426e1437c479c5891e1c6477dfd7ad18b73acac5d80bc504b"
    ]
}
GetUsersByRole
Questo metodo restituisce un elenco di tutti gli utenti per un ruolo e un token specificati. I token fungibili vengono specificati dall'ID token. I token non fungibili sono specificati dal nome token. Questo metodo può essere chiamato solo dal Token Admin del codice concatenato.
func (t *Controller) GetUsersByRole(role string, tokenDetail erc1155Role.TokenDetail) (interface{}, error) {
            auth, err := t.Ctx.ERC1155Auth.CheckAuthorization("ERC1155Role.GetUsersByRole", "TOKEN")
            if err != nil && !auth {
                  return nil, fmt.Errorf("error in authorizing the caller %s", err.Error())
            }
            token, err := t.Ctx.ERC1155Token.GetTokenByIdOrName(tokenDetail)
            if err != nil {
                  return nil, err
            }
            return t.Ctx.ERC1155Role.GetUsersByRole(role, token)
      }
Parametri:
  • role: string: il nome del ruolo da cercare.
  • tokenDetails erc1155Role.TokenDetail: i dettagli che specificano il token. Per i token fungibili, utilizzare il seguente formato:
    {"TokenId":"token1"}
    Per i token non fungibili, utilizzare il seguente formato:
    {"TokenName":"artCollection"}
Valore restituito
{
    "Users": [
        {
            "AccountId": "oaccount~1422a74d262a3a55a37cd9023ef8836f765d0be7b49d397696b9961d7434d22a",
            "OrgId": "appdev",
            "UserId": "idcqa"
        },
        {
            "AccountId": "oaccount~60bb20c14a83f6e426e1437c479c5891e1c6477dfd7ad18b73acac5d80bc504b",
            "OrgId": "appdev",
            "UserId": "user1"
        }
    ]
}

Metodi per gestione cronologia transazioni

GetAccountTransactionHistory
Questo metodo restituisce la cronologia delle transazioni del conto. Questo metodo può essere chiamato solo da un Token Admin del codice concatenato o dal proprietario dell'account. Per i token non fungibili, questo metodo può essere richiamato solo quando è connesso alla rete remota di Oracle Blockchain Platform.
func (t *Controller) GetAccountTransactionHistory(orgId string, userId string, tokenId ...string) (interface{}, error) {
            userAccountId, err := t.Ctx.ERC1155Account.GenerateAccountId(orgId, userId, constants.UserAccount)
            if err != nil {
                  return nil, fmt.Errorf("error in GetAccountTransactionHistory. Error: %s", err)
            }
            auth, err := t.Ctx.ERC1155Auth.CheckAuthorization("ERC1155Account.GetAccountTransactionHistory", "TOKEN", map[string]string{"accountId": userAccountId})
            if err != nil && !auth {
                  return nil, fmt.Errorf("error in authorizing the caller %s", err.Error())
            }
            tokenAccount, err := t.Ctx.ERC1155Account.Get(userAccountId, tokenId...)
            if err != nil {
                  return nil, fmt.Errorf("error in GetAccountTransactionHistory. Error: %s", err)
            }
            tokenAccountId, err := util.GetAccountProperty(tokenAccount, constants.AccountId)
            if err != nil {
                  return nil, fmt.Errorf("error in GetAccountTransactionHistory. Error: %s", err)
            }
            return t.Ctx.ERC1155Account.GetAccountTransactionHistory(tokenAccountId)
      }
Parametri:
  • orgId string - L'ID MSP (Membership Service Provider) dell'utente nell'organizzazione corrente.
  • userId string: il nome utente o l'ID e-mail dell'utente.
  • tokenId ...string – Per un account token non fungibile, una stringa vuota. Per un account token fungibile, l'ID token.
Valore restituito
[
    {
        "Balance": 90,
        "Timestamp": "2023-06-06T11:11:09Z",
        "TokenId": "FNFT",
        "TransactedAccount": "oaccount~dcee860665db8740cb77b846e823752185a1e9a185814d0acb305890f5903446",
        "TransactedAmount": 10,
        "TransactionId": "otransaction~0f4d96fbf8fed88ea8a3133428977721091467c701848d595ebc3fffa88b3657~7c88c736df38d5622512f1e8dcdd50710eb47c953f1ecb24ac44790a9e2f475b",
        "TransactionType": "DEBIT",
        "TriggeredByUserAccountId": "ouaccount~412de5e3998dcd100973e1bad6e8729fddc1c7ff610beab8376d733a35c51f38"
    },
    {
        "Timestamp": "2023-06-06T11:11:09Z",
        "TokenId": "NFT",
        "TransactedAccount": "oaccount~dcee860665db8740cb77b846e823752185a1e9a185814d0acb305890f5903446",
        "TransactionId": "otransaction~0f4d96fbf8fed88ea8a3133428977721091467c701848d595ebc3fffa88b3657~178e3730bc5bee50d02f1464a4eebf733a051905f651e5789039adb4a3edc114",
        "TransactionType": "DEBIT",
        "TriggeredByUserAccountId": "ouaccount~412de5e3998dcd100973e1bad6e8729fddc1c7ff610beab8376d733a35c51f38"
    },
    {
        "Timestamp": "2023-06-06T11:06:54Z",
        "TokenId": "NFT",
        "TransactedAccount": "oaccount~e88276a3be547e31b567346bdddde52d37734da4d5fae83ab2e5c98a10097371",
        "TransactionId": "otransaction~6a13667ea3f6edc4c854e85b127526eccb58783f653c348b42a3869f0f29a4fb~a7cefb22ff39ee7e36967be71de27da6798548c872061a62dabc56d88d50b930",
        "TransactionType": "MINT",
        "TriggeredByUserAccountId": "ouaccount~412de5e3998dcd100973e1bad6e8729fddc1c7ff610beab8376d733a35c51f38"
    },
    {
        "Balance": 100,
        "Timestamp": "2023-06-05T16:34:33Z",
        "TokenId": "FNFT",
        "TransactedAccount": "oaccount~e88276a3be547e31b567346bdddde52d37734da4d5fae83ab2e5c98a10097371",
        "TransactedAmount": 100,
        "TransactionId": "otransaction~2bc15de1766d582d821bd8d61756bca02837dc683c0aa61f69657ccd1d95e335~e4eb15d9354f694230df8835ade012100d82aa43672896a2c7125a86e3048f9f",
        "TransactionType": "MINT",
        "TriggeredByUserAccountId": "ouaccount~412de5e3998dcd100973e1bad6e8729fddc1c7ff610beab8376d733a35c51f38"
    }
]
GetTransactionById
Questo metodo restituisce i dettagli della transazione per un ID transazione specificato. Chiunque può chiamare questo metodo.
func (t *Controller) GetTransactionById(transactionId string) (interface{}, error) {
            return t.Ctx.ERC1155Transaction.GetTransactionById(transactionId)
      }
Parametri:
  • transactionId: string: l'ID della transazione.
Valore restituito
{
    "history": [
        {
            "IsDelete": "false",
            "Timestamp": "2022-12-08T10:45:56Z",
            "TxId": "2da02a53aa1032602df6c68c5628a4ab8b22ba107c0201520ce495948901aa98",
            "Value": {
                "Amount": 5,
                "AssetType": "otransaction",
                "FromAccountId": "oaccount~60bb20c14a83f6e426e1437c479c5891e1c6477dfd7ad18b73acac5d80bc504b",
                "Timestamp": "2022-12-08T10:45:56Z",
                "ToAccountId": "oaccount~1422a74d262a3a55a37cd9023ef8836f765d0be7b49d397696b9961d7434d22a",
                "TokenId": "tokenOne",
                "TransactionId": "otransaction~2da02a53aa1032602df6c68c5628a4ab8b22ba107c0201520ce495948901aa98~9c3ce5f21abd98ca018c196086d73a812f2f49dba323f1de4f6867eecfeec8ff",
                "TransactionType": "TRANSFER",
                "TriggeredByUserAccountId": "ouaccount~24ffd4d32a028a85b4b960f5d55536c837b5429bc7f346150adfa904ec2937cc"
            }
        }
    ],
    "transactionId": "otransaction~2da02a53aa1032602df6c68c5628a4ab8b22ba107c0201520ce495948901aa98~9c3ce5f21abd98ca018c196086d73a812f2f49dba323f1de4f6867eecfeec8ff"
}
DeleteHistoricalTransactions
Questo metodo elimina le transazioni prima di un indicatore orario specificato dal database di stato. Questo metodo può essere chiamato solo da un Token Admin del codice concatenato.
func (t *Controller) DeleteHistoricalTransactions(timestamp string) (interface{}, error) {
            auth, err := t.Ctx.ERC1155Auth.CheckAuthorization("ERC1155Transaction.DeleteHistoricalTransactions", "TOKEN")
            if err != nil && !auth {
                  return nil, fmt.Errorf("error in authorizing the caller %s", err.Error())
            }
            return t.Ctx.ERC1155Transaction.DeleteHistoricalTransactions(timestamp)
      }
Parametri:
  • timestamp: string: tutte le transazioni precedenti a questo indicatore orario verranno eliminate.
Valore restituito
{
    "Transactions": [
        "otransaction~750f68538451847f57948f7d5261dcb81570cd9e429f928a4cb7bfa76392ecf7"
    ],
    "msg": "Successfuly deleted transaction older than date:2022-04-06T08:17:53Z"
}

Metodi per la gestione del comportamento dei token - Comportamento minimo

MintBatch
Questo metodo crea (mette) più token in un'operazione batch. Questo metodo crea solo token fungibili o token non fungibili frazionari.

Per i token fungibili, se il ruolo più piccolo è definito nel file di specifica, qualsiasi utente con il ruolo più piccolo può chiamare questo metodo. In caso contrario, qualsiasi utente può utilizzare questo metodo per creare token. Non è possibile creare più di una proprietà max_mint_quantity del token, se tale proprietà è stata specificata al momento della creazione o dell'aggiornamento del token.

Per i token non fungibili, se il ruolo minter è definito nel file di specifica, qualsiasi utente con il ruolo minter può chiamare questo metodo. In caso contrario, qualsiasi utente può utilizzare questo metodo per creare token. Inoltre, il chiamante deve essere anche il creatore del token. Non esiste un limite superiore alla quantità di token non fungibili frazionari che possono essere coniati.

Non è possibile utilizzare questo metodo per coniare un token intero non fungibile.

func (t *Controller) MintBatch(orgId string, userId string, tokenIds []string, quantity []float64) (interface{}, error) {
            accountId, err := t.Ctx.ERC1155Account.GenerateAccountId(orgId, userId, constants.UserAccount)
            if err != nil {
                  return nil, fmt.Errorf("error in generating the accountId. Error: %s", err)
            }
            var tokens []interface{}
            for _, tokenId := range tokenIds {
                  tokenAssetValue, err := t.getTokenObject(tokenId)
                  if err != nil {
                        return nil, err
                  }
                  tokens = append(tokens, tokenAssetValue.Interface())
            }
            return t.Ctx.ERC1155Token.MintBatch(accountId, tokens, quantity)
      }
Parametri:
  • orgId string - L'ID MSP (Membership Service Provider) dell'utente nell'organizzazione corrente.
  • userId string: il nome utente o l'ID e-mail dell'utente.
  • tokenIds []string: la lista di ID token per i token mint.
  • quantity []float64: l'elenco delle quantità di token da mint, corrispondente all'array ID token.
Restituisce:
  • In caso di operazione riuscita, un oggetto JSON che include dettagli sui token coniati.
Valore restituito
{
    "details": [
        {
            "msg": "Successfully minted 100 tokens of fractional tokenId: plot55 to Org-Id: appdev, User-Id: idcqa"
        },
        {
            "msg": "Successfully minted 100 tokens of tokenId: 'loyalty' to Token-Account-Id 'oaccount~21206f309941a2a23c4f158a0fe1b8f12bb8e2b0c9a2e1358f5efebc0c7d410e'"
        }
    ],
    "msg": "Successfully minted batch of tokens for User-Account-Id 'ouaccount~412de5e3998dcd100973e1bad6e8729fddc1c7ff610beab8376d733a35c51f38' (Org-Id: 'appdev', User-Id: 'idcqa')"
}

Metodi per la gestione del comportamento dei token - comportamento trasferibile

BatchTransferFrom
Questo metodo completa un'operazione batch che trasferisce i token specificati in una lista di ID token da un utente a un altro utente.

Per i NFT, poiché il metodo trasferisce la proprietà del NFT, il mittente del NFT deve possedere il token.

Per le NFT frazionarie, se un utente (incluso il creatore del token) trasferisce tutte le azioni di cui è proprietario, allora perde la proprietà del token. Se una qualsiasi parte di un token viene trasferita a un utente, tale utente diventa automaticamente uno dei proprietari del NFT frazionario.

Questo metodo non convalida che il chiamante del metodo sia il mittente specificato. Questo metodo può essere chiamato da qualsiasi utente.

func (t *Controller) BatchTransferFrom(fromOrgId string, fromUserId string, toOrgId string, toUserId string, tokenIds []string, quantity []float64) (interface{}, error) {
            fromAccountId, err := t.Ctx.ERC1155Account.GenerateAccountId(fromOrgId, fromUserId, constants.UserAccount)
            if err != nil {
                  return nil, fmt.Errorf("error in BatachTransferFrom. Error: %s", err)
            }
            toAccountId, err := t.Ctx.ERC1155Account.GenerateAccountId(toOrgId, toUserId, constants.UserAccount)
            if err != nil {
                  return nil, fmt.Errorf("error in BatachTransferFrom. Error: %s", err)
            }
            var tokens []interface{}
            for _, tokenId := range tokenIds {
                  tokenAssetValue, err := t.getTokenObject(tokenId)
                  if err != nil {
                        return nil, err
                  }
                  tokens = append(tokens, tokenAssetValue.Interface())
            }
            return t.Ctx.ERC1155Token.BatchTransferFrom(fromAccountId, toAccountId, tokens, quantity)
      }
Parametri:
  • fromOrgId string - L'ID MSP (Membership Service Provider) del mittente e del proprietario del token nell'organizzazione corrente.
  • fromUserId string – Il nome utente o l'ID e-mail del mittente e del proprietario del token.
  • toOrgId string - L'ID MSP (Membership Service Provider) del destinatario nell'organizzazione corrente.
  • toUserId string: il nome utente o l'ID e-mail del destinatario.
  • tokenIds string[]: lista di ID token per i token da trasferire.
  • quantity float64[]: l'elenco delle quantità di token da trasferire, corrispondente all'array ID token.
Restituisce:
  • In caso di operazione riuscita, un messaggio con i dettagli per ogni trasferimento di token.
Valore restituito
[
    {
        "msg": "Successfully transferred NFT token: 'FNFT' of '10' quantity from Account-Id: oaccount~e88276a3be547e31b567346bdddde52d37734da4d5fae83ab2e5c98a10097371 (Org-Id: appdev, User-Id: idcqa) to Account-Id: oaccount~dcee860665db8740cb77b846e823752185a1e9a185814d0acb305890f5903446 (Org-Id: appdev, User-Id: user1_minter)"
    },
    {
        "msg": "Successfully transferred 10 FT token: 'FT' from Account-Id: oaccount~21206f309941a2a23c4f158a0fe1b8f12bb8e2b0c9a2e1358f5efebc0c7d410e (Org-Id: appdev, User-Id: idcqa) to Account-Id: oaccount~1089ee5122f367ee0ca38c6660298f4b81f199627e4f67f3691c0f628237974c (Org-Id: appdev, User-Id: user1_minter)"
    },
    {
        "msg": "Successfully transferred NFT token: 'NFT' from Account-Id: oaccount~e88276a3be547e31b567346bdddde52d37734da4d5fae83ab2e5c98a10097371 (Org-Id: appdev, User-Id: idcqa) to Account-Id: oaccount~dcee860665db8740cb77b846e823752185a1e9a185814d0acb305890f5903446 (Org-Id: appdev, User-Id: user1_minter)"
    }
]
SafeBatchTransferFrom
Questo metodo completa un'operazione batch che trasferisce i token specificati in una lista di ID token da un utente a un altro utente.

Per i NFT, poiché il metodo trasferisce la proprietà del NFT, il mittente del NFT deve possedere il token.

Per le NFT frazionarie, se un utente (incluso il creatore del token) trasferisce tutte le azioni di cui è proprietario, allora perde la proprietà del token. Se una qualsiasi parte di un token viene trasferita a un utente, tale utente diventa automaticamente uno dei proprietari del NFT frazionario.

Il chiamante del metodo deve essere il mittente specificato. Questo metodo può essere chiamato da qualsiasi utente.

func (t *Controller) SafeBatchTransferFrom(fromOrgId string, fromUserId string, toOrgId string, toUserId string, tokenIds []string, quantity []float64) (interface{}, error) {
            fromAccountId, err := t.Ctx.ERC1155Account.GenerateAccountId(fromOrgId, fromUserId, constants.UserAccount)
            if err != nil {
                  return nil, fmt.Errorf("error in BatachTransferFrom. Error: %s", err)
            }
            toAccountId, err := t.Ctx.ERC1155Account.GenerateAccountId(toOrgId, toUserId, constants.UserAccount)
            if err != nil {
                  return nil, fmt.Errorf("error in BatachTransferFrom. Error: %s", err)
            }
            var tokens []interface{}
            for _, tokenId := range tokenIds {
                  tokenAssetValue, err := t.getTokenObject(tokenId)
                  if err != nil {
                        return nil, err
                  }
                  tokens = append(tokens, tokenAssetValue.Interface())
            }
            return t.Ctx.ERC1155Token.SafeBatchTransferFrom(fromAccountId, toAccountId, tokens, quantity)
      }
Parametri:
  • fromOrgId string - L'ID MSP (Membership Service Provider) del mittente e del proprietario del token nell'organizzazione corrente.
  • fromUserId string – Il nome utente o l'ID e-mail del mittente e del proprietario del token.
  • toOrgId string - L'ID MSP (Membership Service Provider) del destinatario nell'organizzazione corrente.
  • toUserId string: il nome utente o l'ID e-mail del destinatario.
  • tokenIds string[]: lista di ID token per i token da trasferire.
  • quantity float64[]: l'elenco delle quantità di token da trasferire, corrispondente all'array ID token.
Restituisce:
  • In caso di operazione riuscita, un messaggio con i dettagli per ogni trasferimento di token.
Valore restituito
[
    {
        "msg": "Successfully transferred NFT token: 'FNFT' of '10' quantity from Account-Id: oaccount~e88276a3be547e31b567346bdddde52d37734da4d5fae83ab2e5c98a10097371 (Org-Id: appdev, User-Id: idcqa) to Account-Id: oaccount~dcee860665db8740cb77b846e823752185a1e9a185814d0acb305890f5903446 (Org-Id: appdev, User-Id: user1_minter)"
    },
    {
        "msg": "Successfully transferred 10 FT token: 'FT' from Account-Id: oaccount~21206f309941a2a23c4f158a0fe1b8f12bb8e2b0c9a2e1358f5efebc0c7d410e (Org-Id: appdev, User-Id: idcqa) to Account-Id: oaccount~1089ee5122f367ee0ca38c6660298f4b81f199627e4f67f3691c0f628237974c (Org-Id: appdev, User-Id: user1_minter)"
    },
    {
        "msg": "Successfully transferred NFT token: 'NFT' from Account-Id: oaccount~e88276a3be547e31b567346bdddde52d37734da4d5fae83ab2e5c98a10097371 (Org-Id: appdev, User-Id: idcqa) to Account-Id: oaccount~dcee860665db8740cb77b846e823752185a1e9a185814d0acb305890f5903446 (Org-Id: appdev, User-Id: user1_minter)"
    }
]
BalanceOfBatch
Questo metodo completa un'operazione batch che recupera il saldo dei conti token. I dettagli dell'account sono specificati in tre elenchi separati di ID organizzazione, ID utente e ID token. Questo metodo può essere chiamato solo da un Token Admin del codice concatenato o dai proprietari dell'account. I proprietari del conto possono visualizzare i dettagli del saldo solo per i conti di loro proprietà.
func (t *Controller) BalanceOfBatch(orgIds []string, userIds []string, tokenIds []string) (interface{}, error) {
            callerAccountCheck := false
            _, err := t.Ctx.ERC1155Auth.CheckAuthorization("ERC1155Account.BalanceOfBatch", "TOKEN")
            if err != nil {
                  callerAccountCheck = true
            }
            accountIds, err := t.Ctx.ERC1155Account.GenerateAccountIds(orgIds, userIds, callerAccountCheck)
            if err != nil {
                  return nil, fmt.Errorf("error in BalanceOfBatch. Error: %s", err)
            }
            var tokens []interface{}
            for _, tokenId := range tokenIds {
                  tokenAssetValue, err := t.getTokenObject(tokenId)
                  if err != nil {
                        tokens = append(tokens, map[string]interface{}{"TokenId": tokenId})
                  } else {
                        tokens = append(tokens, tokenAssetValue.Interface())
                  }
            }
            return t.Ctx.ERC1155Account.BalanceOfBatch(accountIds, tokens)
      }
Parametri:
  • orgIds []string: elenco degli ID MSP (Membership Service Provider) nell'organizzazione corrente.
  • userIds []string: elenco del nome utente o degli ID e-mail.
  • tokenIds []string: elenco degli ID del token.
Esempio di valore restituito:

Nell'esempio seguente, l'ID token FNFT rappresenta un token non fungibile frazionario e l'ID token FT rappresenta un token fungibile.

[
    {
        "OrgId": "appdev",
        "UserId": "idcqa",
        "UserAccountId": "ouaccount~412de5e3998dcd100973e1bad6e8729fddc1c7ff610beab8376d733a35c51f38",
        "TokenAccountId": "oaccount~e88276a3be547e31b567346bdddde52d37734da4d5fae83ab2e5c98a10097371",
        "TokenId": "FNFT",
        "Balance": 100
    },
    {
        "OrgId": "appdev",
        "UserId": "idcqa",
        "UserAccountId": "ouaccount~412de5e3998dcd100973e1bad6e8729fddc1c7ff610beab8376d733a35c51f38",
        "TokenAccountId": "oaccount~21206f309941a2a23c4f158a0fe1b8f12bb8e2b0c9a2e1358f5efebc0c7d410e",
        "TokenId": "FT",
        "Balance": 50
    },
    {
        "OrgId": "appdev",
        "UserId": "user1_minter",
        "UserAccountId": "ouaccount~9501bb774c156eb8354dfe489250ea91f757523d70f08ee494bda98bb352003b",
        "TokenAccountId": "oaccount~dcee860665db8740cb77b846e823752185a1e9a185814d0acb305890f5903446",
        "TokenId": "FNFT",
        "Balance": 10
    }
]
ExchangeToken
Questo metodo scambia i token tra gli account specificati. Questo metodo supporta solo lo scambio tra un NFT e un token fungibile o un token fungibile e un NFT. Questo metodo può essere chiamato solo dal proprietario dell'account.
func (t *Controller) ExchangeToken(fromTokenId string, fromOrgId string, fromUserId string, fromTokenQuantity float64, toTokenId string, toOrgId string, toUserId string, toTokenQuantity float64) (interface{}, error) {
            fromUserAccountId, err := t.Ctx.ERC1155Account.GenerateAccountId(fromOrgId, fromUserId, constants.UserAccount)
            if err != nil {
                  return nil, fmt.Errorf("error in BatachTransferFrom. Error: %s", err)
            }
            auth, err := t.Ctx.ERC1155Auth.CheckAuthorization("ERC1155Account.ExchangeToken", "TOKEN", map[string]string{"accountId": fromUserAccountId})
            if err != nil && !auth {
                  return nil, fmt.Errorf("error in authorizing the caller %s", err.Error())
            }
            toUserAccountId, err := t.Ctx.ERC1155Account.GenerateAccountId(toOrgId, toUserId, constants.UserAccount)
            if err != nil {
                  return nil, fmt.Errorf("error in BatachTransferFrom. Error: %s", err)
            }
            return t.Ctx.ERC1155Token.ExchangeToken(fromTokenId, fromUserAccountId, fromTokenQuantity, toTokenId, toUserAccountId, toTokenQuantity)
      }
Parametri:
  • fromTokenId string: l'ID del token di proprietà del mittente.
  • fromOrgId string – L'ID MSP (Membership Service Provider) del mittente nell'organizzazione corrente.
  • fromUserId string – Il nome utente o l'ID e-mail del mittente.
  • fromTokenQuantity float64 – La quantità di token dal mittente da scambiare con il ricevitore.
  • toTokenId string: l'ID del token di proprietà del ricevente.
  • toOrgId string - L'ID MSP (Membership Service Provider) del destinatario nell'organizzazione corrente.
  • toUserId string: il nome utente o l'ID e-mail del destinatario.
  • toTokenQuantity float64 – La quantità di token dal destinatario da scambiare con il mittente.
Restituisce:
  • In caso di operazione riuscita, un messaggio con i dettagli dello scambio di token.
Valore restituito
{
    "msg": "Succesfully exchanged 10 tokens of type 'nonfungible' with tokenId: [r1] from Account 'oaccount~e88276a3be547e31b567346bdddde52d37734da4d5fae83ab2e5c98a10097371' (OrgId: appdev, UserId: idcqa) to 10 tokens of type 'fungible' with tokenId: [loy1] from Account 'oaccount~1089ee5122f367ee0ca38c6660298f4b81f199627e4f67f3691c0f628237974c' (OrgId: 'appdev', UserId: 'user1_minter')"
}

Metodi per la gestione del comportamento dei token - comportamento masterizzabile

BurnBatch
Questo metodo disattiva, o brucia, i token fungibili e non fungibili specificati. Qualsiasi utente può chiamare questo metodo.
func (t *Controller) BurnBatch(orgId string, userId string, tokenIds []string, quantity []float64) (interface{}, error) {
            accountId, err := t.Ctx.ERC1155Account.GenerateAccountId(orgId, userId, constants.UserAccount)
            if err != nil {
                  return nil, fmt.Errorf("error in BatachTransferFrom. Error: %s", err)
            }
            var tokens []interface{}
            for _, tokenId := range tokenIds {
                  tokenAssetValue, err := t.getTokenObject(tokenId)
                  if err != nil {
                        return nil, err
                  }
                  tokens = append(tokens, tokenAssetValue.Interface())
            }
            return t.Ctx.ERC1155Token.Burn(accountId, tokens, quantity)
      }
Parametri:
  • orgId string - L'ID del provider di servizi di membership (MSP) nell'organizzazione corrente.
  • userId string: il nome utente o l'ID e-mail.
  • tokenIds []string: la lista degli ID token da masterizzare
  • quantity []float64: l'elenco delle quantità di token da masterizzare, corrispondente all'array ID token.
Restituisce:
  • In caso di successo, un messaggio con dettagli sulle operazioni di masterizzazione.
Valore restituito
[
    {
        "msg": "Successfully burned NFT token: 'art' from Account-Id: oaccount~76cb672eeb1bd535899562a840d0c15a356db89e24bc8b43ac1dba845a4282c6 (Org-Id: appdev, User-Id: idcqa)"
    },
    {
        "msg": "Successfully burned 2 tokens of tokenId: FT from Account-ID oaccount~9a940587fd322ccc8400233244cd3b13f3aa2a52e418e4c71fb819a2217bc49e (Org-Id: AutoF1377358917, User-Id: idcqa)"
    },
    {
        "msg": "Successfully burned 2 token share of tokenId: FNFT from Account-ID oaccount~87bcb699d507368ee3966cd03ee6d7736ffc55dde8c0f0e16b14866334ac504a (Org-Id: AutoF1377358917, User-Id: idcqa)"
    }
]
BurnNFT
Questo metodo disattiva o brucia il token non fungibile specificato e restituisce un oggetto token e la cronologia token. Qualsiasi utente con il ruolo di masterizzatore può chiamare questo metodo.
func (t *Controller) BurnNFT(orgId string, userId string, tokenId string) (interface{}, error) {
            tokenAsset, err := t.Ctx.ERC1155Token.Get(tokenId)
            if err != nil {
                  return nil, err
            }
            token := tokenAsset.(map[string]interface{})
            if token[constants.TokenType] != constants.NonFungible {
                  return nil, fmt.Errorf("only nonfungible tokens are allowed")
            }
            if token[constants.IsBurned] == true {
                  return nil, fmt.Errorf("token with tokenId %s is already burned", tokenId)
            }
            tokenQuantity := float64(1)
            tokenUnit := token[constants.TokenUnit]
            tokenHistory, err := t.Ctx.ERC1155Token.History(tokenId)
            if err != nil {
                  return nil, err
            }
            if tokenUnit == constants.Fractional {
                  owners, err := t.Ctx.ERC1155Token.OwnerOf(tokenId)
                  if err != nil {
                        return nil, err
                  }
                  ownersList := owners.([]map[string]interface{})
                  if len(ownersList) != 1 {
                        return nil, fmt.Errorf("NFT has multiple owners, to completely burn this NFT it should have only one owner")
                  }
                  tokenQuantity = token[constants.Quantity].(float64)
            }
            token[constants.TokenId], err = strconv.Atoi(token[constants.TokenId].(string))
            if err != nil {
                  return nil, fmt.Errorf("tokenId is expected to be integer but found %s", tokenId)
            }
            tokenHistoryBytes, err := json.Marshal(tokenHistory)
            if err != nil {
                  return nil, err
            }
            var tokenHistoryAsRawJson json.RawMessage
            err = json.Unmarshal(tokenHistoryBytes, &tokenHistoryAsRawJson)
            if err != nil {
                  return nil, err
            }
            token[constants.TokenHistory] = string(tokenHistoryAsRawJson)
            tokenIds := []string{tokenId}
            tokenQuantities := []float64{tokenQuantity}
            token[constants.IsBurned] = true
            _, err = t.BurnBatch(orgId, userId, tokenIds, tokenQuantities)
            if err != nil {
                  return nil, err
            }
            return token, nil
      }
Parametri:
  • orgId: string - L'ID del provider di servizi di membership (MSP) nell'organizzazione corrente.
  • userId: string: il nome utente o l'ID e-mail.
  • tokenId: string – L'ID del token non fungibile da masterizzare
Restituisce:
  • In caso di operazione riuscita, un oggetto token in formato JSON che include informazioni sulla cronologia dei token.
Valore restituito
{
    "AssetType": "otoken",
    "Behaviors": [
        "indivisible",
        "singleton",
        "mintable",
        "transferable",
        "burnable",
        "roles"
    ],
    "CreatedBy": "oaccount~42e89f4c72dfde9502814876423c6da630d466e87436dd1aae201d347ad1288d",
    "CreationDate": "2023-08-22T13:14:46+05:30",
    "IsBurned": true,
    "Mintable": {
        "Max_mint_quantity": 20000
    },
    "On_sale_flag": false,
    "Owner": "oaccount~42e89f4c72dfde9502814876423c6da630d466e87436dd1aae201d347ad1288d",
    "Price": 120,
    "Quantity": 1,
    "Roles": {
        "minter_role_name": "minter"
    },
    "TokenDesc": "",
    "TokenHistory": "[{\"IsDelete\":\"false\",\"Timestamp\":\"2023-08-22T13:14:46+05:30\",\"TxId\":\"c0ea212f19197c5b86323bfca11c6ca545aa0af5d40cd04f9e955b5371fd40ae\",\"Value\":{\"AssetType\":\"otoken\",\"Behaviors\":[\"indivisible\",\"singleton\",\"mintable\",\"transferable\",\"burnable\",\"roles\"],\"CreatedBy\":\"oaccount~42e89f4c72dfde9502814876423c6da630d466e87436dd1aae201d347ad1288d\",\"CreationDate\":\"2023-08-22T13:14:46+05:30\",\"IsBurned\":false,\"Mintable\":{\"Max_mint_quantity\":20000},\"On_sale_flag\":false,\"Owner\":\"oaccount~42e89f4c72dfde9502814876423c6da630d466e87436dd1aae201d347ad1288d\",\"Price\":120,\"Quantity\":1,\"Roles\":{\"minter_role_name\":\"minter\"},\"TokenDesc\":\"\",\"TokenId\":\"1\",\"TokenMetadata\":{\"Description\":\"\",\"Image\":\"\",\"Painter_name\":\"\",\"Painting_name\":\"\"},\"TokenName\":\"artcollection\",\"TokenStandard\":\"erc1155+\",\"TokenType\":\"nonfungible\",\"TokenUnit\":\"whole\",\"TokenUri\":\"example.com\"}}]",
    "TokenId": 1,
    "TokenMetadata": {
        "Description": "",
        "Image": "",
        "Painter_name": "",
        "Painting_name": ""
    },
    "TokenName": "artcollection",
    "TokenStandard": "erc1155+",
    "TokenType": "nonfungible",
    "TokenUnit": "whole",
    "TokenUri": "example.com"
}

Metodi SDK

Metodi per la gestione del controllo degli accessi

IsUserTokenAdmin
Questo metodo restituisce il valore booleano true se l'utente specificato è un Token Admin e altrimenti false. Il metodo può essere chiamato solo da un Token Admin del codice concatenato del token.
Ctx.ERC1155Auth.IsUserTokenAdmin(orgId string, userId string) (interface{}, error)
Parametri:
  • orgId: string - L'ID MSP (Membership Service Provider) dell'utente nell'organizzazione corrente.
  • userId: string: il nome utente o l'ID e-mail dell'utente.
Valore restituito
{
  "result": true
}
AddAdmin
Questo metodo aggiunge un utente come Token Admin del codice concatenato del token. Il metodo può essere chiamato solo da un Token Admin del codice concatenato del token.
Ctx.ERC1155Admin.AddAdmin(orgId string, userId string) (interface{}, error)
Parametri:
  • orgId: string - L'ID MSP (Membership Service Provider) dell'utente nell'organizzazione corrente.
  • userId: string: il nome utente o l'ID e-mail dell'utente.
Restituisce:
  • In caso di operazione riuscita, un messaggio che elenca i dettagli per l'utente aggiunto come Token Admin del codice concatenato del token.
Valore restituito
{
  "msg": "Successfully added Admin (orgId: appdev, userId: user1)"
}
RemoveAdmin
Questo metodo rimuove un utente come Token Admin del codice concatenato del token. Il metodo può essere chiamato solo da un Token Admin del codice concatenato del token. Non è possibile rimuovere se stessi come Token Admin.
Ctx.ERC1155Admin.RemoveAdmin(orgId string, userId string) (interface{}, error)
Parametri:
  • orgId: string - L'ID MSP (Membership Service Provider) dell'utente nell'organizzazione corrente.
  • userId: string: il nome utente o l'ID e-mail dell'utente.
Restituisce:
  • In caso di operazione riuscita, un messaggio che elenca i dettagli per l'utente rimosso come Token Admin del codice concatenato del token.
Valore restituito
{
    "msg": "Successfully removed Admin (orgId appdev userId user1)"
}
GetAllAdminUsers
Questo metodo restituisce un elenco di tutti gli utenti Token Admin.
Ctx.ERC1155Admin.GetAllAdminUsers() (interface{}, error)
Parametri:
  • nessuno
Restituisce:
  • In caso di operazione riuscita, un elenco di tutti gli utenti Token Admin, identificati per ID organizzazione e ID utente.
Valore restituito
{
  "admins": [
    {
      "OrgId": "appdev",
      "UserId": "idcqa"
    },
    {
      "OrgId": "appdev",
      "UserId": "user1"
    }
  ]
}
CheckAuthorization
Utilizzare questo metodo per aggiungere un controllo di accesso a un'operazione. Questa è una funzione asincrona. La maggior parte dei metodi generati automaticamente include il controllo dell'accesso. Alcuni metodi di token possono essere eseguiti solo da ERC721Admin o Account Owner del token o da un MultipleAccountOwner per gli utenti con più account. Il metodo CheckAuthorization fa parte della classe erc721Auth, a cui si accede tramite l'oggetto Ctx. Il mapping del controllo dell'accesso è descritto nel file oChainUtil.go, come mostrato nel testo seguente. È possibile modificare il controllo dell'accesso modificando il file oChainUtil.go.
  var t TokenAccess
      var r RoleAccess
      var a AccountAccess
      var as AccountStatusAccess
      var h HoldAccess
      var ad AdminAccess
      var trx TransactionAccess
      var tc TokenConversionAccess
      var auth AuthAccess
      var erc721ad ERC721AdminAccess
      var erc721t ERC721TokenAccess
      var erc721r ERC721RoleAccess
      var erc721a ERC721AccountAccess
      var erc721as ERC721AccountStatusAccess
      var erc721trx ERC721TransactionAccess

      var erc1155ad ERC1155AdminAccess
      var erc1155t ERC1155TokenAccess
      var erc1155a ERC1155AccountAccess
      var erc1155as ERC1155AccountStatusAccess
      var erc1155trx ERC1155TransactionAccess
      var erc1155role ERC1155RoleAccess
      trx.DeleteHistoricalTransactions = []string{"Admin"}
      ad.AddAdmin = []string{"Admin"}
      ad.RemoveAdmin = []string{"Admin"}
      ad.GetAllAdmins = []string{"Admin", "OrgAdmin"}
      ad.AddOrgAdmin = []string{"Admin", "OrgAdminOrgIdCheck"}
      ad.RemoveOrgAdmin = []string{"Admin", "OrgAdminOrgIdCheck"}
      ad.GetOrgAdmins = []string{"Admin", "OrgAdmin"}
      ad.IsTokenAdmin = []string{"Admin", "MultipleAccountOwner", "OrgAdmin"}
      t.Save = []string{"Admin"}
      t.GetAllTokens = []string{"Admin", "OrgAdmin"}
      t.Update = []string{"Admin"}
      t.GetTokenDecimals = []string{"Admin", "OrgAdmin"}
      t.GetTokensByName = []string{"Admin", "OrgAdmin"}
      t.AddRoleMember = []string{"Admin", "OrgAdminRoleCheck"}
      t.RemoveRoleMember = []string{"Admin", "OrgAdminRoleCheck"}
      t.IsInRole = []string{"Admin", "OrgAdminAccountIdCheck", "AccountOwner"}
      t.GetTotalMintedTokens = []string{"Admin", "OrgAdmin"}
      t.GetNetTokens = []string{"Admin", "OrgAdmin"}
      t.Get = []string{"Admin", "OrgAdmin"}
      t.GetTokenHistory = []string{"Admin", "OrgAdmin"}
      a.CreateAccount = []string{"Admin", "OrgAdminOrgIdCheck"}
      a.AssociateToken = []string{"Admin", "OrgAdminAccountIdCheck"}
      a.GetAllAccounts = []string{"Admin"}
      a.GetAllOrgAccounts = []string{"Admin", "OrgAdminOrgIdCheck"}
      a.GetAccount = []string{"Admin", "OrgAdminAccountIdCheck", "AccountOwner"}
      a.History = []string{"Admin", "AccountOwner"}
      a.GetAccountTransactionHistory = []string{"Admin", "OrgAdminAccountIdCheck", "AccountOwner"}
      a.GetAccountTransactionHistoryWithFilters = []string{"Admin", "OrgAdminAccountIdCheck", "AccountOwner"}
      a.GetSubTransactionsById = []string{"Admin", "TransactionInvoker"}
      a.GetSubTransactionsByIdWithFilters = []string{"Admin", "TransactionInvoker"}
      a.GetAccountBalance = []string{"Admin", "OrgAdminAccountIdCheck", "AccountOwner"}
      a.GetAccountOnHoldBalance = []string{"Admin", "OrgAdminAccountIdCheck", "AccountOwner"}
      a.GetOnHoldIds = []string{"Admin", "OrgAdminAccountIdCheck", "AccountOwner"}
      a.GetAccountsByUser = []string{"Admin", "OrgAdminOrgIdCheck", "MultipleAccountOwner"}

      as.Get = []string{"Admin", "OrgAdminAccountIdCheck", "AccountOwner"}
      as.ActivateAccount = []string{"Admin", "OrgAdminOrgIdCheck"}
      as.SuspendAccount = []string{"Admin", "OrgAdminOrgIdCheck"}
      as.DeleteAccount = []string{"Admin", "OrgAdminOrgIdCheck"}

      r.GetAccountsByRole = []string{"Admin"}
      r.GetUsersByRole = []string{"Admin"}
      r.GetOrgAccountsByRole = []string{"Admin", "OrgAdminOrgIdCheck"}
      r.GetOrgUsersByRole = []string{"Admin", "OrgAdminOrgIdCheck"}
      tc.InitializeExchangePoolUser = []string{"Admin"}
      tc.AddConversionRate = []string{"Admin"}
      tc.UpdateConversionRate = []string{"Admin"}
      tc.GetConversionRate = []string{"Admin", "OrgAdmin", "AnyAccountOwner"}
      tc.GetConversionRateHistory = []string{"Admin", "OrgAdmin", "AnyAccountOwner"}
      tc.TokenConversion = []string{"Admin", "AnyAccountOwner"}
      tc.GetExchangePoolUser = []string{"Admin"}

      erc721ad.AddAdmin = []string{"Admin"}
      erc721ad.GetAllAdmins = []string{"Admin"}
      erc721ad.IsTokenAdmin = []string{"Admin"}
      erc721ad.RemoveAdmin = []string{"Admin"}
      erc721trx.DeleteHistoricalTransactions = []string{"Admin"}
      erc721t.Save = []string{"Admin"}
      erc721t.GetAllTokens = []string{"Admin"}
      erc721t.Update = []string{"Admin"}
      erc721t.GetTokensByName = []string{"Admin"}
      erc721t.AddRoleMember = []string{"Admin"}
      erc721t.RemoveRoleMember = []string{"Admin"}
      erc721t.IsInRole = []string{"Admin", "AccountOwner"}
      erc721t.Get = []string{"Admin", "TokenOwner"}
      erc721t.GetAllTokensByUser = []string{"Admin", "AccountOwner"}
      erc721t.TotalSupply = []string{"Admin"}
      erc721t.TotalNetSupply = []string{"Admin"}
      erc721t.History = []string{"Admin"}
      erc721a.CreateAccount = []string{"Admin"}
      erc721a.CreateUserAccount = []string{"Admin"}
      erc721a.CreateTokenAccount = []string{"Admin"}
      erc721a.AssociateFungibleTokenToAccount = []string{"Admin", "AccountOwner"}
      erc721a.GetAllAccounts = []string{"Admin"}
      erc721a.History = []string{"Admin", "AccountOwner"}
      erc721a.GetAccountTransactionHistory = []string{"Admin", "AccountOwner"}
      erc721a.GetAccountTransactionHistoryWithFilters = []string{"Admin", "AccountOwner"}
      erc721a.GetAccountByUser = []string{"Admin", "MultipleAccountOwner"}
      erc721a.BalanceOf = []string{"Admin", "MultipleAccountOwner"}

      erc721as.Get = []string{"Admin", "AccountOwner"}
      erc721as.ActivateAccount = []string{"Admin"}
      erc721as.SuspendAccount = []string{"Admin"}
      erc721as.DeleteAccount = []string{"Admin"}

      erc721r.GetAccountsByRole = []string{"Admin"}
      erc721r.GetUsersByRole = []string{"Admin"}

      erc1155ad.AddAdmin = []string{"Admin"}
      erc1155ad.GetAllAdmins = []string{"Admin"}
      erc1155ad.IsUserTokenAdmin = []string{"Admin"}
      erc1155ad.RemoveAdmin = []string{"Admin"}
      erc1155t.AddRoleMember = []string{"Admin"}
      erc1155t.IsInRole = []string{"Admin"}
      erc1155t.GetAllTokens = []string{"Admin"}
      erc1155t.GetAllTokensByUser = []string{"Admin", "AccountOwner"}
      erc1155t.Get = []string{"Admin", "TokenOwner"}
      erc1155t.RemoveRoleMember = []string{"Admin"}
      erc1155t.TotalNetSupply = []string{"Admin"}
      erc1155t.TotalSupply = []string{"Admin"}
      erc1155t.GetTokenDecimal = []string{"Admin"}
      erc1155t.GetTokensByName = []string{"Admin"}
      erc1155t.GetTotalMintedTokens = []string{"Admin"}
      erc1155t.GetNetTokens = []string{"Admin"}
      erc1155t.Save = []string{"Admin"}
      erc1155t.Update = []string{"Admin"}

      erc1155trx.DeleteHistoricalTransactions = []string{"Admin"}

      erc1155role.GetAccountsByRole = []string{"Admin"}
      erc1155role.GetUsersByRole = []string{"Admin"}
      erc1155a.AssociateFungibleTokenToAccount = []string{"Admin", "AccountOwner"}
      erc1155a.BalanceOfBatch = []string{"Admin"}
      erc1155a.CreateAccount = []string{"Admin"}
      erc1155a.CreateTokenAccount = []string{"Admin"}
      erc1155a.CreateUserAccount = []string{"Admin"}
      erc1155a.GetAccountTransactionHistory = []string{"Admin", "AccountOwner"}
      erc1155a.GetAccountTransactionHistoryWithFilters = []string{"Admin", "AccountOwner"}
      erc1155a.GetAccountsByUser = []string{"Admin", "AccountOwner"}
      erc1155a.GetAccount = []string{"Admin", "AccountOwner"}
      erc1155a.History = []string{"Admin", "AccountOwner"}
      erc1155a.GetAllAccounts = []string{"Admin"}
      erc1155a.ExchangeToken = []string{"AccountOwner"}
      erc1155a.GetAccountDetailsByUser = []string{"Admin", "AccountOwner"}

      erc1155as.Get = []string{"Admin", "AccountOwner"}
      erc1155as.ActivateAccount = []string{"Admin"}
      erc1155as.SuspendAccount = []string{"Admin"}
      erc1155as.DeleteAccount = []string{"Admin"}
      var accessMap TokenAccessControl
      accessMap.Token = t
      accessMap.Account = a
      accessMap.AccountStatus = as
      accessMap.Hold = h
      accessMap.Role = r
      accessMap.Admin = ad
      accessMap.Auth = auth
      accessMap.TokenConversion = tc
      accessMap.ERC721ADMIN = erc721ad
      accessMap.ERC721TOKEN = erc721t
      accessMap.ERC721ACCOUNT = erc721a
      accessMap.ERC721AccountStatus = erc721as
      accessMap.ERC721ROLE = erc721r
      accessMap.ERC721TRANSACTION = erc721trx
      accessMap.ERC1155Account = erc1155a
      accessMap.ERC1155AccountStatus = erc1155as
      accessMap.ERC1155Admin = erc1155ad
      accessMap.ERC1155Token = erc1155t
      accessMap.ERC1155Transaction = erc1155trx
      accessMap.ERC1155Role = erc1155role
Ctx.ERC1155Auth.CheckAuthorization(funcName string, args []string) (bool, error)
Parametri:
  • funcName string: il valore della mappa tra i ricevitori e i metodi descritti nel file oChainUtil.go.
  • args: argomento di variabile in cui args[0] accetta la costante 'TOKEN' e args[1] utilizza il parametro accountId per aggiungere un controllo di accesso per un AccountOwner. Per aggiungere un controllo dell'accesso per un MultipleAccountOwner, args[1] accetta il parametro orgId e args[2] accetta il parametro userId. Per aggiungere un controllo dell'accesso per un controllo TokenOwner, args[1] accetta il parametro ID token.
Restituisce:
  • Risposta bool dell'errore come richiesto.

Metodi per la gestione della configurazione token

Save
Questo metodo crea i token. Ogni token definito ha il proprio metodo di creazione. Per i token non fungibili, se il ruolo minter è definito nel file di specifica, qualsiasi utente con il ruolo minter può chiamare questo metodo per creare un NFT. In caso contrario, qualsiasi utente può utilizzare questo metodo per creare (mint) NFT. L'utente che chiama questo metodo diventa il proprietario del NFT (intero o frazionario).
Ctx.ERC1155Token.Save(token interface{}, quantity ...float64) (interface{}, error)
Parametri:
  • tokenAsset: interface{}: asset del token. Le proprietà dell'asset sono definite nel file del modello.
  • quantity: number – Solo per i token non fungibili, il numero di token da mint. L'unico valore supportato per questo parametro è 1.
Restituisce:
  • In caso di operazione riuscita, l'asset token in formato JSON, che include le informazioni riportate di seguito.
  • Behavior o Behaviors: elenco dei comportamenti dei token. Proprietà non modificabile.
  • CreatedBy – L'ID account del chiamante, che è l'utente che sta usando il token. Proprietà non modificabile.
  • CreationDate – Il timestamp della transazione di conio. Proprietà non modificabile.
  • IsBurned: questa proprietà indica se il token viene masterizzato. Proprietà non modificabile.
  • Mintable – Le proprietà relative al minting. Il valore max_mint_quantity definisce il numero massimo di token che è possibile creare per la classe di token.
  • Owner – L'ID account del proprietario corrente, che è il chiamante del metodo.
  • Symbol: il simbolo del token. Proprietà non modificabile.
  • TokenDesc: la descrizione del token.
  • TokenMetadata: informazioni JSON che descrivono il token.
  • TokenName: il nome del token. Proprietà non modificabile.
  • TokenStandard: lo standard del token. Proprietà non modificabile.
  • TokenType – Il tipo di token (fungibile o non fungibile). Proprietà non modificabile.
  • TokenUnit – L'unità del token (intero o frazionario). Proprietà non modificabile.
  • TokenUri: l'URI del token.
  • Quantity: la quantità del token.
Esempio di valore restituito (NFT intero):
{
    "AssetType": "otoken",
    "Behaviors": [
        "indivisible",
        "singleton",
        "mintable",
        "transferable",
        "burnable",
        "roles"
    ],
    "CreatedBy": "oaccount~42e89f4c72dfde9502814876423c6da630d466e87436dd1aae201d347ad1288d",
    "CreationDate": "2022-12-29T09:57:03+05:30",
    "IsBurned": false,
    "Mintable": {
        "Max_mint_quantity": 500
    },
    "OnSaleFlag": false,
    "Owner": "oaccount~42e89f4c72dfde9502814876423c6da630d466e87436dd1aae201d347ad1288d",
    "Price": 100,
    "Quantity": 1,
    "Roles": {
        "burner_role_name": "burner",
        "minter_role_name": "minter"
    },
    "TokenDesc": "token description",
    "TokenId": "monalisa",
    "TokenMetadata": {
        "Description": "Mona Lisa Painting",
        "Image": "monalisa.jpeg",
        "PainterName": "Leonardo_da_Vinci",
        "PaintingName": "Mona_Lisa"
    },
    "TokenName": "artcollection",
    "TokenStandard": "erc1155+",
    "TokenType": "nonfungible",
    "TokenUnit": "whole",
    "TokenUri": "https://bafybeid6pmpp62bongoip5iy2skosvyxh3gr7r2e35x3ctvawjco6ddmsq\\\\ .ipfs.infura-ipfs.io/?filename=MonaLisa.jpeg"
}
Esempio di valore restituito (token fungibile):
{
    "AssetType": "otoken",
    "Behaviors": [
        "divisible",
        "mintable",
        "transferable",
        "burnable",
        "roles"
    ],
    "Currency_name": "Dollar",
    "Divisible": {
        "Decimal": 2
    },
    "Mintable": {
        "Max_mint_quantity": 10000
    },
    "Roles": {
        "burner_role_name": "burner",
        "minter_role_name": "minter"
    },
    "TokenDesc": "Token Description",
    "TokenId": "Loyalty",
    "TokenName": "loyalty",
    "TokenStandard": "erc1155+",
    "TokenType": "fungible",
    "TokenUnit": "fractional",
    "Token_to_currency_ratio": 0
}
Esempio di valore restituito (NFT frazionale):
{
    "AssetType": "otoken",
    "Behaviors": [
        "divisible",
        "mintable",
        "transferable",
        "burnable",
        "roles"
    ],
    "CreatedBy": "oaccount~42e89f4c72dfde9502814876423c6da630d466e87436dd1aae201d347ad1288d",
    "CreationDate": "2023-06-14T09:53:53+05:30",
    "Divisible": {
        "Decimal": 2
    },
    "IsBurned": false,
    "Mintable": {
        "Max_mint_quantity": 20000
    },
    "On_sale_flag": false,
    "Price": 1000,
    "Quantity": 100,
    "Roles": {
        "burner_role_name": "burner",
        "minter_role_name": "minter"
    },
    "TokenDesc": "Token Description",
    "TokenId": "realEstate",
    "TokenMetadata": {
        "Description": "Painting Description",
        "Image": "",
        "Painter_name": "",
        "Painting_name": "Paint"
    },
    "TokenName": "realestate",
    "TokenStandard": "erc1155+",
    "TokenType": "nonfungible",
    "TokenUnit": "fractional",
    "TokenUri": "www.realestate.example.com"
}
Update
Questo metodo aggiorna i token. Impossibile aggiornare i metadati del token o l'URI del token di token non fungibili.
Ctx.ERC1155Token.Update(tokenAsset interface{}) (interface{}, error)
Parametri:
  • tokenAsset: interface{}: asset del token. Le proprietà dell'asset sono definite nel file del modello.
Restituisce:
  • In caso di operazione riuscita, l'asset token aggiornato in formato JSON.
Esempio di valore restituito (NFT intero):
{
    "AssetType": "otoken",
    "Behaviors": [
        "indivisible",
        "singleton",
        "mintable",
        "transferable",
        "burnable",
        "roles"
    ],
    "CreatedBy": "oaccount~42e89f4c72dfde9502814876423c6da630d466e87436dd1aae201d347ad1288d",
    "CreationDate": "2022-12-29T09:57:03+05:30",
    "IsBurned": false,
    "Mintable": {
        "Max_mint_quantity": 500
    },
    "OnSaleFlag": false,
    "Owner": "oaccount~42e89f4c72dfde9502814876423c6da630d466e87436dd1aae201d347ad1288d",
    "Price": 100,
    "Quantity": 1,
    "Roles": {
        "burner_role_name": "burner",
        "minter_role_name": "minter"
    },
    "TokenDesc": "token description",
    "TokenId": "monalisa",
    "TokenMetadata": {
        "Description": "Mona Lisa Painting",
        "Image": "monalisa.jpeg",
        "PainterName": "Leonardo_da_Vinci",
        "PaintingName": "Mona_Lisa"
    },
    "TokenName": "artcollection",
    "TokenStandard": "erc1155+",
    "TokenType": "nonfungible",
    "TokenUnit": "whole",
    "TokenUri": "https://bafybeid6pmpp62bongoip5iy2skosvyxh3gr7r2e35x3ctvawjco6ddmsq\\\\ .ipfs.infura-ipfs.io/?filename=MonaLisa.jpeg"
}
History (Token)
Questo metodo restituisce la cronologia per un ID token specificato.
Ctx.ERC1155Token.History(tokenId string) (interface{}, error)
Parametri:
  • tokenId string: l'ID del token.
Restituisce:
  • In caso di operazione riuscita, un array JSON contenente la cronologia dei token.
Esempio di valore restituito (token fungibile):
[
  {
    "IsDelete": "false",
    "Timestamp": "2022-12-08T09:54:11Z",
    "TxId": "823sa7c7a00941c62285c86f922bc4d3f5326a20f4bf2f82daa5bc661e4682e8",
    "Value": {
      "AssetType": "otoken",
      "Behaviors": [
        "divisible",
        "mintable",
        "transferable",
        "roles"
      ],
      "Currency_name": "Rupees",
      "Divisible": {
        "Decimal": 2
      },
      "Mintable": {
        "Max_mint_quantity": 1000
      },
      "Roles": {
        "burner_role_name": "burner",
        "minter_role_name": "minter"
      },
      "TokenDesc": "Updated Token Description",
      "TokenId": "tokenOne",
      "TokenName": "moneytok",
      "TokenStandard": "erc1155+",
      "TokenType": "fungible",
      "TokenUnit": "fractional",
      "Token_to_currency_ratio": 0
    }
  },
  {
    "IsDelete": "false",
    "Timestamp": "2022-12-08T09:54:11Z",
    "TxId": "711bb7c7a00941c62285c86f922bc3b3f5326a20f4bf2f82daa5bc661e4682e8",
    "Value": {
      "AssetType": "otoken",
      "Behaviors": [
        "divisible",
        "mintable",
        "transferable",
        "roles"
      ],
      "Currency_name": "Dollar",
      "Divisible": {
        "Decimal": 2
      },
      "Mintable": {
        "Max_mint_quantity": 1000
      },
      "Roles": {
        "burner_role_name": "burner",
        "minter_role_name": "minter"
      },
      "TokenDesc": "",
      "TokenId": "tokenOne",
      "TokenName": "moneytok",
      "TokenStandard": "erc1155+",
      "TokenType": "fungible",
      "TokenUnit": "fractional",
      "Token_to_currency_ratio": 0
    }
  }
]
Esempio di valore restituito (NFT frazionale):
[
    {
        "Timestamp": "2023-06-20T01:06:33Z",
        "TrxId": "16e53db4f8107f9634b7c3a0a2a81a00f69b634f2a52902b809e544d07f272b1",
        "Value": {
            "AssetType": "otoken",
            "Behaviors": [
                "divisible",
                "mintable",
                "transferable",
                "burnable",
                "roles"
            ],
            "CreatedBy": "oaccount~87bcb699d507368ee3966cd03ee6d7736ffc55dde8c0f0e16b14866334ac504a",
            "CreationDate": "2023-06-20T01:02:27Z",
            "Divisible": {
                "Decimal": 2
            },
            "IsBurned": false,
            "Mintable": {
                "Max_mint_quantity": 20000
            },
            "On_sale_flag": true,
            "Owners": [
                {
                    "AccountId": "oaccount~87bcb699d507368ee3966cd03ee6d7736ffc55dde8c0f0e16b14866334ac504a",
                    "TokenShare": 10
                },
                {
                    "AccountId": "oaccount~3cddfdaa855900579d963aa6f755a4aed1f3a474a2462c1b45bd7f36df673224",
                    "TokenShare": 10
                }
            ],
            "Price": 2000,
            "Quantity": 20,
            "Roles": {
                "burner_role_name": "burner",
                "minter_role_name": "minter"
            },
            "TokenDesc": "",
            "TokenId": "FNFT",
            "TokenMetadata": {
                "Description": "",
                "Image": "",
                "Painter_name": "",
                "Painting_name": ""
            },
            "TokenName": "realestate",
            "TokenStandard": "erc1155+",
            "TokenType": "nonfungible",
            "TokenUnit": "fractional",
            "TokenUri": "www.FNFT.example.com"
        }
    },
    {
        "Timestamp": "2023-06-20T01:02:27Z",
        "TrxId": "cec80910d087682554048f911d2cf98b66382bbcf1615483fa1c96c7ea08077c",
        "Value": {
            "AssetType": "otoken",
            "Behaviors": [
                "divisible",
                "mintable",
                "transferable",
                "burnable",
                "roles"
            ],
            "CreatedBy": "oaccount~87bcb699d507368ee3966cd03ee6d7736ffc55dde8c0f0e16b14866334ac504a",
            "CreationDate": "2023-06-20T01:02:27Z",
            "Divisible": {
                "Decimal": 2
            },
            "IsBurned": false,
            "Mintable": {
                "Max_mint_quantity": 20000
            },
            "On_sale_flag": true,
            "Owners": [
                {
                    "AccountId": "oaccount~87bcb699d507368ee3966cd03ee6d7736ffc55dde8c0f0e16b14866334ac504a",
                    "TokenShare": 20
                }
            ],
            "Price": 2000,
            "Quantity": 20,
            "Roles": {
                "burner_role_name": "burner",
                "minter_role_name": "minter"
            },
            "TokenDesc": "",
            "TokenId": "FNFT",
            "TokenMetadata": {
                "Description": "",
                "Image": "",
                "Painter_name": "",
                "Painting_name": ""
            },
            "TokenName": "realestate",
            "TokenStandard": "erc1155+",
            "TokenType": "nonfungible",
            "TokenUnit": "fractional",
            "TokenUri": "www.FNFT.example.com"
        }
    }
]
Esempio di valore restituito (NFT intero):
[
    {
        "IsDelete": "false",
        "Timestamp": "2023-06-20T01:15:56Z",
        "TxId": "89a3df3ebbe6dca2bcfbd51fc7dca9aab818a2af746b79a92dc8155b729ab22d",
        "Value": {
            "AssetType": "otoken",
            "Behaviors": [
                "indivisible",
                "singleton",
                "mintable",
                "transferable",
                "roles"
            ],
            "CreatedBy": "oaccount~87bcb699d507368ee3966cd03ee6d7736ffc55dde8c0f0e16b14866334ac504a",
            "CreationDate": "2023-06-20T01:15:56Z",
            "IsBurned": false,
            "Mintable": {
                "Max_mint_quantity": 20000
            },
            "On_sale_flag": true,
            "Owner": "oaccount~87bcb699d507368ee3966cd03ee6d7736ffc55dde8c0f0e16b14866334ac504a",
            "Price": 2000,
            "Quantity": 1,
            "Roles": {
                "burner_role_name": "burner",
                "minter_role_name": "minter"
            },
            "TokenDesc": "Updated Token Description",
            "TokenId": "NFT",
            "TokenMetadata": {
                "Description": "",
                "Image": "",
                "Painter_name": "",
                "Painting_name": ""
            },
            "TokenName": "artcollection",
            "TokenStandard": "erc1155+",
            "TokenType": "nonfungible",
            "TokenUnit": "whole",
            "TokenUri": "www.NFT.example.com"
        }
    },
    {
        "IsDelete": "false",
        "Timestamp": "2023-06-20T01:15:56Z",
        "TxId": "90d6af3ebbe6dca2bcfbd51fc7dca9aab818a2af746b79a92dc8155b729ab22d",
        "Value": {
            "AssetType": "otoken",
            "Behaviors": [
                "indivisible",
                "singleton",
                "mintable",
                "transferable",
                "roles"
            ],
            "CreatedBy": "oaccount~87bcb699d507368ee3966cd03ee6d7736ffc55dde8c0f0e16b14866334ac504a",
            "CreationDate": "2023-06-20T01:15:56Z",
            "IsBurned": false,
            "Mintable": {
                "Max_mint_quantity": 20000
            },
            "On_sale_flag": true,
            "Owner": "oaccount~87bcb699d507368ee3966cd03ee6d7736ffc55dde8c0f0e16b14866334ac504a",
            "Price": 2000,
            "Quantity": 1,
            "Roles": {
                "burner_role_name": "burner",
                "minter_role_name": "minter"
            },
            "TokenDesc": "",
            "TokenId": "NFT",
            "TokenMetadata": {
                "Description": "",
                "Image": "",
                "Painter_name": "",
                "Painting_name": ""
            },
            "TokenName": "artcollection",
            "TokenStandard": "erc1155+",
            "TokenType": "nonfungible",
            "TokenUnit": "whole",
            "TokenUri": "www.NFT.example.com"
        }
    }
]
GetAllTokens
Questo metodo restituisce tutti gli asset token salvati nel database di stato. Questo metodo può essere chiamato solo da un Token Admin del codice concatenato. Questo metodo utilizza query avanzate SQL DB Berkeley e può essere richiamato solo quando si è connessi alla rete remota di Oracle Blockchain Platform.
Ctx.ERC1155Token.GetAllTokens()() (interface{}, error)
Parametri:
  • nessuno
Valore restituito
[
  {
    "key": "tokenOne",
    "valueJson": {
      "AssetType": "otoken",
      "Behaviors": [
        "divisible",
        "mintable",
        "transferable",
        "roles"
      ],
      "Currency_name": "",
      "Divisible": {
        "Decimal": 2
      },
      "Mintable": {
        "Max_mint_quantity": 1000
      },
      "Roles": {
        "burner_role_name": "burner",
        "minter_role_name": "minter"
      },
      "TokenDesc": "",
      "TokenId": "tokenOne",
      "TokenName": "moneytok",
      "TokenStandard": "erc1155+",
      "TokenType": "fungible",
      "TokenUnit": "fractional",
      "Token_to_currency_ratio": 0
    }
  },
  {
    "key": "tokenTwo",
    "valueJson": {
      "AssetType": "otoken",
      "Behaviors": [
        "divisible",
        "mintable",
        "transferable",
        "roles"
      ],
      "Currency_name": "",
      "Divisible": {
        "Decimal": 2
      },
      "Mintable": {
        "Max_mint_quantity": 1000
      },
      "Roles": {
        "burner_role_name": "burner",
        "minter_role_name": "minter"
      },
      "TokenDesc": "",
      "TokenId": "tokenTwo",
      "TokenName": "moneytok",
      "TokenStandard": "erc1155+",
      "TokenType": "fungible",
      "TokenUnit": "fractional",
      "Token_to_currency_ratio": 0
    }
  },
  {
    "key": "art",
    "valueJson": {
      "AssetType": "otoken",
      "Behaviors": [
        "indivisible",
        "singleton",
        "mintable",
        "transferable",
        "burnable",
        "roles"
      ],
      "BurnedBy": "oaccount~76cb672eeb1bd535899562a840d0c15a356db89e24bc8b43ac1dba845a4282c6",
      "BurnedDate": "2022-12-08T10:49:37Z",
      "CreatedBy": "oaccount~76cb672eeb1bd535899562a840d0c15a356db89e24bc8b43ac1dba845a4282c6",
      "CreationDate": "2022-12-08T10:45:10Z",
      "IsBurned": true,
      "Mintable": {
        "Max_mint_quantity": 20000
      },
      "OnSaleFlag": false,
      "Owner": "",
      "Price": 0,
      "Roles": {
        "minter_role_name": "minter"
      },
      "TokenDesc": "",
      "TokenId": "art",
      "TokenMetadata": {
        "Description": "",
        "Image": "",
        "PainterName": "",
        "PaintingName": ""
      },
      "TokenName": "artcollection",
      "TokenStandard": "erc1155+",
      "TokenType": "nonfungible",
      "TokenUnit": "whole",
      "TokenUri": "art.example.com",
      "TransferredBy": "ouaccount~24ffd4d32a028a85b4b960f5d55536c837b5429bc7f346150adfa904ec2937cc",
      "TransferredDate": "2022-12-08T10:47:04Z"
    }
  },
  {
    "key": "FNFT",
    "valueJson": {
        "AssetType": "otoken",
        "Behaviors": [
            "divisible",
            "mintable",
            "transferable",
            "burnable",
            "roles"
        ],
        "CreatedBy": "oaccount~87bcb699d507368ee3966cd03ee6d7736ffc55dde8c0f0e16b14866334ac504a",
        "CreationDate": "2023-06-20T01:02:27Z",
        "Divisible": {
            "Decimal": 2
        },
        "IsBurned": false,
        "Mintable": {
            "Max_mint_quantity": 20000
        },
        "On_sale_flag": true,
        "Price": 2000,
        "Quantity": 20,
        "Roles": {
            "burner_role_name": "burner",
            "minter_role_name": "minter"
        },
        "TokenDesc": "",
        "TokenId": "FNFT",
        "TokenMetadata": {
            "Description": "",
            "Image": "",
            "Painter_name": "",
            "Painting_name": ""
        },
        "TokenName": "realestate",
        "TokenStandard": "erc1155+",
        "TokenType": "nonfungible",
        "TokenUnit": "fractional",
        "TokenUri": "www.FNFT.example.com"
    }
  },
  {
    "key": "FNFT",
    "valueJson": {
        "AssetType": "otoken",
        "Behaviors": [
            "divisible",
            "mintable",
            "transferable",
            "burnable",
            "roles"
        ],
        "CreatedBy": "oaccount~87bcb699d507368ee3966cd03ee6d7736ffc55dde8c0f0e16b14866334ac504a",
        "CreationDate": "2023-06-20T01:02:27Z",
        "Divisible": {
            "Decimal": 2
        },
        "IsBurned": false,
        "Mintable": {
            "Max_mint_quantity": 20000
        },
        "On_sale_flag": true,
        "Price": 2000,
        "Quantity": 20,
        "Roles": {
            "burner_role_name": "burner",
            "minter_role_name": "minter"
        },
        "TokenDesc": "",
        "TokenId": "FNFT",
        "TokenMetadata": {
            "Description": "",
            "Image": "",
            "Painter_name": "",
            "Painting_name": ""
        },
        "TokenName": "realestate",
        "TokenStandard": "erc1155+",
        "TokenType": "nonfungible",
        "TokenUnit": "fractional",
        "TokenUri": "www.FNFT.example.com"
    }
  }
]
Get (Token)
Questo metodo restituisce un oggetto token se il token è presente nel database di stato. Questo metodo può essere chiamato solo da un Token Admin del codice concatenato o dal proprietario del token. Per i NFT frazionari, viene restituito anche l'elenco dei proprietari.
Ctx.ERC1155Token.Get(id string, result ...interface{}) (interface{}, error)
Parametri:
  • id string: l'ID del token da ottenere.
Esempio di valore restituito (NFT intero):
{
  "AssetType": "otoken",
  "Behaviors": [
    "indivisible",
    "singleton",
    "mintable",
    "transferable",
    "burnable",
    "roles"
  ],
  "CreatedBy": "oaccount~76cb672eeb1bd535899562a840d0c15a356db89e24bc8b43ac1dba845a4282c6",
  "CreationDate": "2022-12-08T10:55:29Z",
  "IsBurned": false,
  "Mintable": {
    "Max_mint_quantity": 20000
  },
  "OnSaleFlag": false,
  "Owner": "oaccount~76cb672eeb1bd535899562a840d0c15a356db89e24bc8b43ac1dba845a4282c6",
  "Price": 0,
  "Quantity": 1,
  "Roles": {
    "minter_role_name": "minter"
  },
  "TokenDesc": "",
  "TokenId": "nftToken",
  "TokenMetadata": {
    "Description": "",
    "Image": "",
    "PainterName": "",
    "PaintingName": ""
  },
  "TokenName": "artcollection",
  "TokenStandard": "erc1155+",
  "TokenType": "nonfungible",
  "TokenUnit": "whole",
  "TokenUri": "example.com"
}
Esempio di valore restituito (token fungibile):
{
    "AssetType": "otoken",
    "Behaviors": [
        "divisible",
        "mintable",
        "transferable",
        "burnable",
        "roles"
    ],
    "Currency_name": "Dollar",
    "Divisible": {
        "Decimal": 2
    },
    "Mintable": {
        "Max_mint_quantity": 10000
    },
    "Roles": {
        "burner_role_name": "burner",
        "minter_role_name": "minter"
    },
    "TokenDesc": "Token Description",
    "TokenId": "Loyalty",
    "TokenName": "loyalty",
    "TokenStandard": "erc1155+",
    "TokenType": "fungible",
    "TokenUnit": "fractional",
    "Token_to_currency_ratio": 0
}
Esempio di valore restituito (NFT frazionale):
{
    "AssetType": "otoken",
    "Behaviors": [
        "divisible",
        "mintable",
        "transferable",
        "burnable",
        "roles"
    ],
    "CreatedBy": "oaccount~42e89f4c72dfde9502814876423c6da630d466e87436dd1aae201d347ad1288d",
    "CreationDate": "2023-06-14T09:53:53+05:30",
    "Divisible": {
        "Decimal": 2
    },
    "IsBurned": false,
    "Mintable": {
        "Max_mint_quantity": 20000
    },
    "On_sale_flag": false,
    "Owners": [
        {
            "AccountId": "oaccount~42e89f4c72dfde9502814876423c6da630d466e87436dd1aae201d347ad1288d",
            "TokenShare": 100
        }
    ],
    "Price": 1000,
    "Quantity": 100,
    "Roles": {
        "burner_role_name": "burner",
        "minter_role_name": "minter"
    },
    "TokenDesc": "Token Description",
    "TokenId": "realEstate",
    "TokenMetadata": {
        "Description": "Painting Description",
        "Image": "",
        "Painter_name": "",
        "Painting_name": "Paint"
    },
    "TokenName": "realestate",
    "TokenStandard": "erc1155+",
    "TokenType": "nonfungible",
    "TokenUnit": "fractional",
    "TokenUri": "www.realestate.example.com"
}
GetAllTokensByUser
Questo metodo restituisce tutti gli asset token di proprietà di un utente specificato. Questo metodo utilizza query avanzate SQL DB Berkeley e può essere richiamato solo quando si è connessi alla rete remota di Oracle Blockchain Platform.
Ctx.ERC1155Token.GetAllTokensByUser(accountId string) (interface{}, error)
Parametri:
  • accountId string: l'ID account dell'utente.
Valore restituito
[
  {
    "key": "tokenOne",
    "valueJson": {
      "AssetType": "otoken",
      "Behaviors": [
        "divisible",
        "mintable",
        "transferable",
        "roles"
      ],
      "Currency_name": "",
      "Divisible": {
        "Decimal": 2
      },
      "Mintable": {
        "Max_mint_quantity": 1000
      },
      "Roles": {
        "burner_role_name": "burner",
        "minter_role_name": "minter"
      },
      "TokenDesc": "",
      "TokenId": "tokenOne",
      "TokenName": "moneytok",
      "TokenStandard": "erc1155+",
      "TokenType": "fungible",
      "TokenUnit": "fractional",
      "Token_to_currency_ratio": 0
    }
  },
  {
    "key": "nftToken",
    "valueJson": {
      "AssetType": "otoken",
      "Behaviors": [
        "indivisible",
        "singleton",
        "mintable",
        "transferable",
        "burnable",
        "roles"
      ],
      "CreatedBy": "oaccount~76cb672eeb1bd535899562a840d0c15a356db89e24bc8b43ac1dba845a4282c6",
      "CreationDate": "2022-12-08T10:55:29Z",
      "IsBurned": false,
      "Mintable": {
        "Max_mint_quantity": 20000
      },
      "OnSaleFlag": false,
      "Owner": "oaccount~76cb672eeb1bd535899562a840d0c15a356db89e24bc8b43ac1dba845a4282c6",
      "Price": 0,
      "Quantity": 1,
      "Roles": {
        "minter_role_name": "minter"
      },
      "TokenDesc": "",
      "TokenId": "nftToken",
      "TokenMetadata": {
        "Description": "",
        "Image": "",
        "PainterName": "",
        "PaintingName": ""
      },
      "TokenName": "artcollection",
      "TokenStandard": "erc1155+",
      "TokenType": "nonfungible",
      "TokenUnit": "whole",
      "TokenUri": "example.com"
    }
  }
]
OwnerOf
Questo metodo restituisce l'ID account, l'ID organizzazione e l'ID utente del proprietario dell'ID token specificato.
Ctx.ERC1155Token.OwnerOf(tokenId string) (interface{}, error)
Parametri:
  • tokenId string: l'ID del token.
Valore restituito
{
  "AccountId": "oaccount~76cb672eeb1bd535899562a840d0c15a356db89e24bc8b43ac1dba845a4282c6",
  "OrgId": "appdev",
  "UserId": "idcqa"
}
TokenURI
Questo metodo restituisce l'URI di un token specificato. Chiunque può chiamare questo metodo.
Ctx.ERC1155Token.TokenURI(tokenId string) (interface{}, error)
Parametri:
  • tokenId string: l'ID del token.
Valore restituito
{
    "TokenUri": "example.com"
}
Name
Questo metodo restituisce il nome della classe token. Chiunque può chiamare questo metodo.
Ctx.ERC1155Token.Name(tokenId string) (interface{}, error)
Parametri:
  • tokenId string: l'ID del token.
Valore restituito
{"TokenName": "artcollection"}
TotalSupply
Questo metodo restituisce il numero totale di token coniati. I token fungibili vengono specificati dall'ID token. I token non fungibili sono specificati dal nome token.
Ctx.ERC1155Token.TotalSupply(tokenAsset interface{}) (map[string]interface{}, error)
Parametri:
  • tokenAsset interface{}: asset del token.
Valore restituito
{"TotalSupply": 100}
TotalNetSupply
Questo metodo restituisce il numero totale di token coniati meno il numero di token bruciati. I token fungibili vengono specificati dall'ID token. I token non fungibili sono specificati dal nome token.
Ctx.ERC1155Token.TotalNetSupply(token interface{}) (interface{}, error)
Parametri:
  • token interface{}: asset del token.
Valore restituito
{"TotalNetSupply": 100}
GetTokensByName
Questo metodo restituisce tutti gli asset token per un nome token specificato. Questo metodo utilizza query avanzate SQL DB Berkeley e può essere richiamato solo quando si è connessi alla rete remota di Oracle Blockchain Platform.
Ctx.ERC1155Token.GetTokensByName(tokenName string) (interface{}, error)
Parametri:
  • tokenName: string: il nome del token.
Valore restituito
[
  {
    "key": "tokenOne",
    "valueJson": {
      "AssetType": "otoken",
      "Behaviors": [
        "divisible",
        "mintable",
        "transferable",
        "roles"
      ],
      "Currency_name": "",
      "Divisible": {
        "Decimal": 2
      },
      "Mintable": {
        "Max_mint_quantity": 1000
      },
      "Roles": {
        "burner_role_name": "burner",
        "minter_role_name": "minter"
      },
      "TokenDesc": "",
      "TokenId": "tokenOne",
      "TokenName": "moneytok",
      "TokenStandard": "erc1155+",
      "TokenType": "fungible",
      "TokenUnit": "fractional",
      "Token_to_currency_ratio": 0
    }
  },
  {
    "key": "tokenTwo",
    "valueJson": {
      "AssetType": "otoken",
      "Behaviors": [
        "divisible",
        "mintable",
        "transferable",
        "roles"
      ],
      "Currency_name": "",
      "Divisible": {
        "Decimal": 2
      },
      "Mintable": {
        "Max_mint_quantity": 1000
      },
      "Roles": {
        "burner_role_name": "burner",
        "minter_role_name": "minter"
      },
      "TokenDesc": "",
      "TokenId": "tokenTwo",
      "TokenName": "moneytok",
      "TokenStandard": "erc1155+",
      "TokenType": "fungible",
      "TokenUnit": "fractional",
      "Token_to_currency_ratio": 0
    }
  }
]
GetDecimals
Questo metodo restituisce il numero di posizioni decimali per un token specificato. Se il comportamento divisibile non è specificato per il token, viene restituito il valore predefinito di zero posizioni decimali.
Ctx.ERC1155Token.GetDecimals(tokenId string) (int, error)
Parametri:
  • tokenId: string: l'ID del token.
Valore restituito
2

Metodi per la gestione degli account

CreateAccount
Questo metodo crea un account per un utente specificato e account token associati per token fungibili o non fungibili. È necessario creare un account per qualsiasi utente che avrà token in qualsiasi momento. L'account utente tiene traccia dell'account NFT e degli account token fungibili di cui dispone un utente. Gli utenti devono disporre di account nella rete per completare le operazioni correlate al token. Questo metodo può essere chiamato solo da un Token Admin del codice concatenato.

Un account utente ha un ID univoco, formato da un hash SHA-256 del parametro orgId e del parametro userId.

Un utente può avere più account token fungibili con ID account univoci. Gli ID account token fungibili sono formati da un hash SHA-256 del parametro orgId, il parametro userId, la stringa costante ft separata dal simbolo tilde (~) e un numero contatore che indica l'indice del conto fungibile che viene creato separato dal simbolo tilde (~).

Un utente può avere un solo account token non fungibile. Gli ID account token non fungibili sono univoci e sono formati da un hash SHA-256 del parametro orgId, del parametro userId e della stringa costante nft separati dal simbolo tilde (~). Tutti i token non fungibili di proprietà di un utente, siano essi interi o frazionari, sono collegati a questo singolo account token non fungibile.

Ctx.ERC1155Account.CreateAccount(orgId string, userId string, ftAccount bool, nftAccount bool) (ERC1155UserAccount, error)
Parametri:
  • orgId string - L'ID MSP (Membership Service Provider) dell'utente nell'organizzazione corrente.
  • userId string: il nome utente o l'ID e-mail dell'utente.
  • ftAccount bool: se true, viene creato un account token fungibile associato all'account utente.
  • nftAccount bool – Se true, viene creato un account token non fungibile e associato all'account utente.
Restituisce:
  • In caso di operazione riuscita, un oggetto JSON dell'account creato.
Valore restituito
{
  "AssetType": "ouaccount",
  "AccountId": "ouaccount~cf20877546f52687f387e7c91d88b9722c97e1a456cc0484f40c747f7804feae",
  "UserId": "user1",
  "OrgId": "appdev",
  "TotalAccounts": 2,
  "TotalFtAccounts": 1,
  "AssociatedFtAccounts": [
    {
      "AccountId": "oaccount~60bb20c14a83f6e426e1437c479c5891e1c6477dfd7ad18b73acac5d80bc504b",
      "TokenId": ""
    }
  ],
  "AssociatedNftAccount": "oaccount~73c3e835dac6d0a56ca9d8def08269f83cefd59b9d297fe2cdc5a9083828fa58"
}
CreateUserAccount
Questo metodo crea un account per un utente specificato. È necessario creare un account per qualsiasi utente che avrà token in qualsiasi momento. L'account utente tiene traccia dell'account NFT e degli account token fungibili di cui dispone un utente. Gli utenti devono disporre di account nella rete per completare le operazioni correlate al token.

Un ID account è un hash SHA-256 del parametro orgId e del parametro userId. Questo metodo può essere chiamato solo da un Token Admin del codice concatenato.

Ctx.ERC1155Account.CreateUserAccount(orgId string, userId string) (interface{}, error)
Parametri:
  • orgId string - L'ID MSP (Membership Service Provider) dell'utente nell'organizzazione corrente.
  • userId string: il nome utente o l'ID e-mail dell'utente.
Restituisce:
  • In caso di operazione riuscita, un oggetto JSON dell'account utente creato.
Valore restituito
{
  "AssetType": "ouaccount",
  "AccountId": "ouaccount~24ffd4d32a028a85b4b960f5d55536c837b5429bc7f346150adfa904ec2937cc",
  "UserId": "idcqa",
  "OrgId": "appdev",
  "TotalAccounts": 0,
  "TotalFtAccounts": 0,
  "AssociatedFtAccounts": [],
  "AssociatedNftAccount": ""
}
CreateTokenAccount
Questo metodo crea un account token fungibile o non fungibile da associare a un account utente.

Un utente può avere più account token fungibili con ID account univoci. Gli ID account token fungibili sono formati da un hash SHA-256 del parametro orgId, il parametro userId, la stringa costante ft separata dal simbolo tilde (~) e un numero contatore che indica l'indice del conto fungibile che viene creato separato dal simbolo tilde (~).

Un utente può avere un solo account token non fungibile. Gli ID account token non fungibili sono univoci e sono formati da un hash SHA-256 del parametro orgId, del parametro userId e della stringa costante nft separati dal simbolo tilde (~). Tutti i token non fungibili di proprietà di un utente, siano essi interi o frazionari, sono collegati a questo singolo account token non fungibile.

Questo metodo può essere chiamato solo da un Token Admin del codice concatenato.

Ctx.ERC1155Account.CreateTokenAccount(orgId string, userId string, tokenType string) (ERC1155UserAccount, error)
Parametri:
  • orgId string - L'ID MSP (Membership Service Provider) dell'utente nell'organizzazione corrente.
  • userId string: il nome utente o l'ID e-mail dell'utente.
  • tokenType erc1155Token.TokenType: il tipo di account token da creare. Gli unici tipi di token supportati sono nonfungible e fungible.
Restituisce:
  • In caso di operazione riuscita, un oggetto JSON dell'account token creato.
Valore restituito
{
    "AssetType": "ouaccount",
    "AccountId": "ouaccount~24ffd4d32a028a85b4b960f5d55536c837b5429bc7f346150adfa904ec2937cc",
    "UserId": "idcqa",
    "OrgId": "appdev",
    "TotalAccounts": 1,
    "TotalFtAccounts": 1,
    "AssociatedFtAccounts": [
        {
            "AccountId": "oaccount~1422a74d262a3a55a37cd9023ef8836f765d0be7b49d397696b9961d7434d22a",
            "TokenId": ""
        }
    ],
    "AssociatedNftAccount": ""
}
AssociateTokenToToken
Questo metodo associa l'account token fungibile di un utente a un token fungibile particolare.
Ctx.ERC1155Account.AssociateTokenToToken(accountId string, tokenId string) (interface{}, error)
Parametri:
  • accountId string: ID dell'account utente.
  • tokenId string: l'ID del token.
Restituisce:
  • In caso di operazione riuscita, un oggetto JSON dell'account utente, che mostra che il token fungibile è stato associato all'account token. Ad esempio, nell'esempio seguente, il primo oggetto nell'array AssociatedFtAccounts mostra che l'ID account token fungibile e l'ID token sono associati.
Valore restituito
{
    "AssetType": "ouaccount",
    "AccountId": "ouaccount~24ffd4d32a028a85b4b960f5d55536c837b5429bc7f346150adfa904ec2937cc",
    "UserId": "idcqa",
    "OrgId": "appdev",
    "TotalAccounts": 1,
    "TotalFtAccounts": 1,
    "AssociatedFtAccounts": [
        {
            "AccountId": "oaccount~1422a74d262a3a55a37cd9023ef8836f765d0be7b49d397696b9961d7434d22a",
            "TokenId": "tokenOne"
        }
    ],
    "AssociatedNftAccount": ""
}
GetAccountHistory
Questo metodo restituisce la cronologia per un account token specificato.
Ctx.ERC1155Account.GetAccountHistory(accountId string)
Parametri:
  • accountId string: ID dell'account token.
Restituisce:
  • In caso di operazione riuscita, un array di oggetti JSON che descrive la cronologia dell'account.
Valore restituito
[
    {
        "IsDelete": "false",
        "Timestamp": "2023-06-06T11:03:48Z",
        "TxId": "c5180f3be3d9130f25a4b4e866f38a4283117dcbfbffb4f55e2c5b03dba0dd29",
        "Value": {
            "AccountCategory": "",
            "AccountId": "oaccount~21206f309941a2a23c4f158a0fe1b8f12bb8e2b0c9a2e1358f5efebc0c7d410e",
            "AssetType": "oaccount",
            "Balance": 100,
            "BapAccountVersion": 1
            "OrgId": "appdev",
            "TokenId": "loy1",
            "TokenName": "loyalty",
            "TokenType": "fungible",
            "UserId": "idcqa"
        }
    },
    {
        "IsDelete": "false",
        "Timestamp": "2023-06-06T11:02:39Z",
        "TxId": "6f81b0c94b451d375a3892446aefbdf78d9fd1ac43699daa89f0dff10db5fd22",
        "Value": {
            "AccountCategory": "",
            "AccountId": "oaccount~21206f309941a2a23c4f158a0fe1b8f12bb8e2b0c9a2e1358f5efebc0c7d410e",
            "AssetType": "oaccount",
            "Balance": 0,
            "BapAccountVersion": 0
            "OrgId": "appdev",
            "TokenId": "loy1",
            "TokenName": "loyalty",
            "TokenType": "fungible",
            "UserId": "idcqa"
        }
    },
    {
        "IsDelete": "false",
        "Timestamp": "2023-06-05T16:28:46Z",
        "TxId": "8185af648546e909488e72149be497b210f74f95ada252c42da9c35cb9d98691",
        "Value": {
            "AccountCategory": "",
            "AccountId": "oaccount~21206f309941a2a23c4f158a0fe1b8f12bb8e2b0c9a2e1358f5efebc0c7d410e",
            "AssetType": "oaccount",
            "Balance": 0,
            "BapAccountVersion": 0
            "OrgId": "appdev",
            "TokenId": "",
            "TokenName": "",
            "TokenType": "fungible",
            "UserId": "idcqa"
        }
    }
]
GetAccountWithStatus
Questo metodo restituisce i dettagli dell'account token per un utente specificato, incluso lo stato dell'account. Questo metodo può essere chiamato solo da un Token Admin del codice concatenato o dal Account Owner dell'account.
Ctx.ERC1155Account.GetAccountWithStatus(userAccountId string, tokenId ...string) (interface{}, error)
Parametri:
  • userAccountId string: l'ID account dell'utente.
  • tokenId ...string – Per un account token non fungibile, una stringa vuota. Per un account token fungibile, l'ID token.
Restituisce:
  • In caso di operazione riuscita, un oggetto JSON che include i dettagli dell'account token, incluso lo stato dell'account.
Esempio di valore restituito (conto token non fungibile):
{
    "AccountId": "oaccount~cc301bee057f14236a97d434909ec1084970921b008f6baab09c2a0f5f419a9a",
    "AssetType": "oaccount",
    "BapAccountVersion": 1,
    "NoOfNfts": 1,
    "OrgId": "appdev",
    "Status": "active",
    "TokenType": "nonfungible",
    "UserId": "idcqa"
}
Esempio di valore restituito (account token fungibile):
{
    "AccountCategory": "",
    "AccountId": "oaccount~2de8db6b91964f8c9009136831126d3cfa94e1d00c4285c1ea3e6d1f36479ed4",
    "AssetType": "oaccount",
    "Balance": 0,
    "BapAccountVersion": 0,
    "OrgId": "appdev",
    "Status": "active",
    "TokenId": "t1",
    "TokenName": "loyalty",
    "TokenType": "fungible",
    "UserId": "idcqa"
}
GetAccount
Questo metodo restituisce i dettagli dell'account token per un utente specificato. Questo metodo può essere chiamato solo da un Token Admin del codice concatenato o dal Account Owner dell'account.
Ctx.ERC1155Account.Get(accountId string, tokenId ...string) (interface{}, error) 
Parametri:
  • userAccountId string: l'ID account dell'utente.
  • tokenId ...string – Per un account token non fungibile, una stringa vuota. Per un account token fungibile, l'ID token.
Restituisce:
  • In caso di operazione riuscita, un oggetto JSON che include i dettagli dell'account token.
Esempio di valore restituito (conto token non fungibile):
{
    "AccountId": "oaccount~e88276a3be547e31b567346bdddde52d37734da4d5fae83ab2e5c98a10097371",
    "BapAccountVersion": 0,
    "AssetType": "oaccount",
    "NoOfNfts": 4,
    "OrgId": "appdev",
    "TokenType": "nonfungible",
    "UserId": "idcqa"
}
Esempio di valore restituito (account token fungibile):
{
    "AssetType": "oaccount",
    "AccountId": "oaccount~21206f309941a2a23c4f158a0fe1b8f12bb8e2b0c9a2e1358f5efebc0c7d410e",
    "UserId": "idcqa",
    "OrgId": "appdev",
    "BapAccountVersion": 0,
    "TokenType": "fungible",
    "TokenId": "loy1",
    "TokenName": "loyalty",
    "Balance": 90,
    "AccountCategory": ""
}
GetAllAccounts
Questo metodo restituisce i dettagli di tutti gli account utente.
Ctx.ERC1155Account.GetAllAccounts() (interface{}, error)
Parametri:
  • nessuno
Valore restituito
[
    {
        "AssetType": "ouaccount",
        "AccountId": "ouaccount~412de5e3998dcd100973e1bad6e8729fddc1c7ff610beab8376d733a35c51f38",
        "UserId": "idcqa",
        "OrgId": "appdev",
        "TotalAccounts": 3,
        "TotalFtAccounts": 2,
        "AssociatedFtAccounts": [
            {
                "AccountId": "oaccount~21206f309941a2a23c4f158a0fe1b8f12bb8e2b0c9a2e1358f5efebc0c7d410e",
                "TokenId": "loy1"
            },
            {
                "AccountId": "oaccount~58c5a6b09a41befca2a9ea2550439838c4dcf4d8a2a4f7c98e9319cf8479bfc4",
                "TokenId": ""
            }
        ],
        "AssociatedNftAccount": "oaccount~e88276a3be547e31b567346bdddde52d37734da4d5fae83ab2e5c98a10097371"
    },
    {
        "AssetType": "ouaccount",
        "AccountId": "ouaccount~9501bb774c156eb8354dfe489250ea91f757523d70f08ee494bda98bb352003b",
        "UserId": "user1_minter",
        "OrgId": "appdev",
        "TotalAccounts": 2,
        "TotalFtAccounts": 1,
        "AssociatedFtAccounts": [
            {
                "AccountId": "oaccount~1089ee5122f367ee0ca38c6660298f4b81f199627e4f67f3691c0f628237974c",
                "TokenId": "loy1"
            }
        ],
        "AssociatedNftAccount": "oaccount~dcee860665db8740cb77b846e823752185a1e9a185814d0acb305890f5903446"
    },
]
GetAccountDetailsByUser
Questo metodo restituisce un riepilogo dell'account per un utente specificato e i dettagli dei token fungibili e non fungibili associati all'utente.
Ctx.ERC1155Account.GetAccountDetailsByUser(orgId string, userId string) (interface{}, error)
Parametri:
  • orgId string - L'ID MSP (Membership Service Provider) dell'utente nell'organizzazione corrente.
  • userId string: il nome utente o l'ID e-mail dell'utente.
Restituisce:
  • In caso di operazione riuscita, un oggetto account JSON che include e il riepilogo dell'account per l'utente specificato e i dettagli dei token fungibili e non fungibili associati all'utente. Per i token non fungibili frazionari, la proprietà tokenShare nella sezione associatedNFTs mostra la condivisione di proprietà dell'utente.
Valore restituito
{
    "AssociatedFTAccounts": [
        {
            "AccountId": "oaccount~21206f309941a2a23c4f158a0fe1b8f12bb8e2b0c9a2e1358f5efebc0c7d410e",
            "Balance": 90,
            "TokenId": "FT"
        },
    ],
    "AssociatedNFTAccount": {
        "AccountId": "oaccount~e88276a3be547e31b567346bdddde52d37734da4d5fae83ab2e5c98a10097371",
        "AssociatedNFTs": [
            {
                "NFTTokenId": "FNFT",
                "TokenShare": 230
            },
            {
                "NFTTokenId": "NFT"
            },
            {
                "NFTTokenId": "NFT2"
            }
        ]
    },
    "UserAccountId": "ouaccount~412de5e3998dcd100973e1bad6e8729fddc1c7ff610beab8376d733a35c51f38"
}
GetUserByAccountId
Questo metodo restituisce i dettagli utente di un ID account specificato.
Ctx.ERC1155Account.GetUserByAccountById(accountId string) (map[string]interface{}, error)
Parametri:
  • accountId string – L'ID dell'account.
Restituisce:
  • In caso di operazione riuscita, un oggetto JSON dei dettagli utente (orgId e userId).
Valore restituito
{
    "OrgId": "appdev",
    "UserId": "idcqa"
}

Metodi per gestione ruoli

AddRoleMember
Questo metodo aggiunge un ruolo a un utente e a un token specificati. I token fungibili vengono specificati dall'ID token. I token non fungibili sono specificati dal nome token.
Ctx.ERC1155Token.AddRoleMember(userRole string, userAccountId string, asset interface{}) (interface{}, error)
Parametri:
  • userRole: string: il nome del ruolo da aggiungere all'utente specificato.
  • userAccountId: string: l'ID account dell'utente.
  • asset: interface{}: asset del token.
Restituisce:
  • In caso di successo, un messaggio con i dettagli dell'account.
Valore restituito
{
    "msg": "Successfully added role minter to oaccount~1422a74d262a3a55a37cd9023ef8836f765d0be7b49d397696b9961d7434d22a (orgId : appdev, userId : idcqa)"
}
IsInRole
Questo metodo restituisce un valore booleano per indicare se un utente dispone di un ruolo specificato. I token fungibili vengono specificati dall'ID token. I token non fungibili sono specificati dal nome token.
Ctx.ERC1155Token.IsInRole(userRole string, userAccountId string, asset interface{}) (bool, error)
Parametri:
  • userRole: string: il nome del ruolo da cercare.
  • userAccountId: string: l'ID account dell'utente.
  • asset: interface{}: asset del token.
Valore restituito
{
    "result": true
}
RemoveRoleMember
Questo metodo rimuove un ruolo da un utente e da un token specificati. I token fungibili vengono specificati dall'ID token. I token non fungibili sono specificati dal nome token.
Ctx.ERC1155Token.RemoveRoleMember(userRole string, userAccountId string, asset interface{}) (interface{}, error) 
Parametri:
  • userRole: string: il nome del ruolo da rimuovere.
  • userAccountId: string: l'ID account dell'utente.
  • asset: interface{}: asset del token.
Valore restituito
{
    "msg": "Successfully removed role 'minter' from Account Id: oaccount~ec7e4de2f81e3ea071710e07b6ff7d9346e84ef665ca4650885dbe8c3e2bd4c0 (Org-Id: appdev, User-Id: idcqa)"
}
GetAccountsByRole
Questo metodo restituisce un elenco di tutti gli ID account per un ruolo e un token specificati. I token fungibili vengono specificati dall'ID token. I token non fungibili sono specificati dal nome token.
Ctx.ERC1155Role.GetAccountsByRole(roleName string, token interface{}) (interface{}, error)
Parametri:
  • roleName: string: il nome del ruolo da cercare.
  • token: interface{}: asset del token.
Valore restituito
{
    "accounts": [
        "oaccount~1422a74d262a3a55a37cd9023ef8836f765d0be7b49d397696b9961d7434d22a",
        "oaccount~60bb20c14a83f6e426e1437c479c5891e1c6477dfd7ad18b73acac5d80bc504b"
    ]
}
GetUsersByRole
Questo metodo restituisce un elenco di tutti gli utenti per un ruolo e un token specificati. I token fungibili vengono specificati dall'ID token. I token non fungibili sono specificati dal nome token.
Ctx.ERC1155Role.GetUsersByRole(roleName string, token interface{}) (interface{}, error)
Parametri:
  • roleName: string: il nome del ruolo da cercare.
  • token: interface{}: asset del token.
Valore restituito
{
    "Users": [
        {
            "AccountId": "oaccount~1422a74d262a3a55a37cd9023ef8836f765d0be7b49d397696b9961d7434d22a",
            "OrgId": "appdev",
            "UserId": "idcqa"
        },
        {
            "AccountId": "oaccount~60bb20c14a83f6e426e1437c479c5891e1c6477dfd7ad18b73acac5d80bc504b",
            "OrgId": "appdev",
            "UserId": "user1"
        }
    ]
}

Metodi per gestione cronologia transazioni

GetAccountTransactionHistory
Questo metodo restituisce la cronologia delle transazioni del conto. Questo metodo può essere chiamato solo da un Token Admin del codice concatenato o dal proprietario dell'account. Per i token non fungibili, questo metodo può essere richiamato solo quando è connesso alla rete remota di Oracle Blockchain Platform.
Ctx.ERC1155Account.GetAccountTransactionHistory(tokenAccountId string) (interface{}, error)
Parametri:
  • accountId string: ID dell'account utente.
Valore restituito
[
    {
        "Balance": 90,
        "Timestamp": "2023-06-06T11:11:09Z",
        "TokenId": "FNFT",
        "TransactedAccount": "oaccount~dcee860665db8740cb77b846e823752185a1e9a185814d0acb305890f5903446",
        "TransactedAmount": 10,
        "TransactionId": "otransaction~0f4d96fbf8fed88ea8a3133428977721091467c701848d595ebc3fffa88b3657~7c88c736df38d5622512f1e8dcdd50710eb47c953f1ecb24ac44790a9e2f475b",
        "TransactionType": "DEBIT",
        "TriggeredByUserAccountId": "ouaccount~412de5e3998dcd100973e1bad6e8729fddc1c7ff610beab8376d733a35c51f38"
    },
    {
        "Timestamp": "2023-06-06T11:11:09Z",
        "TokenId": "NFT",
        "TransactedAccount": "oaccount~dcee860665db8740cb77b846e823752185a1e9a185814d0acb305890f5903446",
        "TransactionId": "otransaction~0f4d96fbf8fed88ea8a3133428977721091467c701848d595ebc3fffa88b3657~178e3730bc5bee50d02f1464a4eebf733a051905f651e5789039adb4a3edc114",
        "TransactionType": "DEBIT",
        "TriggeredByUserAccountId": "ouaccount~412de5e3998dcd100973e1bad6e8729fddc1c7ff610beab8376d733a35c51f38"
    },
    {
        "Timestamp": "2023-06-06T11:06:54Z",
        "TokenId": "NFT",
        "TransactedAccount": "oaccount~e88276a3be547e31b567346bdddde52d37734da4d5fae83ab2e5c98a10097371",
        "TransactionId": "otransaction~6a13667ea3f6edc4c854e85b127526eccb58783f653c348b42a3869f0f29a4fb~a7cefb22ff39ee7e36967be71de27da6798548c872061a62dabc56d88d50b930",
        "TransactionType": "MINT",
        "TriggeredByUserAccountId": "ouaccount~412de5e3998dcd100973e1bad6e8729fddc1c7ff610beab8376d733a35c51f38"
    },
    {
        "Balance": 100,
        "Timestamp": "2023-06-05T16:34:33Z",
        "TokenId": "FNFT",
        "TransactedAccount": "oaccount~e88276a3be547e31b567346bdddde52d37734da4d5fae83ab2e5c98a10097371",
        "TransactedAmount": 100,
        "TransactionId": "otransaction~2bc15de1766d582d821bd8d61756bca02837dc683c0aa61f69657ccd1d95e335~e4eb15d9354f694230df8835ade012100d82aa43672896a2c7125a86e3048f9f",
        "TransactionType": "MINT",
        "TriggeredByUserAccountId": "ouaccount~412de5e3998dcd100973e1bad6e8729fddc1c7ff610beab8376d733a35c51f38"
    }
]
GetTransactionById
Questo metodo restituisce i dettagli della transazione per un ID transazione specificato.
Ctx.ERC1155Transaction.GetTransactionById(trxId string) (interface{}, error)
Parametri:
  • trxId string: l'ID della transazione.
Valore restituito
{
    "history": [
        {
            "IsDelete": "false",
            "Timestamp": "2022-12-08T10:45:56Z",
            "TxId": "2da02a53aa1032602df6c68c5628a4ab8b22ba107c0201520ce495948901aa98",
            "Value": {
                "Amount": 5,
                "AssetType": "otransaction",
                "FromAccountId": "oaccount~60bb20c14a83f6e426e1437c479c5891e1c6477dfd7ad18b73acac5d80bc504b",
                "Timestamp": "2022-12-08T10:45:56Z",
                "ToAccountId": "oaccount~1422a74d262a3a55a37cd9023ef8836f765d0be7b49d397696b9961d7434d22a",
                "TokenId": "tokenOne",
                "TransactionId": "otransaction~2da02a53aa1032602df6c68c5628a4ab8b22ba107c0201520ce495948901aa98~9c3ce5f21abd98ca018c196086d73a812f2f49dba323f1de4f6867eecfeec8ff",
                "TransactionType": "TRANSFER",
                "TriggeredByUserAccountId": "ouaccount~24ffd4d32a028a85b4b960f5d55536c837b5429bc7f346150adfa904ec2937cc"
            }
        }
    ],
    "transactionId": "otransaction~2da02a53aa1032602df6c68c5628a4ab8b22ba107c0201520ce495948901aa98~9c3ce5f21abd98ca018c196086d73a812f2f49dba323f1de4f6867eecfeec8ff"
}
DeleteHistoricalTransactions
Questo metodo elimina le transazioni prima di un indicatore orario specificato dal database di stato.
Ctx.ERC1155Transaction.DeleteHistoricalTransactions(referenceTime string) (interface{}, error)
Parametri:
  • referenceTime string: tutte le transazioni precedenti a questo indicatore orario verranno eliminate.
Valore restituito
{
    "Transactions": [
        "otransaction~750f68538451847f57948f7d5261dcb81570cd9e429f928a4cb7bfa76392ecf7"
    ],
    "msg": "Successfuly deleted transaction older than date:2022-04-06T08:17:53Z"
}

Metodi per la gestione del comportamento dei token - Comportamento minimo

MintBatch
Questo metodo crea (mette) più token in un'operazione batch. Questo metodo crea solo token fungibili o token non fungibili frazionari.

Per i token fungibili, se il ruolo più piccolo è definito nel file di specifica, qualsiasi utente con il ruolo più piccolo può chiamare questo metodo. In caso contrario, qualsiasi utente può utilizzare questo metodo per creare token. Non è possibile creare più di una proprietà max_mint_quantity del token, se tale proprietà è stata specificata al momento della creazione o dell'aggiornamento del token.

Per i token non fungibili, se il ruolo minter è definito nel file di specifica, qualsiasi utente con il ruolo minter può chiamare questo metodo. In caso contrario, qualsiasi utente può utilizzare questo metodo per creare token. Inoltre, il chiamante deve essere anche il creatore del token. Non esiste un limite superiore alla quantità di token non fungibili frazionari che possono essere coniati.

Non è possibile utilizzare questo metodo per coniare un token intero non fungibile.

Ctx.ERC1155Token.MintBatch(accountId string, tokens []interface{}, quantities []float64) (interface{}, error)
Parametri:
  • accountId string: l'ID account dell'utente.
  • tokenIds []string: la lista di ID token per i token mint.
  • quantity []float64: l'elenco delle quantità di token da mint, corrispondente all'array ID token.
Restituisce:
  • In caso di operazione riuscita, un oggetto JSON che include dettagli sui token coniati.
Valore restituito
{
    "details": [
        {
            "msg": "Successfully minted 100 tokens of fractional tokenId: plot55 to Org-Id: appdev, User-Id: idcqa"
        },
        {
            "msg": "Successfully minted 100 tokens of tokenId: 'loyalty' to Token-Account-Id 'oaccount~21206f309941a2a23c4f158a0fe1b8f12bb8e2b0c9a2e1358f5efebc0c7d410e'"
        }
    ],
    "msg": "Successfully minted batch of tokens for User-Account-Id 'ouaccount~412de5e3998dcd100973e1bad6e8729fddc1c7ff610beab8376d733a35c51f38' (Org-Id: 'appdev', User-Id: 'idcqa')"
}

Metodi per la gestione del comportamento dei token - comportamento trasferibile

BatchTransferFrom
Questo metodo completa un'operazione batch che trasferisce i token specificati in una lista di ID token da un utente a un altro utente.

Per i NFT, poiché il metodo trasferisce la proprietà del NFT, il mittente del NFT deve possedere il token.

Per le NFT frazionarie, se un utente (incluso il creatore del token) trasferisce tutte le azioni di cui è proprietario, allora perde la proprietà del token. Se una qualsiasi parte di un token viene trasferita a un utente, tale utente diventa automaticamente uno dei proprietari del NFT frazionario.

Questo metodo non convalida che il chiamante del metodo sia il mittente specificato.

Ctx.ERC1155Token.BatchTransferFrom(fromAccountId string, toAccountId string, tokens []interface{}, quantities []float64) (interface{}, error) 
Parametri:
  • fromUserAccountId string: l'ID account del mittente e del proprietario del token nell'organizzazione corrente.
  • toUserAccountId string: l'ID del conto del destinatario.
  • tokenIds string[]: lista di ID token per i token da trasferire.
  • quantity float64[]: l'elenco delle quantità di token da trasferire, corrispondente all'array ID token.
Restituisce:
  • In caso di operazione riuscita, un messaggio con i dettagli per ogni trasferimento di token.
Valore restituito
[
    {
        "msg": "Successfully transferred NFT token: 'FNFT' of '10' quantity from Account-Id: oaccount~e88276a3be547e31b567346bdddde52d37734da4d5fae83ab2e5c98a10097371 (Org-Id: appdev, User-Id: idcqa) to Account-Id: oaccount~dcee860665db8740cb77b846e823752185a1e9a185814d0acb305890f5903446 (Org-Id: appdev, User-Id: user1_minter)"
    },
    {
        "msg": "Successfully transferred 10 FT token: 'FT' from Account-Id: oaccount~21206f309941a2a23c4f158a0fe1b8f12bb8e2b0c9a2e1358f5efebc0c7d410e (Org-Id: appdev, User-Id: idcqa) to Account-Id: oaccount~1089ee5122f367ee0ca38c6660298f4b81f199627e4f67f3691c0f628237974c (Org-Id: appdev, User-Id: user1_minter)"
    },
    {
        "msg": "Successfully transferred NFT token: 'NFT' from Account-Id: oaccount~e88276a3be547e31b567346bdddde52d37734da4d5fae83ab2e5c98a10097371 (Org-Id: appdev, User-Id: idcqa) to Account-Id: oaccount~dcee860665db8740cb77b846e823752185a1e9a185814d0acb305890f5903446 (Org-Id: appdev, User-Id: user1_minter)"
    }
]
SafeBatchTransferFrom
Questo metodo completa un'operazione batch che trasferisce i token specificati in una lista di ID token da un utente a un altro utente.

Per i NFT, poiché il metodo trasferisce la proprietà del NFT, il mittente del NFT deve possedere il token.

Per le NFT frazionarie, se un utente (incluso il creatore del token) trasferisce tutte le azioni di cui è proprietario, allora perde la proprietà del token. Se una qualsiasi parte di un token viene trasferita a un utente, tale utente diventa automaticamente uno dei proprietari del NFT frazionario.

Il chiamante del metodo deve essere il mittente specificato.

Ctx.ERC1155Token.SafeBatchTransferFrom(fromAccountId string, toAccountId string, tokens []interface{}, quantities []float64) (interface{}, error)
Parametri:
  • fromUserAccountId string: l'ID account del mittente e del proprietario del token nell'organizzazione corrente.
  • toUserAccountId string: l'ID del conto del destinatario.
  • tokenIds string[]: lista di ID token per i token da trasferire.
  • quantity float64[]: l'elenco delle quantità di token da trasferire, corrispondente all'array ID token.
Restituisce:
  • In caso di operazione riuscita, un messaggio con i dettagli per ogni trasferimento di token.
Valore restituito
[
    {
        "msg": "Successfully transferred NFT token: 'FNFT' of '10' quantity from Account-Id: oaccount~e88276a3be547e31b567346bdddde52d37734da4d5fae83ab2e5c98a10097371 (Org-Id: appdev, User-Id: idcqa) to Account-Id: oaccount~dcee860665db8740cb77b846e823752185a1e9a185814d0acb305890f5903446 (Org-Id: appdev, User-Id: user1_minter)"
    },
    {
        "msg": "Successfully transferred 10 FT token: 'FT' from Account-Id: oaccount~21206f309941a2a23c4f158a0fe1b8f12bb8e2b0c9a2e1358f5efebc0c7d410e (Org-Id: appdev, User-Id: idcqa) to Account-Id: oaccount~1089ee5122f367ee0ca38c6660298f4b81f199627e4f67f3691c0f628237974c (Org-Id: appdev, User-Id: user1_minter)"
    },
    {
        "msg": "Successfully transferred NFT token: 'NFT' from Account-Id: oaccount~e88276a3be547e31b567346bdddde52d37734da4d5fae83ab2e5c98a10097371 (Org-Id: appdev, User-Id: idcqa) to Account-Id: oaccount~dcee860665db8740cb77b846e823752185a1e9a185814d0acb305890f5903446 (Org-Id: appdev, User-Id: user1_minter)"
    }
]
BalanceOfBatch
Questo metodo completa un'operazione batch che recupera il saldo dei conti token. I dettagli dell'account sono specificati in tre elenchi separati di ID organizzazione, ID utente e ID token. Questo metodo può essere chiamato solo da un Token Admin del codice concatenato o dai proprietari dell'account. I proprietari del conto possono visualizzare i dettagli del saldo solo per i conti di loro proprietà.
Ctx.ERC1155Account.BalanceOfBatch(accountIds []string, tokens []interface{}) (interface{}, error)
Parametri:
  • accountIds []string: elenco degli ID account utente.
  • tokenIds []string: elenco degli ID del token.
Valore restituito
[
    {
        "OrgId": "appdev",
        "UserId": "idcqa",
        "UserAccountId": "ouaccount~412de5e3998dcd100973e1bad6e8729fddc1c7ff610beab8376d733a35c51f38",
        "TokenAccountId": "oaccount~e88276a3be547e31b567346bdddde52d37734da4d5fae83ab2e5c98a10097371",
        "TokenId": "FNFT",
        "Balance": 100
    },
    {
        "OrgId": "appdev",
        "UserId": "idcqa",
        "UserAccountId": "ouaccount~412de5e3998dcd100973e1bad6e8729fddc1c7ff610beab8376d733a35c51f38",
        "TokenAccountId": "oaccount~21206f309941a2a23c4f158a0fe1b8f12bb8e2b0c9a2e1358f5efebc0c7d410e",
        "TokenId": "FT",
        "Balance": 50
    },
    {
        "OrgId": "appdev",
        "UserId": "user1_minter",
        "UserAccountId": "ouaccount~9501bb774c156eb8354dfe489250ea91f757523d70f08ee494bda98bb352003b",
        "TokenAccountId": "oaccount~dcee860665db8740cb77b846e823752185a1e9a185814d0acb305890f5903446",
        "TokenId": "FNFT",
        "Balance": 10
    }
]
ExchangeToken
Questo metodo scambia i token tra gli account specificati. Questo metodo supporta solo lo scambio tra un NFT (intero o frazionario) e un token fungibile o un token fungibile e un NFT (intero o frazionario). Questo metodo può essere chiamato solo dal proprietario dell'account.
Ctx.ERC1155Token.ExchangeToken(fromTokenId string, fromUserAccountId string, fromTokenQuantity float64, toTokenId string, toUserAccountId string, toTokenQuantity float64) (interface{}, error) 
Parametri:
  • fromTokenId string: l'ID del token di proprietà del mittente.
  • fromUserAccountId string – L'ID account del mittente.
  • fromTokenQuantity float64 – La quantità di token dal mittente da scambiare con il ricevitore.
  • toTokenId string: l'ID del token di proprietà del ricevente.
  • toUserAccountId string: l'ID del conto del destinatario.
  • toTokenQuantity float64 – La quantità di token dal destinatario da scambiare con il mittente.
Restituisce:
  • In caso di operazione riuscita, un messaggio con i dettagli dello scambio di token.
Valore restituito
{
    "msg": "Succesfully exchanged 10 tokens of type 'nonfungible' with tokenId: [r1] from Account 'oaccount~e88276a3be547e31b567346bdddde52d37734da4d5fae83ab2e5c98a10097371' (OrgId: appdev, UserId: idcqa) to 10 tokens of type 'fungible' with tokenId: [loy1] from Account 'oaccount~1089ee5122f367ee0ca38c6660298f4b81f199627e4f67f3691c0f628237974c' (OrgId: 'appdev', UserId: 'user1_minter')"
}

Metodi per la gestione del comportamento dei token - comportamento masterizzabile

Burn
Questo metodo disattiva, o brucia, i token fungibili e non fungibili specificati.
Ctx.ERC1155Token.Burn(accountId string, tokens []interface{}, quantities []float64) (interface{}, error)
Parametri:
  • accountId string: l'ID account dell'utente.
  • tokenIds []string: la lista degli ID token da masterizzare.
  • quantity []float64: l'elenco delle quantità di token da masterizzare, corrispondente all'array ID token.
Restituisce:
  • In caso di successo, un messaggio con dettagli sulle operazioni di masterizzazione.
Valore restituito
[
    {
        "msg": "Successfully burned NFT token: 'art' from Account-Id: oaccount~76cb672eeb1bd535899562a840d0c15a356db89e24bc8b43ac1dba845a4282c6 (Org-Id: appdev, User-Id: idcqa)"
    },
    {
        "msg": "Successfully burned 2 tokens of tokenId: FT from Account-ID oaccount~9a940587fd322ccc8400233244cd3b13f3aa2a52e418e4c71fb819a2217bc49e (Org-Id: AutoF1377358917, User-Id: idcqa)"
    },
    {
        "msg": "Successfully burned 2 token share of tokenId: FNFT from Account-ID oaccount~87bcb699d507368ee3966cd03ee6d7736ffc55dde8c0f0e16b14866334ac504a (Org-Id: AutoF1377358917, User-Id: idcqa)"
    }
]