-
Notifications
You must be signed in to change notification settings - Fork 340
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
Broadcasting transaction failed with code 7 #1577
Comments
@webmaster128 can you help with the payload for MsgExec |
I do have a similar issue. This is my code. import { DirectSecp256k1HdWallet, Registry } from "@cosmjs/proto-signing";
import { SigningStargateClient, GasPrice } from "@cosmjs/stargate";
import { MsgExec } from "cosmjs-types/cosmos/authz/v1beta1/tx";
import { MsgVote } from "cosmjs-types/cosmos/gov/v1/tx";
import { VoteOption } from "cosmjs-types/cosmos/gov/v1/gov";
// Registry for adding custom messages
const registry = new Registry();
registry.register("/cosmos.authz.v1beta1.MsgExec", MsgExec);
registry.register("/cosmos.gov.v1.MsgVote", MsgVote);
async function voteOnProposal(chainConfig: any, mnemonic: string) {
const { rpcEndpoint, gasPrices, prefix } = chainConfig;
const wallet = await DirectSecp256k1HdWallet.fromMnemonic(mnemonic, {
prefix
});
const client = await SigningStargateClient.connectWithSigner(
rpcEndpoint,
wallet,
{
registry,
gasPrice: GasPrice.fromString(gasPrices)
}
);
const [{ address }] = await wallet.getAccounts();
await client.signAndBroadcast(
address[
{
typeUrl: "/cosmos.authz.v1beta1.MsgExec",
value: {
grantee: address,
msgs: [
{
typeUrl: "/cosmos.gov.v1.MsgVote",
value: {
option: VoteOption.VOTE_OPTION_YES,
proposal_id,
voter
}
}
]
}
}
],
{
amount: [{ denom: "uatom", amount: "2000" }],
gas: "200000"
},
""
);
} This is my error:
Does anyone have suggestions for resolving this issue? |
From Cosmos dev thread, reference https://github.com/eco-stake/restake-ui/blob/9c28425db989689cc63b6625de367f14909cf01f/src/components/VoteForm.js#L9. Most likely missing registry encodings like novi had above Their solution: import { MsgVote } from "cosmjs-types/cosmos/gov/v1/tx";
const registry = new Registry();
registry.register("/cosmos.authz.v1beta1.MsgExec", MsgExec);
registry.register("/cosmos.gov.v1.MsgVote", MsgVote);
function buildExecMessage(grantee: string, messages: any) {
return {
typeUrl: "/cosmos.authz.v1beta1.MsgExec",
value: {
grantee: grantee,
msgs: messages
}
};
}
const message = buildExecMessage(grantee, [
{
typeUrl: "/cosmos.gov.v1beta1.MsgVote",
value: MsgVote.encode(
MsgVote.fromPartial({
proposalId: vote.proposalId as any,
voter: vote.voter,
option: vote.option
})
).finish()
}
]);
const response = await client.signAndBroadcast(
grantee,
[message],
{
amount: [{ denom: config.denom, amount: "2000" }],
gas: "200000"
},
""
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
BroadcastTxError: Broadcasting transaction failed with code 7 (codespace: sdk). Log: invalid from address: empty address string is not allowed: invalid address
Was trying to make a authz MsgExec (ExecMSG function below) and i get the above error.
I have attached my auth grant and msg exec code snippet below for reference
The text was updated successfully, but these errors were encountered: