Skip to content

Instantly share code, notes, and snippets.

@ducphamle2
Last active November 15, 2024 18:40
Show Gist options
  • Select an option

  • Save ducphamle2/b2a467ceb86938dffeba71c576d56987 to your computer and use it in GitHub Desktop.

Select an option

Save ducphamle2/b2a467ceb86938dffeba71c576d56987 to your computer and use it in GitHub Desktop.
unjail a validator on Oraichain
import {
AminoTypes,
defaultRegistryTypes,
GasPrice,
SigningStargateClient
} from "@cosmjs/stargate";
import { DirectSecp256k1HdWallet, Registry } from "@cosmjs/proto-signing";
import dotenv from "dotenv";
import { ORAI } from "@oraichain/common";
import { cosmos } from "@oraichain/proto";
import { argv } from "process";
dotenv.config();
(async () => {
const signer = await DirectSecp256k1HdWallet.fromMnemonic(
// test mnemonic. don't use. Use your mnemonic
"similar wrap labor paddle nominee fringe denial manual tail once jelly gallery",
{ prefix: ORAI }
);
const accounts = await signer.getAccounts();
const address = accounts[0].address;
// registry
const registry = new Registry(defaultRegistryTypes);
// aminotypes
const aminoTypes = new AminoTypes({
...cosmos.slashing.v1beta1.AminoConverter
});
cosmos.slashing.v1beta1.load(registry);
const client = await SigningStargateClient.connectWithSigner(
"https://rpc.orai.io",
signer,
{ gasPrice: GasPrice.fromString("0.001orai"), registry, aminoTypes }
);
const unjailMsg = cosmos.slashing.v1beta1.MessageComposer.withTypeUrl.unjail({
validatorAddr: "oraivaloper1fpwwywm4jyjsgqzlyq7yhqr2ldntn8u3fw2tvd" // replace with your operator address
});
const res = await client.signAndBroadcast(address, [unjailMsg], "auto");
console.log(res);
})();
@ducphamle2
Copy link
Copy Markdown
Author

ducphamle2 commented Nov 15, 2024

package.json file:

{
  "name": "root",
  "license": "MIT",
  "type": "module",
  "scripts": {},
  "engines": {
    "node": ">=18.18.0"
  },
  "dependencies": {
    "@cosmjs/amino": "0.32.4",
    "@cosmjs/cosmwasm-stargate": "0.32.4",
    "@cosmjs/crypto": "0.32.4",
    "@cosmjs/encoding": "0.32.4",
    "@cosmjs/proto-signing": "0.32.4",
    "@cosmjs/stargate": "0.32.4",
    "@cosmjs/tendermint-rpc": "0.32.4",
    "@oraichain/common": "1.2.0",
    "@oraichain/proto": "^0.0.4",
    "axios": "^0.21.4"
  },
  "devDependencies": {
    "cosmjs-types": "0.8.0",
    "dotenv": "^16.4.5"
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment