java.lang.Object
tech.deplant.java4ever.binding.Abi

public class Abi extends Object
abi Contains methods of "abi" module. Provides message encoding and decoding according to the ABI specification.
  • Constructor Details

    • Abi

      public Abi()
  • Method Details

    • encodeMessageBody

      public static Abi.ResultOfEncodeMessageBody encodeMessageBody(Context ctx, Abi.ABI abi, Abi.CallSet callSet, Boolean isInternal, Abi.Signer signer, Number processingTryIndex, String address) throws EverSdkException
      abi.encode_message_body Encodes message body according to ABI function call.
      Parameters:
      abi - Contract ABI.
      callSet - Function call parameters. Must be specified in non deploy message.

      In case of deploy message contains parameters of constructor.

      isInternal - True if internal message body must be encoded.
      signer - Signing parameters.
      processingTryIndex - Processing try index. Used in message processing with retries.

      Encoder uses the provided try index to calculate messageexpiration time.

      Expiration timeouts will grow with every retry.

      Default value is 0.

      address - Destination address of the message Since ABI version 2.3 destination address of external inbound message is used in messagebody signature calculation. Should be provided when signed external inbound message body iscreated. Otherwise can be omitted.
      Returns:
      Abi.ResultOfEncodeMessageBody
      Throws:
      EverSdkException
    • attachSignatureToMessageBody

      public static Abi.ResultOfAttachSignatureToMessageBody attachSignatureToMessageBody(Context ctx, Abi.ABI abi, String publicKey, String message, String signature) throws EverSdkException
      abi.attach_signature_to_message_body
      Parameters:
      abi - Contract ABI
      publicKey - Public key. Must be encoded with `hex`.
      message - Unsigned message body BOC. Must be encoded with `base64`.
      signature - Signature. Must be encoded with `hex`.
      Returns:
      Abi.ResultOfAttachSignatureToMessageBody
      Throws:
      EverSdkException
    • encodeMessage

      public static Abi.ResultOfEncodeMessage encodeMessage(Context ctx, Abi.ABI abi, String address, Abi.DeploySet deploySet, Abi.CallSet callSet, Abi.Signer signer, Number processingTryIndex) throws EverSdkException
      abi.encode_message Encodes an ABI-compatible message Allows to encode deploy and function call messages,both signed and unsigned.

      Use cases include messages of any possible type:- deploy with initial function call (i.e. `constructor` or any other function that is used for some kindof initialization);- deploy without initial function call;- signed/unsigned + data for signing.

      `Signer` defines how the message should or shouldn't be signed:

      `Signer::None` creates an unsigned message. This may be needed in case of some public methods,that do not require authorization by pubkey.

      `Signer::External` takes public key and returns `data_to_sign` for later signing.Use `attach_signature` method with the result signature to get the signed message.

      `Signer::Keys` creates a signed message with provided key pair. Soon `Signer::SigningBox` Allows using a special interface to implement signingwithout private key disclosure to SDK. For instance, in case of using a cold wallet or HSM,when application calls some API to sign data. There is an optional public key can be provided in deploy set in order to substitute onein TVM file.

      Public key resolving priority:1. Public key from deploy set.2. Public key, specified in TVM file.3. Public key, provided by signer.

      Parameters:
      abi - Contract ABI.
      address - Target address the message will be sent to. Must be specified in case of non-deploy message.
      deploySet - Deploy parameters. Must be specified in case of deploy message.
      callSet - Function call parameters. Must be specified in case of non-deploy message.

      In case of deploy message it is optional and contains parametersof the functions that will to be called upon deploy transaction.

      signer - Signing parameters.
      processingTryIndex - Processing try index. Used in message processing with retries (if contract's ABI includes "expire" header).

      Encoder uses the provided try index to calculate messageexpiration time. The 1st message expiration time is specified inClient config.

      Expiration timeouts will grow with every retry.Retry grow factor is set in Client config:<.....add config parameter with default value here>

      Default value is 0.

      Returns:
      Abi.ResultOfEncodeMessage
      Throws:
      EverSdkException
    • encodeInternalMessage

      public static Abi.ResultOfEncodeInternalMessage encodeInternalMessage(Context ctx, Abi.ABI abi, String address, String srcAddress, Abi.DeploySet deploySet, Abi.CallSet callSet, String value, Boolean bounce, Boolean enableIhr) throws EverSdkException
      abi.encode_internal_message Encodes an internal ABI-compatible message Allows to encode deploy and function call messages.

      Use cases include messages of any possible type:- deploy with initial function call (i.e. `constructor` or any other function that is used for some kindof initialization);- deploy without initial function call;- simple function call

      There is an optional public key can be provided in deploy set in order to substitute onein TVM file.

      Public key resolving priority:1. Public key from deploy set.2. Public key, specified in TVM file.

      Parameters:
      abi - Contract ABI. Can be None if both deploy_set and call_set are None.
      address - Target address the message will be sent to. Must be specified in case of non-deploy message.
      srcAddress - Source address of the message.
      deploySet - Deploy parameters. Must be specified in case of deploy message.
      callSet - Function call parameters. Must be specified in case of non-deploy message.

      In case of deploy message it is optional and contains parametersof the functions that will to be called upon deploy transaction.

      value - Value in nanotokens to be sent with message.
      bounce - Flag of bounceable message. Default is true.
      enableIhr - Enable Instant Hypercube Routing for the message. Default is false.
      Returns:
      Abi.ResultOfEncodeInternalMessage
      Throws:
      EverSdkException
    • attachSignature

      public static Abi.ResultOfAttachSignature attachSignature(Context ctx, Abi.ABI abi, String publicKey, String message, String signature) throws EverSdkException
      abi.attach_signature Combines `hex`-encoded `signature` with `base64`-encoded `unsigned_message`. Returns signed message encoded in `base64`.
      Parameters:
      abi - Contract ABI
      publicKey - Public key encoded in `hex`.
      message - Unsigned message BOC encoded in `base64`.
      signature - Signature encoded in `hex`.
      Returns:
      Abi.ResultOfAttachSignature
      Throws:
      EverSdkException
    • decodeMessage

      public static Abi.DecodedMessageBody decodeMessage(Context ctx, Abi.ABI abi, String message, Boolean allowPartial) throws EverSdkException
      abi.decode_message Decodes message body using provided message BOC and ABI.
      Parameters:
      abi - contract ABI
      message - Message BOC
      allowPartial - Flag allowing partial BOC decoding when ABI doesn't describe the full body BOC. Controls decoder behaviour when after decoding all described in ABI params there are some data left in BOC: `true` - return decoded values `false` - return error of incomplete BOC deserialization (default)
      Returns:
      Abi.DecodedMessageBody
      Throws:
      EverSdkException
    • decodeMessageBody

      public static Abi.DecodedMessageBody decodeMessageBody(Context ctx, Abi.ABI abi, String body, Boolean isInternal, Boolean allowPartial) throws EverSdkException
      abi.decode_message_body Decodes message body using provided body BOC and ABI.
      Parameters:
      abi - Contract ABI used to decode.
      body - Message body BOC encoded in `base64`.
      isInternal - True if the body belongs to the internal message.
      allowPartial - Flag allowing partial BOC decoding when ABI doesn't describe the full body BOC. Controls decoder behaviour when after decoding all described in ABI params there are some data left in BOC: `true` - return decoded values `false` - return error of incomplete BOC deserialization (default)
      Returns:
      Abi.DecodedMessageBody
      Throws:
      EverSdkException
    • encodeAccount

      public static Abi.ResultOfEncodeAccount encodeAccount(Context ctx, Abi.StateInitSource stateInit, Long balance, Long lastTransLt, Number lastPaid, Boc.BocCacheType bocCache) throws EverSdkException
      abi.encode_account Creates account state BOC Creates account state provided with one of these sets of data :1. BOC of code, BOC of data, BOC of library2. TVC (string in `base64`), keys, init params
      Parameters:
      stateInit - Source of the account state init.
      balance - Initial balance.
      lastTransLt - Initial value for the `last_trans_lt`.
      lastPaid - Initial value for the `last_paid`.
      bocCache - Cache type to put the result. The BOC itself returned if no cache type provided
      Returns:
      Abi.ResultOfEncodeAccount
      Throws:
      EverSdkException
    • decodeAccountData

      public static Abi.ResultOfDecodeAccountData decodeAccountData(Context ctx, Abi.ABI abi, String data, Boolean allowPartial) throws EverSdkException
      abi.decode_account_data Decodes account data using provided data BOC and ABI. Note: this feature requires ABI 2.1 or higher.
      Parameters:
      abi - Contract ABI
      data - Data BOC or BOC handle
      allowPartial - Flag allowing partial BOC decoding when ABI doesn't describe the full body BOC. Controls decoder behaviour when after decoding all described in ABI params there are some data left in BOC: `true` - return decoded values `false` - return error of incomplete BOC deserialization (default)
      Returns:
      Abi.ResultOfDecodeAccountData
      Throws:
      EverSdkException
    • updateInitialData

      public static Abi.ResultOfUpdateInitialData updateInitialData(Context ctx, Abi.ABI abi, String data, Map<String,Object> initialData, String initialPubkey, Boc.BocCacheType bocCache) throws EverSdkException
      abi.update_initial_data Updates initial account data with initial values for the contract's static variables and owner's public key. This operation is applicable only for initial account data (before deploy). If the contract is already deployed, its data doesn't contain this data section any more.
      Parameters:
      abi - Contract ABI
      data - Data BOC or BOC handle
      initialData - List of initial values for contract's static variables. `abi` parameter should be provided to set initial data
      initialPubkey - Initial account owner's public key to set into account data
      bocCache - Cache type to put the result. The BOC itself returned if no cache type provided.
      Returns:
      Abi.ResultOfUpdateInitialData
      Throws:
      EverSdkException
    • encodeInitialData

      public static Abi.ResultOfEncodeInitialData encodeInitialData(Context ctx, Abi.ABI abi, Map<String,Object> initialData, String initialPubkey, Boc.BocCacheType bocCache) throws EverSdkException
      abi.encode_initial_data Encodes initial account data with initial values for the contract's static variables and owner's public key into a data BOC that can be passed to `encode_tvc` function afterwards. This function is analogue of `tvm.buildDataInit` function in Solidity.
      Parameters:
      abi - Contract ABI
      initialData - List of initial values for contract's static variables. `abi` parameter should be provided to set initial data
      initialPubkey - Initial account owner's public key to set into account data
      bocCache - Cache type to put the result. The BOC itself returned if no cache type provided.
      Returns:
      Abi.ResultOfEncodeInitialData
      Throws:
      EverSdkException
    • decodeInitialData

      public static Abi.ResultOfDecodeInitialData decodeInitialData(Context ctx, Abi.ABI abi, String data, Boolean allowPartial) throws EverSdkException
      abi.decode_initial_data Decodes initial values of a contract's static variables and owner's public key from account initial data This operation is applicable only for initial account data (before deploy). If the contract is already deployed, its data doesn't contain this data section any more.
      Parameters:
      abi - Contract ABI. Initial data is decoded if this parameter is provided
      data - Data BOC or BOC handle
      allowPartial - Flag allowing partial BOC decoding when ABI doesn't describe the full body BOC. Controls decoder behaviour when after decoding all described in ABI params there are some data left in BOC: `true` - return decoded values `false` - return error of incomplete BOC deserialization (default)
      Returns:
      Abi.ResultOfDecodeInitialData
      Throws:
      EverSdkException
    • decodeBoc

      public static Abi.ResultOfDecodeBoc decodeBoc(Context ctx, Abi.AbiParam[] params, String boc, Boolean allowPartial) throws EverSdkException
      abi.decode_boc Decodes BOC into JSON as a set of provided parameters. Solidity functions use ABI types for builder encoding.The simplest way to decode such a BOC is to use ABI decoding.ABI has it own rules for fields layout in cells so manually encodedBOC can not be described in terms of ABI rules.

      To solve this problem we introduce a new ABI type `Ref(<ParamType>)`which allows to store `ParamType` ABI parameter in cell reference and, thus,decode manually encoded BOCs. This type is available only in `decode_boc` functionand will not be available in ABI messages encoding until it is included into some ABI revision.

      Such BOC descriptions covers most users needs. If someone wants to decode some BOC whichcan not be described by these rules (i.e. BOC with TLB containing constructors of flagsdefining some parsing conditions) then they can decode the fields up to fork condition,check the parsed data manually, expand the parsing schema and then decode the whole BOCwith the full schema.

      Parameters:
      params - Parameters to decode from BOC
      boc - Data BOC or BOC handle
      allowPartial -
      Returns:
      Abi.ResultOfDecodeBoc
      Throws:
      EverSdkException
    • encodeBoc

      public static Abi.ResultOfAbiEncodeBoc encodeBoc(Context ctx, Abi.AbiParam[] params, Map<String,Object> data, Boc.BocCacheType bocCache) throws EverSdkException
      abi.encode_boc Encodes given parameters in JSON into a BOC using param types from ABI.
      Parameters:
      params - Parameters to encode into BOC
      data - Parameters and values as a JSON structure
      bocCache - Cache type to put the result. The BOC itself returned if no cache type provided
      Returns:
      Abi.ResultOfAbiEncodeBoc
      Throws:
      EverSdkException
    • calcFunctionId

      public static Abi.ResultOfCalcFunctionId calcFunctionId(Context ctx, Abi.ABI abi, String functionName, Boolean output) throws EverSdkException
      abi.calc_function_id Calculates contract function ID by contract ABI
      Parameters:
      abi - Contract ABI.
      functionName - Contract function name
      output - If set to `true` output function ID will be returned which is used in contract response. Default is `false`
      Returns:
      Abi.ResultOfCalcFunctionId
      Throws:
      EverSdkException