Skip to content

handle_init_contract()

Handle explanation

The Ethereum application will call the plugin using this handle upon reception of a smart contract that the plugin is supposed to know how to parse.

The plugin needs to perform the following actions:

  • Check that the selector is recognized
  • Initialize the fields of its context structure

Most of this logic is already done in the boilerplate plugin. You just need to adapt for your use case.

Fields descriptions

typedef struct ethPluginInitContract_s {
    // INPUT. Used to check that `ETH_PLUGIN_INTERFACE_VERSION_LATEST` is
    // correct.
    eth_plugin_interface_version_t interfaceVersion;

    // OUTPUT. Used by the plugin to inform the Ethereum application of the
    // result of this handle The following return codes are expected, any other
    // will abort the signing process:
    // - ETH_PLUGIN_RESULT_OK
    // - ETH_PLUGIN_RESULT_FALLBACK : if the signing logic should fallback to
    // the generic one
    eth_plugin_result_t result;

    // DEPRECATED, will be removed soon. Do not use.
    ethPluginSharedRW_t *pluginSharedRW;

    // INPUT. Transaction data available to the plugin. READ-ONLY.
    ethPluginSharedRO_t *pluginSharedRO;

    // RW INPUT. Contains the semi-persistent RAM space that can be used by the
    // plugin in each handle call.
    uint8_t *pluginContext;

    // INPUT. Size of context allocated by the Ethereum application, must be
    // equal to PLUGIN_CONTEXT_SIZE.
    size_t pluginContextLength;

    // INPUT. Selector of the smart contract that Ethereum application is asking
    // te plugin to display.
    const uint8_t *selector;

    // INPUT. Total length of the data to come.
    size_t dataSize;

} ethPluginInitContract_t;