Error generating wallet in typescript: TypeError: invalid BytesLike value

When running this typescript test:
The error is triggered by generating a wallet. I receive the same error when using the launchNodeAndGetWallets function as well.

import { BaseAssetId, Provider, Wallet } from "fuels";
import { generateTestWallet, launchNode } from "@fuel-ts/account/test-utils";

import { expect, test } from "vitest";

let provider: Provider;
let wallet: Wallet;

test("provider is available", async () => {
  process.env.GENESIS_SECRET =
    "0x6e48a022f9d4ae187bca4e2645abd62198ae294ee484766edbdaadf78160dc68";
  await launchNode({});
  provider = await Provider.create("http://0.0.0.0:4000/graphql");
  wallet = await generateTestWallet(provider, [[1000, BaseAssetId]]);
  expect(provider).not.toBeUndefined;
  expect(wallet).not.toBeUndefined;
}, 10000);

I get the following error:

...
2024-03-09T00:15:35.764132Z  INFO new{name=fuel-core}:initialize_loop{service="TxPool"}: fuel_core_services::service: 330: Starting TxPool service
2024-03-09T00:15:35.764147Z  INFO new{name=fuel-core}:initialize_loop{service="PoA"}: fuel_core_services::service: 330: Starting PoA service
2024-03-09T00:15:35.764153Z  INFO new{name=fuel-core}:initialize_loop{service="PoASyncTask"}: fuel_core_services::service: 330: Starting PoASyncTask service
 ❯ src/__tests__/sdk_init.test.ts (1)
   × provider is available

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Failed Tests 1 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯

 FAIL  src/__tests__/sdk_init.test.ts > provider is available
TypeError: invalid BytesLike value (argument="value", value={ "data": [ 33, 9, 65, 38, 246, 69, 125, 122, 154, 122, 187, 193, 114, 187, 23, 139, 116, 208, 44, 235, 235, 9, 59, 239, 79, 90, 246, 163, 1, 130, 241, 24 ], "type": "Buffer" }, code=INVALID_ARGUMENT, version=6.11.1)
 ❯ makeError node_modules/ethers/src.ts/utils/errors.ts:687:21
 ❯ assert node_modules/ethers/src.ts/utils/errors.ts:715:25
 ❯ assertArgument node_modules/ethers/src.ts/utils/errors.ts:727:5
 ❯ _getBytes node_modules/ethers/src.ts/utils/data.ts:44:5
 ❯ getBytes node_modules/ethers/src.ts/utils/data.ts:55:12
 ❯ hexlify node_modules/ethers/src.ts/utils/data.ts:102:19
 ❯ sha256 node_modules/ethers/src.ts/crypto/sha2.ts:41:12
 ❯ Function.fromPublicKey node_modules/@fuel-ts/address/src/address.ts:153:25
 ❯ new Signer node_modules/@fuel-ts/account/src/signer/signer.ts:41:28
 ❯ new BaseWalletUnlocked node_modules/@fuel-ts/account/src/wallet/base-wallet-unlocked.ts:40:20

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
Serialized Error: { code: 'INVALID_ARGUMENT', argument: 'value', value: { '0': 33, '1': 9, '2': 65, '3': 38, '4': 246, '5': 69, '6': 125, '7': 122, '8': 154, '9': 122, '10': 187, '11': 193, '12': 114, '13': 187, '14': 23, '15': 139, '16': 116, '17': 208, '18': 44, '19': 235, '20': 235, '21': 9, '22': 59, '23': 239, '24': 79, '25': 90, '26': 246, '27': 163, '28': 1, '29': 130, '30': 241, '31': 24, constructor: 'Function<Buffer>', readBigUInt64LE: 'Function<readBigUInt64LE>', readBigUInt64BE: 'Function<readBigUInt64BE>', readBigUint64LE: 'Function<readBigUInt64LE>', readBigUint64BE: 'Function<readBigUInt64BE>', readBigInt64LE: 'Function<readBigInt64LE>', readBigInt64BE: 'Function<readBigInt64BE>', writeBigUInt64LE: 'Function<writeBigUInt64LE>', writeBigUInt64BE: 'Function<writeBigUInt64BE>', writeBigUint64LE: 'Function<writeBigUInt64LE>', writeBigUint64BE: 'Function<writeBigUInt64BE>', writeBigInt64LE: 'Function<writeBigInt64LE>', writeBigInt64BE: 'Function<writeBigInt64BE>', readUIntLE: 'Function<readUIntLE>', readUInt32LE: 'Function<readUInt32LE>', readUInt16LE: 'Function<readUInt16LE>', readUInt8: 'Function<readUInt8>', readUIntBE: 'Function<readUIntBE>', readUInt32BE: 'Function<readUInt32BE>', readUInt16BE: 'Function<readUInt16BE>', readUintLE: 'Function<readUIntLE>', readUint32LE: 'Function<readUInt32LE>', readUint16LE: 'Function<readUInt16LE>', readUint8: 'Function<readUInt8>', readUintBE: 'Function<readUIntBE>', readUint32BE: 'Function<readUInt32BE>', readUint16BE: 'Function<readUInt16BE>', readIntLE: 'Function<readIntLE>', readInt32LE: 'Function<readInt32LE>', readInt16LE: 'Function<readInt16LE>', readInt8: 'Function<readInt8>', readIntBE: 'Function<readIntBE>', readInt32BE: 'Function<readInt32BE>', readInt16BE: 'Function<readInt16BE>', writeUIntLE: 'Function<writeUIntLE>', writeUInt32LE: 'Function<writeUInt32LE>', writeUInt16LE: 'Function<writeUInt16LE>', writeUInt8: 'Function<writeUInt8>', writeUIntBE: 'Function<writeUIntBE>', writeUInt32BE: 'Function<writeUInt32BE>', writeUInt16BE: 'Function<writeUInt16BE>', writeUintLE: 'Function<writeUIntLE>', writeUint32LE: 'Function<writeUInt32LE>', writeUint16LE: 'Function<writeUInt16LE>', writeUint8: 'Function<writeUInt8>', writeUintBE: 'Function<writeUIntBE>', writeUint32BE: 'Function<writeUInt32BE>', writeUint16BE: 'Function<writeUInt16BE>', writeIntLE: 'Function<writeIntLE>', writeInt32LE: 'Function<writeInt32LE>', writeInt16LE: 'Function<writeInt16LE>', writeInt8: 'Function<writeInt8>', writeIntBE: 'Function<writeIntBE>', writeInt32BE: 'Function<writeInt32BE>', writeInt16BE: 'Function<writeInt16BE>', readFloatLE: 'Function<readFloatForwards>', readFloatBE: 'Function<readFloatBackwards>', readDoubleLE: 'Function<readDoubleForwards>', readDoubleBE: 'Function<readDoubleBackwards>', writeFloatLE: 'Function<writeFloatForwards>', writeFloatBE: 'Function<writeFloatBackwards>', writeDoubleLE: 'Function<writeDoubleForwards>', writeDoubleBE: 'Function<writeDoubleBackwards>', asciiSlice: 'Function<asciiSlice>', base64Slice: 'Function<base64Slice>', base64urlSlice: 'Function<base64urlSlice>', latin1Slice: 'Function<latin1Slice>', hexSlice: 'Function<hexSlice>', ucs2Slice: 'Function<ucs2Slice>', utf8Slice: 'Function<utf8Slice>', asciiWrite: 'Function<asciiWrite>', base64Write: 'Function<base64Write>', base64urlWrite: 'Function<base64urlWrite>', latin1Write: 'Function<latin1Write>', hexWrite: 'Function<hexWrite>', ucs2Write: 'Function<ucs2Write>', utf8Write: 'Function<utf8Write>', parent: { constructor: 'Function<ArrayBuffer>', byteLength: 32, slice: 'Function<slice>' }, offset: +0, copy: 'Function<copy>', toString: 'Function<toString>', equals: 'Function<equals>', inspect: 'Function<inspect>', compare: 'Function<compare>', indexOf: 'Function<indexOf>', lastIndexOf: 'Function<lastIndexOf>', includes: 'Function<includes>', fill: 'Function<fill>', write: 'Function<write>', toJSON: 'Function<toJSON>', subarray: 'Function<subarray>', slice: 'Function<slice>', swap16: 'Function<swap16>', swap32: 'Function<swap32>', swap64: 'Function<swap64>', toLocaleString: 'Function<toString>', BYTES_PER_ELEMENT: 1, buffer: { constructor: 'Function<ArrayBuffer>', byteLength: 32, slice: 'Function<slice>' }, byteLength: 32, byteOffset: +0, length: 32, entries: 'Function<entries>', keys: 'Function<keys>', values: 'Function<values>', copyWithin: 'Function<copyWithin>', every: 'Function<every>', filter: 'Function<filter>', find: 'Function<find>', findIndex: 'Function<findIndex>', forEach: 'Function<forEach>', join: 'Function<join>', map: 'Function<map>', reverse: 'Function<reverse>', reduce: 'Function<reduce>', reduceRight: 'Function<reduceRight>', set: 'Function<set>', some: 'Function<some>', sort: 'Function<sort>', at: 'Function<at>', findLast: 'Function<findLast>', findLastIndex: 'Function<findLastIndex>' }, shortMessage: 'invalid BytesLike value' }

Environment Details

Test Runner: Vitest
Fuels: 0.76.0

active toolchain:
beta-5-aarch64-apple-darwin (default)
forc : 0.49.2
- forc-client
- forc-deploy : 0.49.2
- forc-run : 0.49.2
- forc-crypto : 0.49.2
- forc-doc : 0.49.2
- forc-explore : 0.28.1
- forc-fmt : 0.49.2
- forc-lsp : 0.49.2
- forc-tx : 0.49.2
- forc-wallet : 0.4.3
fuel-core : 0.22.1
fuel-core-keygen : 0.22.1

Hi Svimes,

I believe this is due to the genesis wallet being unfunded. You can see how that is done here on GitHub.

Not setting the GENESIS_SECRET env argument, led to the test running successfully for me. Happy to talk you over the genesis wallet seeding though, if this solution doesn’t suffice your requirements.

Hope this helps :slight_smile:

3 Likes

I also meet this problem ,now i learned , thank you very much

You’re most welcome!

Anytime :slight_smile:

Glad to help!

Welcome to the Fuel community :raised_hands:

1 Like

Thanks for decoding the error message, this should help.

I have issues running without explicitly setting the GENESIS_SECRET as the process stalls on generation. If you have resources on Genesis wallet seeding those would be extremely helpful.

You will need to supply a custom chain to the launchNode function to achieve this, details can found here. The chainConfig.json will need to include a new entry within coins for your genesis block address and the assets associated.

Hope this helps :slight_smile:

1 Like