Sui.

Post

Share your knowledge.

HaGiang.
Jul 26, 2025
Expert Q&A

Could anyone have the same issue and kindly tell me why i get this error?

I found I pass tx to build on sdk and i'll get error "No sui client passed to Transaction#build, but transaction data was not sufficient to build offline."

  • Sui
  • Architecture
0
6
Share
Comments
.

Answers

6
Paul.
Paul4340
Jul 31 2025, 12:19

The error message you're seeing:

"No sui client passed to Transaction#build, but transaction data was not sufficient to build offline."

typically occurs when you're trying to build a transaction using the Sui SDK, but the required Sui client instance (or necessary network data) has not been passed, and the transaction data itself does not contain enough information for the SDK to build the transaction offline.

Key Insights:

  1. Missing Sui Client Instance: The error indicates that the transaction building process is expecting a Sui client to be passed, which is required for interacting with the Sui network to fetch any necessary data (such as the current state of the blockchain, object states, or account information).

  2. Offline Transaction Building: The Sui SDK allows offline transaction building, but it needs enough data (e.g., the current state of objects, gas estimation, signer information) to construct the transaction. If this data is insufficient or unavailable (which is often the case when you try to build offline), it will fail with this error.

How to Fix:

  1. Pass the Sui Client: Ensure that you're passing a valid Sui client instance when calling the build function. This client is necessary for network communication to fetch required data like account balances, object states, and gas estimation, which is vital for building a valid transaction.

    Example in JavaScript/TypeScript:

    const { JsonRpcProvider } = require('@mysten/sui.js');
    const { TransactionBlock } = require('@mysten/sui.js');
    
    // Instantiate the Sui client (JsonRpcProvider)
    const provider = new JsonRpcProvider('https://fullnode.devnet.sui.io');
    
    // Create a new transaction block
    const txBlock = new TransactionBlock();
    
    // Add instructions to the transaction block (e.g., transfer tokens)
    txBlock.moveCall({
      target: '0xYourMovePackage::YourModule::yourFunction',
      arguments: [...],
    });
    
    // Pass the Sui client to the transaction build method
    const txData = await txBlock.build({ provider });
    
    // Sign and send the transaction (if needed)
    

    In this case, the provider (Sui client) is passed to the build function, which gives the SDK the ability to interact with the network and gather the necessary data for transaction construction.

  2. Offline Building with Sufficient Data: If you intend to build the transaction offline (without accessing the network), you need to ensure that the transaction data you're passing to build is complete. This includes:

    • The object IDs you want to interact with.
    • The sender’s account information (e.g., signer).
    • The gas information (e.g., gas price and gas budget).

    To build a transaction offline, ensure that you are providing all the relevant data needed for the SDK to construct the transaction.

  3. Ensure the Correct Context: If you're working with a test or development environment, make sure that:

    • You’re using the correct node endpoint for your test environment (e.g., Testnet, Devnet).
    • Your wallet or signer is properly initialized, and its address is linked with the transaction.
  4. Transaction Construction Dependencies: If you're using some custom modules or complex transactions, ensure that any modules or resources required for the transaction are also included in the transaction data.

Summary of Solutions:

  • Ensure a Sui client is passed: Make sure you're passing a valid Sui client (provider) to the build method.
  • Complete transaction data: If building offline, ensure you’re passing enough transaction data (object IDs, signer info, gas info).
  • Check your environment: Ensure you're using the correct node endpoint and that the wallet or signer is properly configured.

Once you pass the necessary Sui client or provide sufficient data for offline transaction construction, the error should be resolved.

8
Comments
.
Arnold.
Arnold3036
Jul 29 2025, 14:59

You need to pass a connected SuiClient to Transaction.build() or provide all required offline data (like gas, sender, etc.).

Fix:

// Example: Pass SuiClient when building TX  
const tx = new Transaction();  
// ... add commands  
const txBytes = await tx.build({ client: suiClient }); // ✅ With client  

// OR provide full offline data  
const txBytes = await tx.build({
  provider: {
    sender: "0xYourAddress",
    gasBudget: 1000,
  },  
});  

Why?

  • Online mode (client): Fetches missing data (gas, chain ID).
  • Offline mode: Requires manual sender, gasBudget, etc.
5
Comments
.
Evgeniy CRYPTOCOIN.
Jul 30 2025, 08:55

You’re getting this error because:

  1. Missing Sui Client – The Transaction builder needs a connected SuiClient for online data (e.g., gas estimation, object references).
  2. Incomplete Offline Data – If building offline, you must provide all required fields (gas budget, inputs, etc.) manually.

Fix:

Pass suiClient:

const tx = new TransactionBlock({ client: suiClient });  

Or set offline data: Manually add gasBudget, sender, and inputs.

Why it happens: SDK can’t infer gas/data without a client connection.

(Common when using TransactionBlock without setup.)

4
Comments
.
Alya.
Alya-14
Jul 31 2025, 14:35

You’re missing the Sui client in the transaction builder. The SDK needs a client to fetch object/gas data unless all inputs are manually provided. Pass a SuiClient to TransactionBlock#build() or fully specify objects, gas, and sender offline. Most fix: provide the client.

3
Comments
.
290697tz.
Jul 27 2025, 06:55

This error means you're trying to build a transaction using the SDK without providing a Sui client, and the transaction lacks enough data for offline building. To fix it, ensure you pass a valid Sui client instance when calling .build(). Alternatively, supply all required transaction details for offline building. Check that your wallet, gas budget, and inputs are complete. Review the SDK documentation for proper usage.

2
Comments
.
shamueely.
Jul 26 2025, 17:57

You’re getting the error "No sui client passed to Transaction#build, but transaction data was not sufficient to build offline" because your code is trying to build a transaction without providing either:

  1. A connected SuiClient instance OR
  2. All the required information (like gas object, sender, inputs, etc.) to build the transaction offline

This usually happens when you're using the Sui TypeScript SDK and call transaction.build() without:

  • Supplying a SuiClient (to fetch missing on-chain data)
  • OR manually providing all the missing parts like gas payment, sender, chain ID, and object metadata

✅ How to Fix It

If you're online and want the SDK to fetch missing data:

const tx = new TransactionBlock();
// ... your tx logic
await tx.build({ client: suiClient }); // ✅ fixes the error

If you want to build offline, then you must manually set everything:

await tx.setSender(senderAddress);
await tx.setGasBudget(10000000);
await tx.setGasPayment([gasObjectId]);
// Then:
await tx.build(); // ✅ no client needed if all inputs are set

But if even one thing is missing (like gasPayment or sender), build() will throw this exact error.


🔍 Common Causes

  • Forgetting to call setSender() or setGasPayment() before build()
  • Assuming the SDK will auto-fetch data without passing a client
  • Attempting offline signing but lacking full transaction context

💡 What You Should Do

If you're online and using Sui Fullnode/Testnet: Always use:

await tx.build({ client: suiClient });

If you're offline signing (e.g., hardware wallet, embedded signer): Manually set every required property.

Read the official SDK transaction building guide here: https://docs.sui.io/tools/sdk-reference/ts-sdk#transactionblock

1
Comments
.

Do you know the answer?

Please log in and share it.