UnmarshalBinaryBare expected to read prefix bytes 75FBFAB8 (since it is registered concrete) but got 0A141DFA

I’m trying to transfer coins from Alice’s account to Bob’s account through Basecoin example. However at the first time, I couldn’t even send a Tx because of the error: ERROR: Cannot encode unregistered concrete type auth.StdTx.. So I’ve added this code: cdc.RegisterConcrete(&auth.StdTx{}, "auth/StdTx", nil) to basecoin/app/app.go. Afterward the Tx was succeded and Alice’s coin balance is shrinked. But I couldn’t find out Bab’s coin balance with below error.

$ basecli account cosmosaccaddr1rhavh905ytjwx8vqz5x8s8hxdsqfzcgrkyqdhe
panic: UnmarshalBinaryBare expected to read prefix bytes 75FBFAB8 (since it is registered concrete) but got 0A141DFA...

goroutine 1 [running]:
github.com/cosmos/cosmos-sdk/examples/basecoin/types.GetAccountDecoder.func1(0xc4209bc030, 0x29, 0x2a, 0x0, 0x0, 0x0, 0x1)
	/home/arpeggio/go/src/github.com/cosmos/cosmos-sdk/examples/basecoin/types/account.go:42 +0x18f
github.com/cosmos/cosmos-sdk/x/auth/client/cli.GetAccountCmd.func1(0xc4208be240, 0xc420133ee0, 0x1, 0x1, 0x0, 0x0)
	/home/arpeggio/go/src/github.com/cosmos/cosmos-sdk/x/auth/client/cli/account.go:63 +0x265
github.com/cosmos/cosmos-sdk/vendor/github.com/spf13/cobra.(*Command).execute(0xc4208be240, 0xc420133eb0, 0x1, 0x1, 0xc4208be240, 0xc420133eb0)
	/home/arpeggio/go/src/github.com/cosmos/cosmos-sdk/vendor/github.com/spf13/cobra/command.go:698 +0x46d
github.com/cosmos/cosmos-sdk/vendor/github.com/spf13/cobra.(*Command).ExecuteC(0x164dcc0, 0xde28c0, 0x24, 0xc4208bc34f)
	/home/arpeggio/go/src/github.com/cosmos/cosmos-sdk/vendor/github.com/spf13/cobra/command.go:783 +0x2e4
github.com/cosmos/cosmos-sdk/vendor/github.com/spf13/cobra.(*Command).Execute(0x164dcc0, 0xc4208ae8e0, 0x164dda0)
	/home/arpeggio/go/src/github.com/cosmos/cosmos-sdk/vendor/github.com/spf13/cobra/command.go:736 +0x2b
github.com/cosmos/cosmos-sdk/vendor/github.com/tendermint/tendermint/libs/cli.Executor.Execute(0x164dcc0, 0xf2bf68, 0x2, 0xc4208b2cc0)
	/home/arpeggio/go/src/github.com/cosmos/cosmos-sdk/vendor/github.com/tendermint/tendermint/libs/cli/setup.go:89 +0x4e
main.main()
	/home/arpeggio/go/src/github.com/cosmos/cosmos-sdk/examples/basecoin/cmd/basecli/main.go:79 +0x558

Here is the commands that I’ve executed and basecoind and basecli version is 0.23.1-d27c5ee.

$ basecoind init
{
  "chain_id": "test-chain-w888j8",
  "node_id": "2c67250af4e7833c7b18fbccc4822203ed95806f",
  "app_message": {
    "secret": "come drum sheriff plug analyst rubber left exclude project basic whip flash web fade figure miss check symbol initial clay useful share pencil fold"
  }
}
$ basecli keys add alice --recover
Enter a passphrase for your key:
Repeat the passphrase:
Enter your recovery seed phrase:
come drum sheriff plug analyst rubber left exclude project basic whip flash web fade figure miss check symbol initial clay useful share pencil fold
NAME:	TYPE:	ADDRESS:						PUBKEY:
alice	local	cosmosaccaddr169xee6hdmwxqtgjdyx3es9z3ca6lgnz6d80j0d	cosmosaccpub1addwnpepqv0xnw0uww22dzmejxqcjz499fxctxq3ma6glz2sdevm84uhrkez5h8szl4
$ basecli keys add bob
Enter a passphrase for your key:
Repeat the passphrase:
NAME:	TYPE:	ADDRESS:						PUBKEY:
bob	local	cosmosaccaddr1rhavh905ytjwx8vqz5x8s8hxdsqfzcgrkyqdhe	cosmosaccpub1addwnpepq289873yatnzhfuph4xun6qsthe8rxxpw83ssuevd6t83slhdqssju3k5hn
**Important** write this seed phrase in a safe place.
It is the only way to recover your account if you ever forget your password.

hotel whip course vendor syrup garment normal embody network height pluck option aim cricket awesome victory tooth cupboard room polar dumb doll kidney comfort
$ basecli keys list
NAME:	TYPE:	ADDRESS:						PUBKEY:
alice	local	cosmosaccaddr169xee6hdmwxqtgjdyx3es9z3ca6lgnz6d80j0d	cosmosaccpub1addwnpepqv0xnw0uww22dzmejxqcjz499fxctxq3ma6glz2sdevm84uhrkez5h8szl4
bob	local	cosmosaccaddr1rhavh905ytjwx8vqz5x8s8hxdsqfzcgrkyqdhe	cosmosaccpub1addwnpepq289873yatnzhfuph4xun6qsthe8rxxpw83ssuevd6t83slhdqssju3k5hn
$ basecoind start
$ basecli account cosmosaccaddr169xee6hdmwxqtgjdyx3es9z3ca6lgnz6d80j0d
{
  "type": "basecoin/Account",
  "value": {
    "BaseAccount": {
      "address": "cosmosaccaddr169xee6hdmwxqtgjdyx3es9z3ca6lgnz6d80j0d",
      "coins": [
        {
          "denom": "mycoin",
          "amount": "9007199254740992"
        }
      ],
      "public_key": null,
      "account_number": "0",
      "sequence": "0"
    },
    "name": ""
  }
}
$ basecli send --from=alice --amount=10000mycoin --to=cosmosaccaddr1rhavh905ytjwx8vqz5x8s8hxdsqfzcgrkyqdhe --sequence=0 --chain-id=test-chain-w888j8
Defaulting to account number: 0
Defaulting to next sequence number: 0
Password to sign with 'alice':
Committed at block 30. Hash: D3CB40613CDF9619E53B92EF151A93AF0FC62D22
$ basecli tx D3CB40613CDF9619E53B92EF151A93AF0FC62D22
{
  "hash": "D3CB40613CDF9619E53B92EF151A93AF0FC62D22",
  "height": "30",
  "tx": {
    "type": "auth/StdTx",
    "value": {
      "msg": [
        {
          "type": "cosmos-sdk/Send",
          "value": {
            "inputs": [
              {
                "address": "cosmosaccaddr169xee6hdmwxqtgjdyx3es9z3ca6lgnz6d80j0d",
                "coins": [
                  {
                    "denom": "mycoin",
                    "amount": "10000"
                  }
                ]
              }
            ],
            "outputs": [
              {
                "address": "cosmosaccaddr1rhavh905ytjwx8vqz5x8s8hxdsqfzcgrkyqdhe",
                "coins": [
                  {
                    "denom": "mycoin",
                    "amount": "10000"
                  }
                ]
              }
            ]
          }
        }
      ],
      "fee": {
        "amount": [
          {
            "denom": "",
            "amount": "0"
          }
        ],
        "gas": "200000"
      },
      "signatures": [
        {
          "pub_key": {
            "type": "tendermint/PubKeySecp256k1",
            "value": "Ax5pufxzlKaLeZGBiQqlKk2FmBHfdI+JUG5Zs9eXHbIq"
          },
          "signature": {
            "type": "tendermint/SignatureSecp256k1",
            "value": "MEQCIEpcp4OHzuvBWj+CRrVYkfIaJzr6pU1/Ftb7GFT6j0OcAiAZEQBsiPrWemgojRRL4mBbP+RWxJ416Wd4F3zJ9Yj/9Q=="
          },
          "account_number": "0",
          "sequence": "0"
        }
      ],
      "memo": ""
    }
  },
  "result": {
    "log": "Msg 0: ",
    "gas_used": "3084",
    "tags": [
      {
        "key": "c2VuZGVy",
        "value": "Y29zbW9zYWNjYWRkcjE2OXhlZTZoZG13eHF0Z2pkeXgzZXM5ejNjYTZsZ256NmQ4MGowZA=="
      },
      {
        "key": "cmVjaXBpZW50",
        "value": "Y29zbW9zYWNjYWRkcjFyaGF2aDkwNXl0and4OHZxejV4OHM4aHhkc3FmemNncmt5cWRoZQ=="
      }
    ],
    "fee": {}
  }
}

Should I use another version of cosmos-sdk? If so please tell me the right version.
Thank you in advance.

What version of the SDK are you using? Also I’m assuming this is basecoin?

The version is 0.23.1-d27c5ee and yes, it is basecoin example.

We have been making a bunch of changes to the SDK in preparation for the hub launch. We have not kept basecoin up to date and won’t be fixing the incompatibilities until after we launch the hub.

1 Like

I see, it seems like I need to do my homework.

I got it. The account mapper’s parameter was wrong.
I’ve changed the problematic code:

	app.accountMapper = auth.NewAccountMapper(
		cdc,
		app.keyAccount,        // target store
		auth.ProtoBaseAccount, // prototype
	)

to this:

	app.accountMapper = auth.NewAccountMapper(
		cdc,
		app.keyAccount,        // target store
		func () auth.Account {
			return &types.AppAccount{}
		},
	)

So, now I can see Bob’s balance!
Hope it helps someone.

2 Likes

If this makes basecoin work for you, want to submit a PR to the SDK?

1 Like

Yes please! We would love a PR for this!

I just submitted PR. :smiley:

1 Like