We’ve found some strange issues when trying to deploy our contract from the frontend. The contract compiles without any problems, and the bytecode size is 74,640 bytes, which is well within the 100kB limit.
If we use the command-line interface (CLI) and run forc deploy --testnet, the deployment works as expected.
However, when we try to deploy the contract programmatically from the frontend using the auto-generated ABI and hex files, we encounter a vague error that doesn’t provide any useful information.
To generate the contract types, we followed the steps from the Fuel documentation:
npx fuels init --contracts ../counter-contract/ --output ./src/sway-api
npx fuels build
When we try to deploy the contract using the generated types:
import { FuelMultisigAbi__factory } from "@/services/contracts/multisig/contracts/factories/FuelMultisigAbi__factory";
const gasPrice = wallet.provider.getGasConfig().minGasPrice;
const gasMax = wallet.provider.getGasConfig().maxGasPerTx;
const factory = await FuelMultisigAbi__factory.deployContract(
bytecode,
wallet,
{
gasPrice,
maxFee: gasMax,
}
);
The deployment fails with a vague error.
Error
at new t....
Or
Error
at new JSONRPCErrorException ...
However, if we change the contract to a simple counter contract, the deployment works smoothly. This suggests that the issue is specific to the contract we’re trying to deploy.
Also, when we use the TypeGen process from the Fuels TS guide:
pnpm fuels typegen -i ./abis/*-abi.json -o ./types
And then deploy it:
import { DemoContractAbi__factory } from './types';
import bytecode from './types/DemoContractAbi.hex';
const gasPrice = wallet.provider.getGasConfig().minGasPrice;
// Deploy
const contract = await DemoContractAbi__factory.deployContract(bytecode, wallet, { gasPrice });
This deployment still fails.
If we try to replicate this using Fuelet wallet instead of the Fuel wallet, we see the following error:
Error: FuelError: Invalid u16, too many bytes.
at new JSONRPCErrorException (models.js:60:28)
at JSONRPCClient.eval (client.js:217:48)
at step (client.js:107:23)
at Object.eval [as next] (client.js:48:20)
at fulfilled (client.js:11:32)
The dependencies involved are:
"@fuels/connectors": "0.1.1",
"@fuels/react": "0.18.0",
"fuels": "0.82.0",
It seems to be an issue similar to the one on this forum post:
This bug is somewhat blocking for our development at the moment. The inability to reliably deploy our full-featured contract is hindering our ability to thoroughly test the contract’s functionality. To work around this, we have created a temporary contract with a reduced set of features, in an effort to keep the contract size smaller. However, this workaround means we won’t be able to fully test the complete functionality of our intended contract until we can resolve the deployment issue. This is a suboptimal situation, as we won’t have complete confidence in the contract’s behavior until we can deploy and test the full version. Resolving this deployment problem is a high priority for us, as it is currently impeding our development progress.