Error while creating an account

Im creating a script using wallet sdk for wallet management. i am right now stuck at createAccount method.

i am getting the response till signature but not after that.

this is the createAccount method:

async createAccount(opts = {}) {
    const state = this.store.getState();
    if (!state.idObject) {
      throw new Error("Identity not initialized");
    }
    try {
      const wallet = ConcordiumHdWallet.fromSeedPhrase(state.mnemonic, state.network);
      const cryptographicParameters = await this.client.getCryptographicParameters();
      // console.log("Cryptographic Parameters:", cryptographicParameters);

      const { revealedAttributes = [] } = opts;
      const publicKey = wallet.getAccountPublicKey(state.ipInfo.ipIdentity, state.identityIndex, state.credCounter).toString('hex');
      const credentialPublicKeys = {
        keys: {
          0: { schemeId: 'Ed25519', verifyKey: publicKey }
        },
        threshold: 1
      };
      // console.log("Credential Public Keys:", credentialPublicKeys);

      // Generate randomness for attribute commitments, if any attributes are revealed.
      const attributeRandomness = {};
      for (const attr of revealedAttributes) {
        attributeRandomness[attr] = wallet.getAttributeCommitmentRandomness(
          state.ipInfo.ipIdentity,
          state.identityIndex,
          state.credCounter,
          attr
        ).toString('hex');
      }

      const credentialInput = {
        revealedAttributes,
        idObject: state.idObject.value,
        globalContext: cryptographicParameters,
        credNumber: state.credCounter,
        ipInfo: state.ipInfo,
        arsInfos: state.arsInfos,
        attributeRandomness,
        credentialPublicKeys,
        idCredSec: wallet.getIdCredSec(state.ipInfo.ipIdentity, state.identityIndex).toString('hex'),
        prfKey: wallet.getPrfKey(state.ipInfo.ipIdentity, state.identityIndex).toString('hex'),
        sigRetrievelRandomness: wallet.getSignatureBlindingRandomness(state.ipInfo.ipIdentity, state.identityIndex).toString('hex')
      };
      console.log("Credential Input:", credentialInput);

      const expiry = TransactionExpiry.fromDate(new Date(Date.now() + 3600000));
      console.log("expiry:", expiry);
      const credentialTx = createCredentialTransactionNoSeed(credentialInput, expiry);
      console.log("Credential Transaction:", credentialTx);

      // Sign the credential transaction.
      const signingKey = wallet.getAccountSigningKey(credentialTx.unsignedCdi.ipIdentity, state.identityIndex, state.credCounter);
      console.log("Signing Key:", signingKey.toString('hex'));
      const signature = await signCredentialTransaction(credentialTx, signingKey);
      console.log("Credential Signature:", signature);
      const transactionHash = await this.client.sendCredentialDeploymentTransaction(credentialTx, signature);
      console.log("Credential Transaction Hash:", transactionHash);
      const accountAddress = getAccountAddress(credentialTx.unsignedCdi.credId);
      console.log("Account Address:", accountAddress);
      // Update persistent state.
      this.store.updateState({
        credCounter: state.credCounter + 1,
        accounts: [...state.accounts, accountAddress]
      });

      return { accountAddress, credentialTx, signature, transactionHash };
    } catch (error) {
      throw new Error(`Failed to create account: ${error.message}`);
    }
  }

this is the response:

Credential Input: {
  revealedAttributes: [
    'firstName',
    'lastName',
    'sex',
    'dob',
    'countryOfResidence',
    'nationality',
    'idDocType',
    'idDocNo',
    'idDocIssuer',
    'idDocIssuedAt',
    'idDocExpiresAt',
    'nationalIdNo',
    'taxIdNo'
  ],
  idObject: {
    attributeList: {
      chosenAttributes: [Object],
      createdAt: '202502',
      maxAccounts: 200,
      validTo: '202602'
    },
    preIdentityObject: {
      choiceArData: [Object],
      idCredPub: 'a4b66474114b3617d84a05487a59e7dc20ce84313b10d2caae5a3f73a80fb365e07f41f7fc5b35d3bf80c67e098a6028',
      idCredSecCommitment: '882ec4a6a4276b2c61df21bf831845c0212ac248e95b8de70dd8e63c0cbf994495ca79c2c284788b77110dc333e5ed1e',
      ipArData: [Object],
      prfKeyCommitmentWithIP: 'a9feea34b39d139163fa19443fb6670531eb2923f3af8c7782bd42cc83499e232df04d8e7d23773459b876c692113a64',
      prfKeySharingCoeffCommitments: [Array],
      proofsOfKnowledge: '7f2c77b9017...442b584d'
    },
    signature: 'aff2c6e18afa479fc643976f635e87da4166578667590883cb4acc2417bda7b0e5e7658000f3e494f0ddecb5051a07f7802af5abaed2b93b8d64d793a9842716d189ea97fe69efc03096690825ccebedb133a61058e3fd88ad954bfede766de3'
  },
  globalContext: {
    onChainCommitmentKey: 'b14cbfe44a02c6b1f78711176d5f437295367aa4f2a8c2551ee10d25a03adc69d61a332a058971919dad7312e1fc94c5a8d45e64b6f917c540eee16c970c3d4b7f3caf48a7746284878e2ace21c82ea44bf84609834625be1f309988ac523fac',
    bulletproofGenerators: '000001009885.....d93b2431ef2'... 39160 more characters,
    genesisString: 'Concordium Testnet Version 5'
  },
  credNumber: 0,
  ipInfo: {
    ipCdiVerifyKey: '2e1cff3988174c379432c1fad7ccfc385c897c4477c06617262cec7193226eca',
    ipDescription: {
      description: 'Concordium testnet identity provider',
      name: 'Concordium testnet IP',
      url: ''
    },
    ipIdentity: 0,
    ipVerifyKey: '97f1d3a73.....780e6f846'
  },
  arsInfos: {
    '1': {
      arDescription: [Object],
      arIdentity: 1,
      arPublicKey: 'b14cbfe44a02c6b1f78711176d5f437295367aa4f2a8c2551ee10d25a03adc69d61a332a058971919dad7312e1fc94c58ed5281b5d117cb74068a5deef28f027c9055dd424b07043568ac040a4e51f3307f268a77eaebc36bd4bf7cdbbe238b8'
    },
    '2': {
      arDescription: [Object],
      arIdentity: 2,
      arPublicKey: 'b14cbfe44a02c6b1f78711176d5f437295367aa4f2a8c2551ee10d25a03adc69d61a332a058971919dad7312e1fc94c5aefb2334688a2ecc95e7c49e9ccbc7218b5c9e151ac22462d064f564ffa56bb8b3685fcdc8d7d8cb43f43d608e7e8515'
    },
    '3': {
      arDescription: [Object],
      arIdentity: 3,
      arPublicKey: 'b14cbfe44a02c6b1f78711176d5f437295367aa4f2a8c2551ee10d25a03adc69d61a332a058971919dad7312e1fc94c5a791a28a6d3e7ca0857c0f996f94e65da78b8d9b5de5e32164e291e553ed103bf14d6fab1f21749d59664e34813afe77'
    }
  },
  attributeRandomness: {
    firstName: '0ac0f99bb660f2900ede99418370d6aaa81e4a1ac30f969f6179b1e9c676d0b5',
    lastName: '0ac0f99bb660f2900ede99418370d6aaa81e4a1ac30f969f6179b1e9c676d0b5',
    sex: '0ac0f99bb660f2900ede99418370d6aaa81e4a1ac30f969f6179b1e9c676d0b5',
    dob: '0ac0f99bb660f2900ede99418370d6aaa81e4a1ac30f969f6179b1e9c676d0b5',
    countryOfResidence: '0ac0f99bb660f2900ede99418370d6aaa81e4a1ac30f969f6179b1e9c676d0b5',
    nationality: '0ac0f99bb660f2900ede99418370d6aaa81e4a1ac30f969f6179b1e9c676d0b5',
    idDocType: '0ac0f99bb660f2900ede99418370d6aaa81e4a1ac30f969f6179b1e9c676d0b5',
    idDocNo: '0ac0f99bb660f2900ede99418370d6aaa81e4a1ac30f969f6179b1e9c676d0b5',
    idDocIssuer: '0ac0f99bb660f2900ede99418370d6aaa81e4a1ac30f969f6179b1e9c676d0b5',
    idDocIssuedAt: '0ac0f99bb660f2900ede99418370d6aaa81e4a1ac30f969f6179b1e9c676d0b5',
    idDocExpiresAt: '0ac0f99bb660f2900ede99418370d6aaa81e4a1ac30f969f6179b1e9c676d0b5',
    nationalIdNo: '0ac0f99bb660f2900ede99418370d6aaa81e4a1ac30f969f6179b1e9c676d0b5',
    taxIdNo: '0ac0f99bb660f2900ede99418370d6aaa81e4a1ac30f969f6179b1e9c676d0b5'
  },
  credentialPublicKeys: { keys: { '0': [Object] }, threshold: 1 },
  idCredSec: '3335d205f90265fc70db68fba8e6decc8b412613a38a095e65901b58698906ff',
  prfKey: '5a34bf93fb57f0f9f9d0825fb0c9d8aecc27b319bea9dac71b64bd618c41d85f',
  sigRetrievelRandomness: '0460c24cfb854647f4a5d4caf1b42b07198ce282a2cf2a4dbeb7f89004949172'        
}
expiry: TransactionExpiry {
  expiryEpochSeconds: 1739947162n,
  __type: 'ccd_transaction_expiry'
}
Credential Transaction: {
  expiry: TransactionExpiry {
    expiryEpochSeconds: 1739947162n,
    __type: 'ccd_transaction_expiry'
  },
  randomness: {
    attributesRand: {},
    credCounterRand: '1e7f305fea842ab97eb4b48f5abe4af136b1219de55217bbe5f304b95e255dd8',
    idCredSecRand: '4b2ec3476740998185c0851b4b6c09c59a30969b7eb051d5914d4acefac4ba92',
    maxAccountsRand: '0705a98e59fb93eaef8add9d78be383ae9b615f6bb03d201a68ef6bf566e871c',
    prfRand: '4c9e5e20808e59ec867b75e2c15143931011662227ebd9490a3f799c94077330'
  },
  unsignedCdi: {
    arData: { '1': [Object], '2': [Object], '3': [Object] },
    credId: '95b8e4c305b78e0e85df89cacb39b195bffdc4c39abcadff00650c6b99d6eae16dcb3b8ed2378eb4e436c18dc47ff68e',
    credentialPublicKeys: { keys: [Object], threshold: 1 },
    ipIdentity: 0,
    policy: {
      createdAt: '202502',
      revealedAttributes: [Object],
      validTo: '202602'
    },
    proofs: {
      challenge: 'bee375a94e3891d6c3203009769bff5361c4a159d4815f3e8cdb1aa01aa18908',
      commitments: 'a3f82d9...53bcb4',
      credCounterLessThanMaxAccounts: 'aa3916f...3ea14127',
      proofIdCredPub: [Object],
      proofIpSig: '3e46b1....11e3bca6e85',
      proofRegId: '1888f9fb.....00ba7',
      sig: 'af33720b0e430916ad2901118d328e56a9472077f7dc0ae3f51b00bfa588120fc5d21c94cd669f175d17012a9cce6c11872edc9b88497a5ac7c5df9543ed444c9aee6fecfd98e8ffcf1fc2be40581f21a8f7e2f1feb1e8081765a778a1e25205'
    },
    revocationThreshold: 2
  }
}
Signing Key: b5c08d8b3447cb3dfdc3f5698d092d331a59c063b187ee89ce6647874fef8365
Credential Signature: 08ee8df65072e747d63a2e3e1be853a1bf271b5508952da75207379d47d8b6f6b5027c44dd5d09efa661a691865b9c4f6cfd91fc6302c122e6872290b1e72d0c
Test script encountered an error: Failed to create account: ```

this is the test script snippet for testing out this method:

const accountResult = await controller.createAccount({ revealedAttributes: [ ‘firstName’, ‘lastName’, ‘sex’, ‘dob’, ‘countryOfResidence’, ‘nationality’, ‘idDocType’, ‘idDocNo’, ‘idDocIssuer’, ‘idDocIssuedAt’, ‘idDocExpiresAt’, ‘nationalIdNo’, ‘taxIdNo’ ] });
console.log(“AcountResult:”, accountResult);```

i think there is something wrong with sendCredentialDeploymentTransaction method im using in this method.
or
revealedAttributes parameter in test snippet

please suggest what could be the reason

Hi there

So one thing is that the attributeRandomness should not depend on the revealed attributes, but should be constructed for every attribute (taken from here)

let attributeRandomness: any = {};
const attributeKeys = Object.keys(AttributesKeys).filter((v) => isNaN(Number(v)));
attributeKeys.forEach((v) => attributeRandomness[v] = wallet.getAttributeCommitmentRandomness(identityProviderIndex, identityIndex, credNumber, AttributesKeys[v as AttributeKeyString]).toString('hex'));

In case you are not aware, revealed attributes are rarely desirable, since this is the act of actually putting the information on chain tied to the account, which is different from doing ZK proofs.