Creates a new ErrorCoinInsufficient instance.
Configuration object for the error
The amount of Coin that is insufficient (shortfall amount)
The type script of the Coin that has insufficient amount
Optionalreason?: 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 ErrorCoinInsufficient({
amount: ccc.numFrom(1000),
type: coinScript,
reason: "Custom insufficient amount message"
});
// More commonly, catch the error when it's thrown by Coin methods
try {
const result = await coin.completeInputsByAmount(signer, tx);
} catch (error) {
if (error instanceof ErrorCoinInsufficient) {
// Handle the insufficient amount error
console.error(`Insufficient Coin: need ${error.amount} more tokens`);
}
}
ReadonlyamountThe amount of Coin that is insufficient (shortfall amount). This represents how many more Coin tokens are needed to complete the operation.
ReadonlytypeThe type script of the Coin that has insufficient amount. This identifies which specific Coin token is lacking sufficient funds.
Error thrown when there are insufficient Coin to complete a transaction. This error provides detailed information about the shortfall, including the exact amount needed, the Coin type script, and an optional custom reason.
Example