ZCN S.C.

ZCN Smart Contract Functions

NewZCNSmartContract

Creates a new instance of the ZCN Smart Contract.

goCopy codefunc NewZCNSmartContract() smartcontractinterface.SmartContractInterface {
	var contract = &ZCNSmartContract{
		smartcontractinterface.NewSC(ADDRESS),
		make(map[string]smartContractFunction),
	}

	contract.InitSC()
	contract.setSC(contract.SmartContract, &smartcontract.BCContext{})
	return contract
}

InitSC

Initializes smart contract functions within the ZCN Smart Contract, associating each function with a key.

goCopy codefunc (zcn *ZCNSmartContract) InitSC()

Key Functions

  • Configuration

    • update-global-config: Updates the global configuration of the smart contract.

    • update-authorizer-config: Configures specific authorizers for the smart contract.

  • Bridge-Related

    • mint: Mints new ZCN tokens.

    • burn: Burns ZCN tokens, typically used for cross-chain interactions.

  • Authorizer Management

    • add-authorizer: Adds a new authorizer.

    • delete-authorizer: Removes an existing authorizer.

    • authorizer-health-check: Conducts a health check on an authorizer.

  • Delegate Pools

    • add-to-delegate-pool: Adds tokens to the delegate pool for staking.

    • delete-from-delegate-pool: Removes tokens from the delegate pool.

    • update-authorizer-stake-pool: Updates the stake pool for an authorizer.


Execution Statistics

ZCN Smart Contract records metrics for each major function to track performance:


Core Functions

Execute

Executes a specified function within the ZCN Smart Contract based on the provided method name and input data.

Function Signature:

goCopy codefunc (zcn *ZCNSmartContract) Execute(
	trans *transaction.Transaction,
	method string,
	input []byte,
	ctx cstate.StateContextI
) (string, error)

Parameters:

Returns:

  • string - Result of the function execution.

  • error - Error if the execution fails.


Cost Table Retrieval

GetCostTable

Retrieves the cost table for the smart contract, containing configuration costs associated with each operation.

Function Signature:

goCopy codefunc (zcn *ZCNSmartContract) GetCostTable(balances cstate.StateContextI) (map[string]int, error)

Parameters:

Returns:

  • map[string]int - A map containing the cost configuration for each function.

  • error - Error if retrieval fails.

Last updated