Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to sign and send a custom message #1596

Open
ppoliani opened this issue Jun 26, 2024 · 3 comments
Open

Unable to sign and send a custom message #1596

ppoliani opened this issue Jun 26, 2024 · 3 comments

Comments

@ppoliani
Copy link

ppoliani commented Jun 26, 2024

I've been trying to sing and send a custom message using ledger. The error is the following

Error: Broadcasting transaction failed with code 4 (codespace: sdk). Log: signature verification failed; please verify account number (172), sequence (5) and chain-id (chain-1): unauthorized

Here's the code I use:

const registry = new Registry(defaultRegistryTypes)
registry.register("/chainx.vesting.MsgRelease", MsgRelease);

const aminoTypes = new AminoTypes({
  "/chainx.vesting.MsgRelease": {
    aminoType: "vesting/Release",
    toAmino: ({creator, posIndex}) => {
      return {
        creator,
        posIndex: posIndex.toString(), 
      }
    },
    fromAmino: ({creator, posIndex}) => {        
      return {
        creator,
        posIndex: BigInt(posIndex),
      }
    },
  }
});

const data = useStargateSigningClient({
  opts: {
    aminoTypes,
    registry,
  },
})
const stargate = data.data;

const message = {
  typeUrl: "/chainx.vesting.MsgRelease",
  value: MsgRelease.fromPartial({
    creator: account.data.bech32Address,
    posIndex
  }),
};
const fee = {
  amount: coins(2000, 'ustake'),
  gas: '222000',
}

const result = await stargate.signAndBroadcast(account.data.bech32Address, [message], fee);

Where

export interface MsgRelease {
  creator: string;
  posIndex: Long;
}

And here's the go struct on the chain itself

type MsgRelease struct {
	Creator  string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"`
	PosIndex uint64 `protobuf:"varint,2,opt,name=posIndex,proto3" json:"posIndex,omitempty"`
}

A few points regarding that:

  • I can send the transaction using the direct mode (directly signing with Keplr extention, no Ledger)
  • I can send the transaction using the chain's CLI. I can also see the same exact prompt on the Ledger device. Exact same to what I see when I try to sign via the web app.
  • I have tried to replace BigInt(posIndex), with simply posIndex and Long.fromString(posIndex) but to no avail.
@Wgil
Copy link

Wgil commented Jul 25, 2024

Facing the same here

@Wgil
Copy link

Wgil commented Jul 25, 2024

Please let me know if you found a solution @ppoliani

@MSalopek
Copy link

Facing the same issue.

Same as OP this also works in my case:

I can send the transaction using the direct mode (directly signing with Keplr extention, no Ledger)
I can send the transaction using the chain's CLI. I can also see the same exact prompt on the Ledger device. Exact same to what I see when I try to sign via the web app.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants