Cannot deploy contract on beta-5 using ts sdk

TS sdk version: 0.73.0

Here are the toolchain versions:

forc : 0.49.1

  • forc-client
  • forc-deploy : 0.49.1
  • forc-run : 0.49.1
  • forc-crypto : 0.49.1
  • forc-doc : 0.49.1
  • forc-explore : 0.28.1
  • forc-fmt : 0.49.1
  • forc-lsp : 0.49.1
  • forc-tx : 0.49.1
  • forc-wallet : 0.4.2
    fuel-core : 0.22.0
    fuel-core-keygen : 0.22.0
    fuels versions
    forc : 0.54.0
    forc-wallet : 0.54.0

Here is the code snippet:

const exchangeBytecode = readFileSync(path.join(__dirname, '../../bin-files/thunder_exchange.bin'));
const exchangeFactory = new ContractFactory(exchangeBytecode, ThunderExchangeAbi__factory.abi, OWNER);
const { minGasPrice: gasPrice } = provider.getGasConfig();
const exchange = await exchangeFactory.deployContract({gasPrice});

Here is the error I receive when I try to deploy the contract:

_FuelError: Invalid u16, too many bytes.
    at NumberCoder.encode (/Users/fsociety/thunder/thunder-sdk/node_modules/@fuel-ts/abi-coder/src/coders/number.ts:55:13)
    at WitnessCoder.encode (/Users/fsociety/thunder/thunder-sdk/node_modules/@fuel-ts/transactions/src/coders/witness.ts:26:39)
    at /Users/fsociety/thunder/thunder-sdk/node_modules/@fuel-ts/abi-coder/src/coders/array.ts:34:74
    at Array.map (<anonymous>)
    at ArrayCoder.encode (/Users/fsociety/thunder/thunder-sdk/node_modules/@fuel-ts/abi-coder/src/coders/array.ts:34:52)
    at TransactionCreateCoder.encode (/Users/fsociety/thunder/thunder-sdk/node_modules/@fuel-ts/transactions/src/coders/transaction.ts:220:73)
    at TransactionCoder.encode (/Users/fsociety/thunder/thunder-sdk/node_modules/@fuel-ts/transactions/src/coders/transaction.ts:372:40)
    at CreateTransactionRequest.toTransactionBytes (/Users/fsociety/thunder/thunder-sdk/node_modules/@fuel-ts/providers/src/transaction-request/transaction-request.ts:189:35)
    at CreateTransactionRequest.byteSize (/Users/fsociety/thunder/thunder-sdk/node_modules/@fuel-ts/providers/src/transaction-request/transaction-request.ts:518:17)
    at CreateTransactionRequest.calculateMinGas (/Users/fsociety/thunder/thunder-sdk/node_modules/@fuel-ts/providers/src/transaction-request/transaction-request.ts:538:25) {
  VERSIONS: { FORC: '0.49.2', FUEL_CORE: '0.22.0', FUELS: '0.73.0' },
  code: 'encode-error'
}

I think the latest release includes the fix for your problem. :slight_smile:

Updating to the new version should do the trick.

Please, let me know how it goes.

Thanks.

2 Likes

For more information about this problem, please refer to this post:

Yes! It solved my problem

Thanks a lot!

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.