Post
Share your knowledge.
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
Answers
6The 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:
-
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).
-
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:
-
Pass the Sui Client: Ensure that you're passing a valid Sui client instance when calling the
buildfunction. 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 thebuildfunction, which gives the SDK the ability to interact with the network and gather the necessary data for transaction construction. -
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
buildis 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.
-
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.
-
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
buildmethod. - 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.
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.
You’re getting this error because:
- Missing Sui Client – The
Transactionbuilder needs a connectedSuiClientfor online data (e.g., gas estimation, object references). - 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.)
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.
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.
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:
- A connected
SuiClientinstance OR - 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()orsetGasPayment()beforebuild() - 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
Do you know the answer?
Please log in and share it.
Sui is a Layer 1 protocol blockchain designed as the first internet-scale programmable blockchain platform.
- How to Maximize Profit Holding SUI: Sui Staking vs Liquid Staking616
- Why does BCS require exact field order for deserialization when Move structs have named fields?65
- Multiple Source Verification Errors" in Sui Move Module Publications - Automated Error Resolution55
- Sui Move Error - Unable to process transaction No valid gas coins found for the transaction419
- Sui Transaction Failing: Objects Reserved for Another Transaction410