Skip to content

GenerateKernelAdvanced

Anatol Sevastsyan edited this page Jun 1, 2022 · 4 revisions

Env::GenerateKernelAdvanced

void GenerateKernelAdvanced(const ContractID* pCid,
                            uint32_t iMethod,
                            const void* pArg, 
                            uint32_t nArg,
                            const FundsChange* pFunds,
                            uint32_t nFunds, 
                            const PubKey* pSig,
                            uint32_t nSig,
                            const char* szComment,
                            uint32_t nCharge,
                            Height hMin,
                            Height hMax, 
                            const PubKey& ptFullBlind, 
                            const PubKey& ptFullNonce,
                            const Secp_scalar_data& skForeignSig,
                            uint32_t iSlotBlind, 
                            uint32_t iSlotNonce,
                            Secp_scalar_data* pChallenges);

Generates kernel for which makes node to call method iMethod of contract with pCid. In contrast to GenerateKernel provides more control of the exact kernel being-generated. Essential to create multi-signed transactions.

Parameters

  • pCid : pointer to contract ID
  • iMethod : method number to call
  • pArg : pointer to arguments buffer
  • nArg : length of the arguments buffer
  • pFunds : optional pointer to an array of FundsChange structures
  • nFunds : number of elements in the above array
  • pSig : optional pointer to an array of SigRequest structures
  • nSig : number of elements in the above array
  • szComment : Transaction comment (0-terminated character string)
  • nCharge : estimate of the BVM charge (in charge uints) that the transaction execution is supposed to consume
  • hMin : minimal kernel height
  • hMax : maximal kernel height
  • ptFullBlind : total kernel blinding factor (together with [FundsChange] forms the kernel commitment)
  • ptFullNonce : total kernel nonce used for its (multi)signature
  • skForeignSig : foreign part of the kernel (multi)signature
  • iSlotBlind : slot number used to store internal kernel blinding factor
  • iSlotNonce : slot number used to store internal nonce used for its signature
  • pChallenges : (out) - array of challenges for the kernel signature, size of this array equals to nSig

Return value

  • none

Notes

App shader calls this function to request the wallet to create the transaction that is supposed to either deploy, destroy, or invoke a contract method on a blockchain.

Set iMethod to 0 if the contract is being-deployed, in this case pCid (pointer to ContractID) is ignored. Otherwise the pCid must point to a valid ContractID.

The pArgs/nArgs describe the proprietary structure with the parameters as expected by the shader's method.

The pFunds/nFunds is the array description of FundsChange structures, which describe the funds that should be consumed/received in the transaction. The app shader should specify such a structure for each asset type. The wallet selects transaction inputs/outputs appropriately. See description of FundsChange for more info.

The pSig/nSig is the array description of SigRequest structures, which should correspond to the keys by which the kernel must be signed. App shader should specify such a structure for each key requested by the contract shader via AddSig, in the same order.

nCharge is a rough estimate of how much BVM charge the contract invocation would consume. Based on it the wallet calculates the minimum transaction fee. For "simple" methods, that don't perform excessive computations or I/O app shader may specify 0. The default minimum fee should be enough.

Example

Clone this wiki locally