Creates a new ErrorUdtInsufficientCoin instance.
Configuration object for the error
The amount of UDT coins that are insufficient (shortfall amount)
The type script of the UDT that has insufficient balance
Optional
reason?: stringOptional custom reason message. If not provided, a default message will be generated
// Manual creation (typically not needed as the error is thrown automatically)
const error = new ErrorUdtInsufficientCoin({
amount: ccc.numFrom(1000),
type: udtScript,
reason: "Custom insufficient balance message"
});
// More commonly, catch the error when it's thrown by UDT methods
try {
const result = await udt.completeInputsByBalance(tx, signer);
} catch (error) {
if (error instanceof ErrorUdtInsufficientCoin) {
// Handle the insufficient balance error
console.error(`Insufficient UDT: need ${error.amount} more tokens`);
}
}
Readonly
amountThe amount of UDT coins that are insufficient (shortfall amount). This represents how many more UDT tokens are needed to complete the operation.
Readonly
typeThe type script of the UDT that has insufficient balance. This identifies which specific UDT token is lacking sufficient funds.
Error thrown when there are insufficient UDT coins to complete a transaction. This error provides detailed information about the shortfall, including the exact amount needed, the UDT type script, and an optional custom reason.
Example