chaincode

package
v0.0.0-...-059df17 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 9, 2026 License: Apache-2.0, MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// TxList defines all transaction handlers available in the chaincode.
	// Transactions are grouped by functionality:
	//   - Create operations: Initialize new assets (wallets, tokens, escrows)
	//   - Read operations: Query existing assets
	//   - Balance operations: Query and verify account balances
	//   - Token operations: Mint, transfer, and burn digital assets
	//   - Escrow operations: Manage conditional fund transfers
	TxList = []tx.Transaction{
		transaction.DebugTest,

		transaction.CreateUserDir,
		transaction.CreateWallet,
		transaction.CreateDigitalAsset,
		transaction.CreateAndLockEscrow,

		transaction.ReadUserDir,
		transaction.ReadDigitalAsset,
		transaction.ReadEscrow,

		transaction.GetBalance,
		transaction.GetEscrowBalance,
		transaction.GetWalletByOwner,
		transaction.MintTokens,
		transaction.TransferTokens,
		transaction.BurnTokens,

		transaction.RefundEscrow,
		transaction.VerifyEscrowCondition,
		transaction.ReleaseEscrow,
	}

	// AssetTypeList defines all asset types managed by the chaincode.
	// Each asset type represents a core data structure:
	//   - Wallet: User accounts holding digital assets
	//   - DigitalAssetToken: Fungible tokens (e.g., CBDC)
	//   - UserDirectory: Mapping between public keys and wallets
	//   - Escrow: Conditional payment contracts
	AssetTypeList = []assets.AssetType{
		asset.Wallet,
		asset.DigitalAssetToken,
		asset.UserDirectory,
		asset.Escrow,
	}
)

Functions

func GenerateCollection

func GenerateCollection(orgs []string)

GenerateCollection handles collection generation (if needed)

func InitFunc

func InitFunc(stub shim.ChaincodeStubInterface) (response pb.Response)

InitFunc performs comprehensive startup validation checks. It verifies that all asset types and transaction definitions are properly configured and consistent with the chaincode specification.

Parameters:

stub: The chaincode stub for ledger interaction

Returns:

response: Peer response with status 200 on success, error response otherwise

func RunCCaaS

func RunCCaaS() error

RunCCaaS starts the chaincode as a service using the Chaincode as a Service (CCaaS) model. It reads server configuration from environment variables and optionally wraps the chaincode with FPC (Fabric Private Chaincode) for confidential execution.

Environment Variables:

CHAINCODE_SERVER_ADDRESS: The address and port for the chaincode server
CHAINCODE_PKG_ID: The chaincode package identifier
FPC_ENABLED: Set to "true" to enable FPC confidential execution

Returns:

error: Error if server fails to start, nil on successful startup

func SetupCC

func SetupCC() error

SetupCC initializes the chaincode with all necessary components. This function configures the chaincode header metadata and registers all transaction handlers, asset types, and event definitions with cc-tools.

Returns:

error: Error if initialization fails, nil on success

func StartChaincode

func StartChaincode() error

StartChaincode initializes and starts the chaincode in the appropriate execution mode. It determines the startup mode based on environment variables and handles both CCaaS (Chaincode as a Service) and direct execution modes, with optional FPC support.

Environment Variables:

RUN_CCAAS: Set to "true" to run in CCaaS mode
FPC_ENABLED: Set to "true" to enable FPC confidential execution

Returns:

error: Error if chaincode fails to start, nil on successful startup

Types

type ConfidentialEscrowCC

type ConfidentialEscrowCC struct{}

ConfidentialEscrowCC implements the Hyperledger Fabric chaincode interface for confidential escrow operations.

func (*ConfidentialEscrowCC) Init

func (t *ConfidentialEscrowCC) Init(stub shim.ChaincodeStubInterface) (response pb.Response)

Init is called during chaincode instantiation to initialize the ledger state. This method performs startup validation checks for assets and transactions to ensure the chaincode is properly configured before accepting invocations.

Parameters:

stub: The chaincode stub for ledger interaction

Returns:

response: Peer response indicating success or failure of initialization

func (*ConfidentialEscrowCC) Invoke

func (t *ConfidentialEscrowCC) Invoke(stub shim.ChaincodeStubInterface) (response pb.Response)

Invoke is called for each transaction invocation on the chaincode. It ensures proper initialization has occurred and delegates transaction execution to the cc-tools transaction runner.

Parameters:

stub: The chaincode stub for ledger interaction

Returns:

response: Peer response containing transaction result or error detail

Directories

Path Synopsis
This file implements transaction handlers for digital asset token lifecycle management.
This file implements transaction handlers for digital asset token lifecycle management.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL