Documentation
¶
Index ¶
- type Asset
- type AssetPrivateDetails
- type SmartContract
- func (s *SmartContract) AgreeToTransfer(ctx contractapi.TransactionContextInterface) error
- func (s *SmartContract) CreateAsset(ctx contractapi.TransactionContextInterface) error
- func (s *SmartContract) DeleteAsset(ctx contractapi.TransactionContextInterface) error
- func (s *SmartContract) DeleteTranferAgreement(ctx contractapi.TransactionContextInterface) error
- func (s *SmartContract) GetAssetByRange(ctx contractapi.TransactionContextInterface, startKey string, endKey string) ([]*Asset, error)
- func (s *SmartContract) PurgeAsset(ctx contractapi.TransactionContextInterface) error
- func (s *SmartContract) QueryAssetByOwner(ctx contractapi.TransactionContextInterface, assetType string, owner string) ([]*Asset, error)
- func (s *SmartContract) QueryAssets(ctx contractapi.TransactionContextInterface, queryString string) ([]*Asset, error)
- func (s *SmartContract) ReadAsset(ctx contractapi.TransactionContextInterface, assetID string) (*Asset, error)
- func (s *SmartContract) ReadAssetPrivateDetails(ctx contractapi.TransactionContextInterface, collection string, assetID string) (*AssetPrivateDetails, error)
- func (s *SmartContract) ReadTransferAgreement(ctx contractapi.TransactionContextInterface, assetID string) (*TransferAgreement, error)
- func (s *SmartContract) TransferAsset(ctx contractapi.TransactionContextInterface) error
- type TransferAgreement
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Asset ¶
type Asset struct { Type string `json:"objectType"` //Type is used to distinguish the various types of objects in state database ID string `json:"assetID"` Color string `json:"color"` Size int `json:"size"` Owner string `json:"owner"` }
Asset describes main asset details that are visible to all organizations
type AssetPrivateDetails ¶
type AssetPrivateDetails struct { ID string `json:"assetID"` AppraisedValue int `json:"appraisedValue"` }
AssetPrivateDetails describes details that are private to owners
type SmartContract ¶
type SmartContract struct {
contractapi.Contract
}
SmartContract of this fabric sample
func (*SmartContract) AgreeToTransfer ¶
func (s *SmartContract) AgreeToTransfer(ctx contractapi.TransactionContextInterface) error
AgreeToTransfer is used by the potential buyer of the asset to agree to the asset value. The agreed to appraisal value is stored in the buying orgs org specifc collection, while the buyer client ID is stored in the asset collection using a composite key
func (*SmartContract) CreateAsset ¶
func (s *SmartContract) CreateAsset(ctx contractapi.TransactionContextInterface) error
CreateAsset creates a new asset by placing the main asset details in the assetCollection that can be read by both organizations. The appraisal value is stored in the owners org specific collection.
func (*SmartContract) DeleteAsset ¶
func (s *SmartContract) DeleteAsset(ctx contractapi.TransactionContextInterface) error
DeleteAsset can be used by the owner of the asset to delete the asset
func (*SmartContract) DeleteTranferAgreement ¶
func (s *SmartContract) DeleteTranferAgreement(ctx contractapi.TransactionContextInterface) error
DeleteTranferAgreement can be used by the buyer to withdraw a proposal from the asset collection and from his own collection.
func (*SmartContract) GetAssetByRange ¶
func (s *SmartContract) GetAssetByRange(ctx contractapi.TransactionContextInterface, startKey string, endKey string) ([]*Asset, error)
GetAssetByRange performs a range query based on the start and end keys provided. Range queries can be used to read data from private data collections, but can not be used in a transaction that also writes to private data.
func (*SmartContract) PurgeAsset ¶
func (s *SmartContract) PurgeAsset(ctx contractapi.TransactionContextInterface) error
PurgeAsset can be used by the owner of the asset to delete the asset Trigger removal of the asset
func (*SmartContract) QueryAssetByOwner ¶
func (s *SmartContract) QueryAssetByOwner(ctx contractapi.TransactionContextInterface, assetType string, owner string) ([]*Asset, error)
QueryAssetByOwner queries for assets based on assetType, owner. This is an example of a parameterized query where the query logic is baked into the chaincode, and accepting a single query parameter (owner). Only available on state databases that support rich query (e.g. CouchDB) =========================================================================================
func (*SmartContract) QueryAssets ¶
func (s *SmartContract) QueryAssets(ctx contractapi.TransactionContextInterface, queryString string) ([]*Asset, error)
QueryAssets uses a query string to perform a query for assets. Query string matching state database syntax is passed in and executed as is. Supports ad hoc queries that can be defined at runtime by the client. If this is not desired, follow the QueryAssetByOwner example for parameterized queries. Only available on state databases that support rich query (e.g. CouchDB)
func (*SmartContract) ReadAsset ¶
func (s *SmartContract) ReadAsset(ctx contractapi.TransactionContextInterface, assetID string) (*Asset, error)
ReadAsset reads the information from collection
func (*SmartContract) ReadAssetPrivateDetails ¶
func (s *SmartContract) ReadAssetPrivateDetails(ctx contractapi.TransactionContextInterface, collection string, assetID string) (*AssetPrivateDetails, error)
ReadAssetPrivateDetails reads the asset private details in organization specific collection
func (*SmartContract) ReadTransferAgreement ¶
func (s *SmartContract) ReadTransferAgreement(ctx contractapi.TransactionContextInterface, assetID string) (*TransferAgreement, error)
ReadTransferAgreement gets the buyer's identity from the transfer agreement from collection
func (*SmartContract) TransferAsset ¶
func (s *SmartContract) TransferAsset(ctx contractapi.TransactionContextInterface) error
TransferAsset transfers the asset to the new owner by setting a new owner ID
type TransferAgreement ¶
TransferAgreement describes the buyer agreement returned by ReadTransferAgreement