{"modulePath":"github.com/hyperledger/fabric-samples/asset-transfer-basic/chaincode-go","version":"v0.0.0-20260918092737-5789681b4f4d","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package chaincode\n\n## Types\n\n```go\ntype Asset struct {\n\tAppraisedValue int    `json:\"AppraisedValue\"`\n\tColor          string `json:\"Color\"`\n\tID             string `json:\"ID\"`\n\tOwner          string `json:\"Owner\"`\n\tSize           int    `json:\"Size\"`\n}\n```\nAsset describes basic details of what makes up a simple asset Insert struct field in alphabetic order =\u003e to achieve determinism across languages golang keeps the order when marshal to json but doesn't order automatically\n\n```go\ntype SmartContract struct {\n\tcontractapi.Contract\n}\n```\nSmartContract provides functions for managing an Asset\n\n```go\nfunc (s *SmartContract) AssetExists(ctx contractapi.TransactionContextInterface, id string) (bool, error)\n```\nAssetExists returns true when asset with given ID exists in world state\n\n```go\nfunc (s *SmartContract) CreateAsset(ctx contractapi.TransactionContextInterface, id string, color string, size int, owner string, appraisedValue int) error\n```\nCreateAsset issues a new asset to the world state with given details.\n\n```go\nfunc (s *SmartContract) DeleteAsset(ctx contractapi.TransactionContextInterface, id string) error\n```\nDeleteAsset deletes an given asset from the world state.\n\n```go\nfunc (s *SmartContract) GetAllAssets(ctx contractapi.TransactionContextInterface) ([]*Asset, error)\n```\nGetAllAssets returns all assets found in world state\n\n```go\nfunc (s *SmartContract) InitLedger(ctx contractapi.TransactionContextInterface) error\n```\nInitLedger adds a base set of assets to the ledger\n\n```go\nfunc (s *SmartContract) ReadAsset(ctx contractapi.TransactionContextInterface, id string) (*Asset, error)\n```\nReadAsset returns the asset stored in the world state with given id.\n\n```go\nfunc (s *SmartContract) TransferAsset(ctx contractapi.TransactionContextInterface, id string, newOwner string) (string, error)\n```\nTransferAsset updates the owner field of asset with given id in world state, and returns the old owner.\n\n```go\nfunc (s *SmartContract) UpdateAsset(ctx contractapi.TransactionContextInterface, id string, color string, size int, owner string, appraisedValue int) error\n```\nUpdateAsset updates an existing asset in the world state with provided parameters.\n\n","path":"github.com/hyperledger/fabric-samples/asset-transfer-basic/chaincode-go/chaincode","name":"chaincode","synopsis":"","isRedistributable":true}
