Add Account: Transaction succeeded but throws an Error

Hi everyone,

I am adding an account using emulator / service account, and using the exact code provided on flow docs

  1. JS function returning a Promise returning txID:

const addAccounts = () => {
return fcl.send([
import FungibleToken from ${process.env.REACT_APP_FUNGIBLE_CONTRACT}
import FlowToken from ${process.env.REACT_APP_FLOW_CONTRACT}

    transaction {
      prepare(signer: AuthAccount) {
        let newAccount = AuthAccount(payer: signer)
        let key = PublicKey(
            publicKey: "949ab5529e09a2ddae62548413de7100ed849fb8a128edd1cb0fb121dc6bbe28dd5706f04727f2da434d93df6075655d493d40c2aca2ab859478e9995af54d45".decodeHex(),
            signatureAlgorithm: SignatureAlgorithm.ECDSA_P256

            publicKey: key,
            hashAlgorithm: HashAlgorithm.SHA3_256,
            weight: 1000.0

]).then((encodedData) => {
  return fcl.decode(encodedData).then(txId => {
    return txId;
}).catch((error) => {
  console.error("Add Accounts", error);
  return error;


  1. using fcl subscribe to follow the transaction state:

fcl.tx(txId).subscribe((status) => this.checkTxStatus(status, txId));

transaction will be sealed, account will be created, emulator do not display any error, but the fcl subscribe call will fail:

sdk.module.js:1 Uncaught (in promise) Error: Undefined Decoder Error: Enum@publicKey.signatureAlgorithm


If i am removing the part adding a key to the new account:

        // newAccount.keys.add(
        //     publicKey: key,
        //     hashAlgorithm: HashAlgorithm.SHA3_256,
        //     weight: 1000.0
        // )

then everything is fine, the account is added (with no key), emulator display no error and fcl subscribe display no error

It sounds like fcl.subscribe is somehow jumping signatures from the transaction signer public key to the new added account public key ???

Thanks to anyone for helping :kissing_heart:

You can add decoder for Enum type. For example, like this:

// somewhere uptop in your import
  import { config } from "@onflow/fcl";

  // then inside initialization block
    .put("decoder.Enum", (val) => {
      const result = {

      for (let i = 0; i < val.fields.length; i++) {
        const field = val.fields[i];
        result[] = field.value;

      return result;

Reference example here:

1 Like

Thanks a lot Max !!!

1 Like