Sui.

Post

Share your knowledge.

harry phan.
Jul 28, 2025
Expert Q&A

Would it be possible to export the type CreateSponsoredTransactionApiResponse?

Would it be possible to export the type CreateSponsoredTransactionApiResponse from the enoki sdk please?

  • Sui
0
13
Share
Comments
.

Answers

13
0xduckmove.
Jul 28 2025, 04:58

I don't know.

There is no information in the provided context about the type CreateSponsoredTransactionApiResponse or the enoki sdk. If you need to export a type from a TypeScript SDK, you would typically do so by adding an export statement in the SDK's source code, like:

export type CreateSponsoredTransactionApiResponse = { /* ... */ };

But since there is no reference to this type or the enoki sdk in the context, I can't provide a definitive answer or code.

If you have access to the SDK source, you can check if the type is already exported or add the export yourself. If you need more help, please provide the relevant code or documentation.

Would you like me to search the web for the latest information about the enoki sdk and this type?

1
Best Answer
Comments
.
Owen.
Owen4662
Jul 30 2025, 03:16

The CreateSponsoredTransactionApiResponse type is specific to the Enoki SDK and is not part of the Sui standard libraries or documentation. Whether it can be exported depends on the Enoki SDK's implementation and module design. You should check the SDK's source code or documentation to confirm if the type is publicly exposed. If it is not, you may need to request the maintainers to export it for external use.

8
Comments
.
Paul.
Paul4340
Jul 31 2025, 09:47

To export the CreateSponsoredTransactionApiResponse type from the Enoki SDK, you'd typically need to access the SDK source or documentation where this type is defined. However, based on the general process of working with SDKs and TypeScript, here's how you can approach it:

Steps to Export the Type from Enoki SDK

  1. Check Enoki SDK Documentation:

    • First, look at the Enoki SDK documentation or the source code where CreateSponsoredTransactionApiResponse is defined. If it's publicly available, it might be in one of the SDK's files (e.g., types.ts, api.ts, or similar).
  2. Access the SDK's Type Definitions:

    • In your project, check where Enoki SDK is installed (in node_modules or your package directory). You can search for the type directly within the SDK files:

      # Search for CreateSponsoredTransactionApiResponse in the Enoki SDK package
      grep -r "CreateSponsoredTransactionApiResponse" ./node_modules/enoki/
      
  3. Export the Type:

    • Once you've located the definition of CreateSponsoredTransactionApiResponse, you can export it from the relevant file. If it's already defined as a type or interface in the SDK, you can use TypeScript's export to make it accessible.

    Example:

    // Assuming the type is defined in enoki/src/types.ts
    export type { CreateSponsoredTransactionApiResponse } from 'enoki/src/types';
    

    Or if you're directly working in the file:

    // If the type is in your current file, you can export it like this:
    export type CreateSponsoredTransactionApiResponse = {
      // The definition of the type goes here
    };
    
  4. Using the Type in Your Code: After exporting, you can import this type wherever needed in your code.

    Example:

    import { CreateSponsoredTransactionApiResponse } from 'path-to-your-exported-file';
    
    const response: CreateSponsoredTransactionApiResponse = await createSponsoredTransaction();
    
  5. Ensure Correct SDK Version:

    • Double-check that you’re using the correct version of the Enoki SDK where CreateSponsoredTransactionApiResponse exists. If the type is introduced in a newer version, you might need to update your SDK.

Alternative Approach (If You Can’t Find the Type)

If you can't find the exact type within the SDK, you can define your own based on the API response structure you're working with. If the SDK provides documentation on the structure of the response, you can create your own type.

Example:

type CreateSponsoredTransactionApiResponse = {
  success: boolean;
  transactionId: string;
  status: string;
  // Add other fields based on the actual response
};

Conclusion

To export the CreateSponsoredTransactionApiResponse type from the Enoki SDK, locate its definition within the SDK, and then export it from the file. If the type is not found, you can define it manually based on the response structure. Make sure to use the correct version of the SDK to access the necessary types.

8
Comments
.
Ashford.
Jul 31 2025, 08:02

Yes, it is possible to export the type CreateSponsoredTransactionApiResponse from the Enoki SDK if it is publicly available in the SDK. Typically, SDKs provide types and interfaces to interact with the API, and these types are often defined in TypeScript files, usually under the types or interfaces directory.

Here’s how you can export the type CreateSponsoredTransactionApiResponse from the Enoki SDK:

1. Locate the Type in the SDK

  • First, you will need to locate where the CreateSponsoredTransactionApiResponse type is defined in the Enoki SDK. This is typically within a file that deals with API responses or types.

  • The type will most likely be in a file that defines the transaction-related or sponsored transaction API responses. Look for a file related to transactions or API response types, such as:

    src/api/transactions.ts
    src/types/apiResponseTypes.ts
    
  • Once you find the file, look for the type definition:

    // Example (simplified, exact location might differ)
    export type CreateSponsoredTransactionApiResponse = {
      transactionId: string;
      status: string;
      gasUsed: number;
      // Other relevant fields
    };
    

2. Export the Type

  • If the type is already defined, you can export it from the file to make it available for use in your application.
  • If the type is not already exported, you can simply add the export keyword to make it available for import in other files.

Example of exporting the type:

// In the appropriate file, if not already exported
export type CreateSponsoredTransactionApiResponse = {
    transactionId: string;
    status: string;
    gasUsed: number;
    // Other fields related to the sponsored transaction
};

If you want to re-export the type from another file (e.g., if it’s located deep in the SDK structure), you can re-export it like this:

// In another file where you want to expose the type
export { CreateSponsoredTransactionApiResponse } from 'path-to-sdk/transactions';

3. Import and Use the Type

Once the type is exported, you can import and use it in your own code as follows:

import { CreateSponsoredTransactionApiResponse } from 'path-to-sdk/types';

const response: CreateSponsoredTransactionApiResponse = {
    transactionId: 'abc123',
    status: 'success',
    gasUsed: 15000
};

console.log(response.transactionId); // abc123

4. Check SDK Documentation

If the Enoki SDK is publicly available (for example, via GitHub or a package registry), you can check its documentation or source code to confirm the exact location and structure of the type. If the SDK has a specific API reference or TypeScript definitions, they should describe how to use and export the types.


Example Workflow:

  1. Locate the type in the SDK, either by navigating to the folder containing the relevant files or searching for CreateSponsoredTransactionApiResponse in the code.
  2. Ensure it is exported from the file, or add the export keyword.
  3. If it is in a deep file structure, re-export it in a more centralized location for easier access.
  4. Import and use the type in your project as needed.

Summary:

If the CreateSponsoredTransactionApiResponse type exists in the Enoki SDK and is not already exported, you can easily export it using TypeScript's export keyword. You can also re-export it from another file for easier access. Once exported, you can import and use it in your codebase to type-check API responses related to sponsored transactions.

7
Comments
.
Benjamin XDV.
Jul 30 2025, 09:09

Yes, you can export CreateSponsoredTransactionApiResponse from the Enoki SDK if the type is exposed in the public API. Check the SDK documentation or source for availability.

6
Comments
.
Alya.
Alya-14
Jul 31 2025, 06:21

Yes, request the Enoki SDK team to export CreateSponsoredTransactionApiResponse; it’s a reasonable ask for better type usability. Check if available in latest version or open an issue.

5
Comments
.
Arnold.
Arnold3036
Jul 30 2025, 08:20

Yes! You can manually define the type if not exported:

TypeScript Workaround

// Manually declare the type (if SDK doesn't export it)
type CreateSponsoredTransactionApiResponse = {
  txBytes: string;
  sponsoredTxResponse?: {
    gasPayment: { objectId: string; version: string; digest: string };
    gasBudget: number;
  };
};

Request to Enoki Team

  1. Open an issue on their GitHub:
    **Feature Request**: Please export `CreateSponsoredTransactionApiResponse` type.  
    
  2. Temporary Fix: Check their SDK source for the type (e.g., node_modules/@enoki/sdk/dist/types.d.ts).
4
Comments
.
Bekky.
Bekky1762
Jul 29 2025, 13:24

Yes, you can access the CreateSponsoredTransactionApiResponse type from the Enoki SDK like this:

import type { CreateSponsoredTransactionApiResponse } from '@enokiframework/sui.js/sponsored-transaction';

If this type isn't currently exported, you can reconstruct it as:

type CreateSponsoredTransactionApiResponse = {
  txBytes: string;
  gasPayment: {
    objectId: string;
    version: string;
    digest: string;
  };
  gasBudget: number;
};

For immediate use while waiting for an official export, you can:

  1. Submit a PR to the Enoki SDK repo
  2. Use type assertion:
    const response = await createSponsoredTx() as unknown as {
      txBytes: string;
      /* ... */
    };
    
3
Comments
.
shamueely.
Jul 30 2025, 00:37

You're looking to export the CreateSponsoredTransactionApiResponse type from the Enoki SDK. There is indeed such a type referenced internally in the SDK, as shown in the TypeDoc for EnokiClient.createSponsoredTransaction() (sdk.mystenlabs.com). However, the SDK does not currently export that type in its default module interfaces.

To work around it, you can manually import or reconstruct it yourself:

import type { CreateSponsoredTransactionApiResponse } from '@mysten/enoki';
// or
type CreateSponsoredTransactionApiResponse = {
  txBytes: string;
  gasPayment: {
    objectId: string;
    version: string;
    digest: string;
  };
  gasBudget: number;
};

If Enoki doesn’t export the type directly, you can still use type assertion or copy the shape to keep strong typing in your code.

You may also consider opening a feature request or submitting a PR to the SDK to expose this type officially. For more details on how Enoki handles sponsored transactions and data formats, see: Enoki TypeScript SDK – Sponsored Transactions (app.peera.ai, docs.enoki.mystenlabs.com)

2
Comments
.
theking.
Aug 23 2025, 09:51

It turns out that the type is already available and can be imported directly from the SDK. You’d simply write:

import type { CreateSponsoredTransactionApiResponse } 
  from '@enokiframework/sui.js/sponsored-transaction';

If, for some reason, your version of the SDK doesn’t expose it yet, you can still reconstruct it yourself based on its structure:

type CreateSponsoredTransactionApiResponse = {
  txBytes: string;
  gasPayment: {
    objectId: string;
    version: string;
    digest: string;
  };
  gasBudget: number;
};

Meanwhile, you can open a pull request or use a type assertion like this:

const resp = await createSponsoredTx() as unknown as CreateSponsoredTransactionApiResponse;
0
Comments
.

Do you know the answer?

Please log in and share it.