Secret Network
WebsiteDiscordGithub
  • 👋INTRODUCTION
    • Secret Network Introduction
    • Secret Network Techstack
      • Private transactions - A quick summary
      • Blockchain Technology
        • Cosmos Basics
        • Tendermint
        • Cosmos SDK
        • IBC
        • CosmWasm
      • Privacy Technology
        • Encryption - Key Management
          • Overview
          • Key Derivation & Encryption Techniques
          • The Initialization Of Secret Network
          • Full Node Boostrap
          • Contract State Encryption
          • Transaction Encryption
          • Consensus seed rotation
        • Trusted Execution Environments  (TEE) —  Intel SGX
          • How Secret Network Uses SGX
          • SGX-SPS Security & Reliabillity
          • Remote Attestation
          • Trusted & Untrusted Core
          • Sealing
        • Private smart contracts - overview
  • 💻Development
    • 🏠Getting Started
      • Setting Up Your Environment
        • Cargo.toml Best Practices (Crates vs Dependencies)
      • Compile and Deploy
      • Running the Application
      • Compile and Deploy on Secret testnet (best for Javascript devs)
      • Fullstack dApp Integration
    • 🤓Secret Contracts
      • Secret Contracts & CosmWasm
        • Framework overview
        • Secret Contract Components
          • Instantiation Message
          • Execution Message
          • Query Message
          • Deps/DepsMut
          • Storage
            • Prefixed Storage
            • Singleton
            • Keymap
            • Append Store
            • Best practices
        • CosmWasm vs Secret CosmWasm
      • Secret Tokens (SNIP-20)
      • Contract - module call
      • Secret contract - Design Space/Features
        • Secret Contracts introduction
        • Gas/Fee usage
        • TPS and scalability
        • Privacy Essentials
        • Access Control
          • Viewing Keys
          • Permits
        • Trusted and untrusted data
        • Secret-VRF - on-chain Randomness
        • Privacy design
          • Mitigate privacy risks - full guide
          • Gas Evaporation & Tracking
        • Confidential Computing Layer
        • Fiat/Crypto Onboarding
        • Account abstraction
        • Fee abstraction
        • Wallet support
        • Bridge (messaging/tokens)
        • IBC (Hooks, PFM, Wasm)
        • Price Oracles
        • Auto Restaking
      • Permissioned Viewing
        • Viewing Keys
        • Permits
      • Cross Contract Communication
      • Submessages
        • get_contract_code_hash
      • Randomness API - Secret VRF
        • Native On-chain randomness
        • Randomness over IBC
      • Execution Finalization
      • Factory Contracts
      • Contract Migration
        • Manual - < v1.11
        • Native - from v1.11
      • Cross-deploy Vanilla CW and Secret Contracts
      • Testing Secret Contracts
        • Unit Tests
        • Continuous Integration
        • Datatype Handling - Uint, floats etc.
    • 👀Secret Contract - Reference, Guides, Examples
      • Starter guide - Millionaire's Problem
      • Reference Contracts
      • Open source dApps
      • Tools & Libraries
        • Network interaction SDKs
          • Secret.js (JavaScript)
          • SecretPy (Python)
          • SecretK (Kotlin)
          • Secret.NET
            • Snippets
              • Deploying a Contract
              • Send Native Coin
              • Query a Contract
              • Create a new Wallet
              • Permits
              • SNIP20
              • SNIP721
          • Shade.Js
        • LocalSecret - Devnet docker
        • Smart contract - Tools/Utils
          • Secret Toolkit
          • CW-Plus
          • Fadroma - SC framework
          • Hidden Gems
          • Other
            • Secret IDE
            • Polar
    • 🖼️Frontend Development
      • Getting Started with SecretJS
        • Usage Examples
          • Sending Queries
          • Sending Messages
          • Contract Migration
          • Wallet Integrations
          • Query Permits
          • SNIP20 (SCRT Tokens)
          • SNIP721 (Secret NFTs)
      • Feegrant
        • Understanding Feegrant allowances
        • Grant allowances
        • Using grant allowances to execute transactions
        • Using the Fee Grant Faucet
    • 📬Deployment Addresses/ API Endpoints
      • Secret (SNIP 20) token contracts list
        • SNIP Asset naming guidelines
      • Connecting to the Network
        • API Endpoints Mainnet (Secret-4)
        • API Endpoints Testnet (Pulsar-3)
        • Usage examples
        • Comparison of endpoint types
      • Create your own SNIP-25 IBC Token
  • Secret AI
    • 🤝Introduction
    • 🏗️Architecture
    • 👩‍💻Secret AI SDK
      • Setting Up Your Environment
      • Running the Application
    • 🪙Economics
    • Smart Contract Reference
      • SubscriptionManager
      • WorkerManager
      • RewardsManager
  • 🌐SecretVM - Confidential Virtual Machines
    • 🤝Introduction
    • 🏗️Architecture
    • ☑️Attestation
      • What is Attestation
      • Obtaining Attestation Data
      • Attestation Report - Key Fields
      • Chain of Trust
    • 🏁Launching a SecretVM
    • 🛠️Managing SecretVM Lifecycle
    • ✅Verifying a SecretVM
      • 🐢Full Verification
      • 🐰Quick Verification
    • 💡Best Practices for Developers
    • 📖Glossary
  • 🔓Confidential Computing Layer
    • 🧑‍🚀IBC Developer Toolkit
      • Basics
        • Overview
        • Cross-chain Messaging with IBC Hooks
          • Functions, Methods, and Data Structures
          • Typescript SDK
          • IBC-Hooks
        • IBC Relaying with Go Relayer
      • Usecases
        • Storing Encrypted Data on Secret Network
          • Key-Value store Developer Tutorial
        • Secret VRF for IBC with IBC-Hooks
        • Confidential Voting
        • Sealed Bid Auctions
      • Supported Networks
        • Mainnet
        • Testnet
    • 🤝Ethereum (EVM) Developer Toolkit
      • Basics
        • Overview
        • Connecting Metamask to Secret Network
        • SecretPath + Reown integration
        • Cross-chain Messaging
          • SecretPath
            • Architecture Overview
            • Detailed Architecture
            • SecretPath Developer Tutorials
            • Public EVM Gateway Architecture
            • How to deploy SecretPath on your chain
          • Axelar GMP
            • Architecture Overview
            • Axelar GMP Developer Tutorial
      • Usecases
        • Storing Encrypted Data on Secret Network
          • Key-Value store Developer Tutorial
        • Sealed Bid Auction
          • Sealed Bid Auction Developer Tutorial
        • Confidential Voting
          • Confidential Voting Developer Tutorial with SecretPath
        • VRF
          • Implementing VRF into any EVM Contract
          • VRF Developer Tutorial
          • Performance figures of SecretVRF vs competitors
          • Using encrypted payloads for VRF
          • Converting from Chainlink VRF to Secret VRF in four steps
        • Confidential Document Sharing
        • Tokens
          • From EVM to Secret
      • Supported Networks
        • EVM
          • EVM Mainnet
          • EVM Testnet
          • Gateway Contract ABI
        • Secret Gateway
          • SecretPath mainnet (secret-4) contracts
          • SecretPath testnet (pulsar-3) contracts
    • 🙌Solana Developer Toolkit
      • Usecases
        • Storing Encrypted Data on Secret Network
          • Key-value Store Developer Tutorial
        • VRF
          • VRF Developer Tutorial
      • Program IDs
        • Solana Mainnet & Testnet
        • Gateway Contract IDL
  • 🤫Overview, Ecosystem and Technology
    • 🚀Secret Network Overview
      • The SCRT coin
      • Private Tokens
      • Use Cases
        • Decentralized Finance (DeFi)
        • Art And Digital Media
        • Gaming
        • Data Privacy
        • Payments And Transactions
        • Communication
      • The technology
      • History
      • Roadmap (Core development)
        • Secret 2.0
      • Where To Buy SCRT?
      • Using the Testnet
    • 🐸Ecosystem Overview
      • Wallets
      • Applications
      • Explorers & tools
      • Funding
        • SCRT Labs Grants
        • Dilutive funding/VC raise
        • Community Pool
        • Developer bounties
          • SCRT Labs bounties [on-hold]
          • CCBL [on-hold]
          • CCR [On-hold]
        • Application specific
          • Shade Grants
      • Contributors & Entities
        • Validators
        • SCRT Labs
        • Secret Foundation
        • Secret Committees
          • Support
          • Governance
      • Secret Network Dictionary
  • 🔧Infrastructure
    • 🔓Use SecretCLI
      • Secretcli vs. Secretd
      • Install
      • Configuration
      • Address Types
      • Key Types
      • Generating Keys
      • Viewing Keys
      • Query Transactions
      • Send Tokens
      • Multisig Keys
      • Multisig Transactions
      • Transaction Broadcasting
      • Fees & Gas
      • Fee Distribution
      • Secret Contracts
      • Slashing
      • Minting
      • Delegating
      • Restake
      • Nodes
      • Governance
        • Creating Governance Proposals
        • Query Proposals
        • Deposits
        • Voting
    • 🔐Use Ledger hardware wallet
      • 🔐Ledger with SecretCLI
    • 🖥️Running a node/validator
      • Setting up a node/validator
        • Hardware setup
          • Hardware Compliance
          • VPS/Bare-Metal Compliance
            • Leaseweb Setup
            • PhoenixNAP Setup
            • Psychz Setup
            • nForce Setup
            • Vultr Setup
            • OVHCloud Setup
            • Microsoft Azure Setup
          • Patching your Node
          • Enclave verification
          • Registration troubleshooting
        • Testnet Setup
          • Install SGX
          • Install secretd
          • Setup Full Node
          • Testnet State Sync
          • Becoming a Testnet Validator
          • Installing CLI & Creating A New Address
        • Mainnet Setup
          • Install SGX
          • Install secretd
          • Setup Full Node
          • Quicksync / Snapshot
          • Statesync
          • Becoming A Validator
          • Installing CLI & Creating A New Address
      • Maintaining a node/validator
        • Slashing information
        • Migrating a Validator
        • Troubleshooting
        • Validator Backup
        • Server security
          • SSH authentication
          • Server configuration
          • Uncomplicated-Firewall (UFW)
          • Local CLI
        • Node Monitoring
          • Prometheus
            • Environment Preperation
            • Install Node Exporter
            • Install Prometheus
            • Configuring Prometheus
          • Grafana
            • Install Grafana
            • Grafana Dashboard
            • Next Steps
          • Docker
            • Install Docker
            • Configuration
            • Start Containers
            • Grafana Dashboard
            • Application Ports
            • Stop Containers
          • Goaccess
            • Install Goaccess
            • Setup Goaccess
        • Helpful commands
          • Query Validators
          • Bond Tokens
          • Withdraw Rewards
          • Query Delegations
          • Unbond Tokens
          • Query Unbonding-Delegations
          • Redelegate Tokens
          • Query Redelegations
          • Query Parameters
          • Query Pool
          • Query Delegations To Validator
      • API Noderunning
        • Running Multiple Nodes on the Same Server
        • Node Loadbalancing using Nginx
          • Setup Nginx
          • Example Nginx config
        • Using Auto heal to improve cluster uptime for Nginx
      • Sentry and Archive nodes
        • Mantlemint
        • Sentry Nodes
        • Archive Nodes
    • ⛓️IBC Relayers
      • Hermes
      • RLY
      • IBC channel database
    • 🆙Upgrade Instructions
      • v1.13
      • v1.12
      • v1.11
      • v1.10
      • v1.9
      • v1.8
      • v1.7
      • Shockwave Omega v1.6
      • v1.5
      • Shockwave Delta v1.4
      • Shockwave Delta v1.4 (Testnet)
      • Shockwave Alpha v1.3
      • Cosmovisor
      • Vulcan Network Upgrade (OLD)
    • ☠️Postmortems
      • SNIP-20 leaks
      • xApic
      • Secpk-Verifications Bloat
      • Earn Contract Exploit
      • Testnet Halt 95
    • ✍️Contribute to the documentation
      • Report Bugs
      • Suggest Enhancements
      • First Contribution Guide
      • Pull Request Templates
        • Update Documentation
        • Bug Fix
        • Improve Performance
        • Change Functionality
      • Style Guide
    • 🌊Versioning & Changelog
      • Secret Network v1.13
      • Secret Network v1.12
      • Secret Network v1.11
      • Secret Network v1.10
      • Secret network v1.9
      • Secret Network v1.7/1.8
      • Secret Network v1.6
      • Secret Network v1.5
      • Secret Network v1.4 (CosmWasm 1.0)
Powered by GitBook
On this page
  • Secret Network Client Setup
  • SecretJS Messages

Was this helpful?

Edit on GitHub
Export as PDF
  1. Development
  2. Frontend Development
  3. Getting Started with SecretJS
  4. Usage Examples

Sending Messages

Learn how to send messages with SecretJS.

PreviousSending QueriesNextContract Migration

Last updated 3 months ago

Was this helpful?

Secret Network Client Setup

import { SecretNetworkClient, Wallet } from "secretjs";

const wallet = new Wallet("Your mnemonic words go here");

const secretjs = new SecretNetworkClient({
  chainId: "pulsar-3",
  url: "https://pulsar.lcd.secretnodes.com",
  wallet: wallet,
  walletAddress: wallet.address,
});

SecretJS Messages

On a signer secret.js, secretjs.tx is used to broadcast transactions. Every function under secretjs.tx can receive an optional .

Used to send a complex transactions, which contains a list of messages. The messages are executed in sequence, and the transaction succeeds if all messages succeed.

For a list of all messages see:

const addMinterMsg = new MsgExecuteContract({
  sender: MY_ADDRESS,
  contract_address: MY_NFT_CONTRACT,
  code_hash: MY_NFT_CONTRACT_CODE_HASH, // optional but way faster
  msg: { add_minters: { minters: [MY_ADDRESS] } },
  sent_funds: [], // optional
});

const mintMsg = new MsgExecuteContract({
  sender: MY_ADDRESS,
  contract_address: MY_NFT_CONTRACT,
  code_hash: MY_NFT_CONTRACT_CODE_HASH, // optional but way faster
  msg: {
    mint_nft: {
      token_id: "1",
      owner: MY_ADDRESS,
      public_metadata: {
        extension: {
          image: "https://scrt.network/secretnetwork-logo-secondary-black.png",
          name: "secretnetwork-logo-secondary-black",
        },
      },
      private_metadata: {
        extension: {
          image: "https://scrt.network/secretnetwork-logo-primary-white.png",
          name: "secretnetwork-logo-primary-white",
        },
      },
    },
  },
  sent_funds: [], // optional
});

const tx = await secretjs.tx.broadcast([addMinterMsg, mintMsg], {
  gasLimit: 200_000,
});

Used to simulate a complex transactions, which contains a list of messages, without broadcasting it to the chain. Can be used to get a gas estimation or to see the output without actually committing a transaction on-chain.

The input should be exactly how you'd use it in secretjs.tx.broadcast(), except that you don't have to pass in gasLimit, gasPriceInFeeDenom & feeDenom.

Notes:

  • On mainnet, it's recommended to not simulate every transaction as this can burden your node provider. Instead, use this while testing to determine the gas limit for each of your app's transactions, then in production use hard-coded values.

  • Gas estimation is known to be a bit off, so you might need to adjust it a bit before broadcasting.

  • MsgInstantiateContract, MsgExecuteContract, MsgMigrateContract, MsgUpdateAdmin & MsgClearAdmin simulations are not supported for security reasons.

const sendToAlice = new MsgSend({
  from_address: bob,
  to_address: alice,
  amount: stringToCoins("1uscrt"),
});

const sendToEve = new MsgSend({
  from_address: bob,
  to_address: eve,
  amount: stringToCoins("1uscrt"),
});

const sim = await secretjs.tx.simulate([sendToAlice, sendToEve]);

const tx = await secretjs.tx.broadcast([sendToAlice, sendToEve], {
  // Adjust gasLimit up by 10% to account for gas estimation error
  gasLimit: Math.ceil(sim.gasInfo.gasUsed * 1.1),
});

Used to sign transactions independently from the broadcast process. This is useful when you want to keep your seed safe and sign transactions offline.

Used to send offline signed transactions.

const bob = "secret1dgqnta7fwjj6x9kusyz7n8vpl73l7wsm0gaamk";
const msg = new MsgSend({
  from_address: myAddress,
  to_address: bob,
  amount: stringToCoins("1000000uscrt"),
});

let signedTX = await secretjs.tx.signTx([msg], {
  gasLimit: 20_000,
  gasPriceInFeeDenom: 0.1,
  feeDenom: "uscrt",
});

let tx = await secretjs.tx.broadcastSignedTx(signedTX);

MsgExec attempts to execute the provided messages using authorizations granted to the grantee. Each message should have only one signer corresponding to the granter of the authorization.

MsgGrant is a request type for Grant method. It declares authorization to the grantee on behalf of the granter with the provided expiration time.

MsgRevoke revokes any authorization with the provided sdk.Msg type on the granter's account with that has been granted to the grantee.

MsgMultiSend represents an arbitrary multi-in, multi-out send message.

const tx = await secretjs.tx.bank.multiSend(
  {
    inputs: [
      {
        address: myAddress,
        coins: stringToCoins("2uscrt"),
      },
    ],
    outputs: [
      {
        address: alice,
        coins: stringToCoins("1uscrt"),
      },
      {
        address: bob,
        coins: stringToCoins("1uscrt"),
      },
    ],
  },
  {
    gasLimit: 20_000,
  },
);
##### `secretjs.tx.bank.multiSend.simulate()`

MsgSend represents a message to send coins from one account to another.

const tx = await secretjs.tx.bank.send(
  {
    from_address: myAddress,
    to_address: alice,
    amount: stringToCoins("1uscrt"),
  },
  {
    gasLimit: 20_000,
  },
);

Upload a compiled contract to Secret Network

const tx = await secretjs.tx.compute.storeCode(
  {
    sender: myAddress,
    wasm_byte_code: fs.readFileSync(
      `${__dirname}/snip20-ibc.wasm.gz`,
    ) as Uint8Array,
    source: "",
    builder: "",
  },
  {
    gasLimit: 1_000_000,
  },
);

const codeId = Number(
  tx.arrayLog.find((log) => log.type === "message" && log.key === "code_id")
    .value,
);

Instantiate a contract from code id

ateContractParams)

const tx = await secretjs.tx.compute.instantiateContract(
  {
    sender: myAddress,
    admin: myAddress, // optional admin address that can perform code migrations
    code_id: codeId,
    code_hash: codeHash, // optional but way faster
    initMsg: {
      name: "Secret SCRT",
      admin: myAddress,
      symbol: "SSCRT",
      decimals: 6,
      initial_balances: [{ address: myAddress, amount: "1" }],
      prng_seed: "eW8=",
      config: {
        public_total_supply: true,
        enable_deposit: true,
        enable_redeem: true,
        enable_mint: false,
        enable_burn: false,
      },
      supported_denoms: ["uscrt"],
    },
    label: "sSCRT",
    init_funds: [], // optional
  },
  {
    gasLimit: 100_000,
  },
);

const contractAddress = tx.arrayLog.find(
  (log) => log.type === "message" && log.key === "contract_address",
).value;

WARNING: secretjs.tx.compute simulations are not supported for security reasons.

Execute a function on a contract

const tx = await secretjs.tx.compute.executeContract(
  {
    sender: myAddress,
    contract_address: contractAddress,
    code_hash: codeHash, // optional but way faster
    msg: {
      transfer: {
        recipient: bob,
        amount: "1",
      },
    },
    sent_funds: [], // optional
  },
  {
    gasLimit: 100_000,
  },
);

WARNING: secretjs.tx.compute simulations are not supported for security reasons.

Migrate a contract's code while keeping the same address. Invokes the migrate() function on the new code.

const tx = await secretjs.tx.compute.migrateContract(
  {
    sender: myAddress,
    contract_address: contractAddress,
    code_id: newCodeId,
    code_hash: codeHash, // optional but way faster
    msg: {
      migrate_state_to_new_format: {},
    },
    sent_funds: [], // optional
  },
  {
    gasLimit: 100_000,
  },
);

WARNING: secretjs.tx.compute simulations are not supported for security reasons.

Update a contract's admin.

const tx = await secretjs.tx.compute.updateAdmin(
  {
    sender: currentAdminAddress,
    contract_address: contractAddress,
    new_admin: newAdminAddress,
  },
  {
    gasLimit: 100_000,
  },
);

WARNING: secretjs.tx.compute simulations are not supported for security reasons.

clear a contract's admin.

const tx = await secretjs.tx.compute.clearAdmin(
  {
    sender: currentAdminAddress,
    contract_address: contractAddress,
  },
  {
    gasLimit: 100_000,
  },
);

WARNING: secretjs.tx.compute simulations are not supported for security reasons.

MsgVerifyInvariant represents a message to verify a particular invariance.

MsgFundCommunityPool allows an account to directly fund the community pool.

const tx = await secretjs.tx.distribution.fundCommunityPool(
  {
    depositor: myAddress,
    amount: stringToCoins("1uscrt"),
  },
  {
    gasLimit: 20_000,
  },
);

MsgSetWithdrawAddress sets the withdraw address for a delegator (or validator self-delegation).

const tx = await secretjs.tx.distribution.setWithdrawAddress(
  {
    delegator_address: mySelfDelegatorAddress,
    withdraw_address: myOtherAddress,
  },
  {
    gasLimit: 20_000,
  },
);

MsgWithdrawDelegatorReward represents delegation withdrawal to a delegator from a single validator.

const tx = await secretjs.tx.distribution.withdrawDelegatorReward(
  {
    delegator_address: myAddress,
    validator_address: someValidatorAddress,
  },
  {
    gasLimit: 20_000,
  },
);

MsgWithdrawValidatorCommission withdraws the full commission to the validator address.

const tx = await secretjs.tx.distribution.withdrawValidatorCommission(
  {
    validator_address: myValidatorAddress,
  },
  {
    gasLimit: 20_000,
  },
);

Or a better one:

const tx = await secretjs.tx.broadcast(
  [
    new MsgWithdrawDelegatorReward({
      delegator_address: mySelfDelegatorAddress,
      validator_address: myValidatorAddress,
    }),
    new MsgWithdrawValidatorCommission({
      validator_address: myValidatorAddress,
    }),
  ],
  {
    gasLimit: 30_000,
  },
);

MsgSubmitEvidence represents a message that supports submitting arbitrary evidence of misbehavior such as equivocation or counterfactual signing.

MsgGrantAllowance adds permission for Grantee to spend up to Allowance of fees from the account of Granter.

const newWallet = new Wallet();

const txGranter = await secretjsGranter.tx.feegrant.grantAllowance({
  granter: secretjsGranter.address,
  grantee: newWallet.address,
  allowance: {
    spend_limit: stringToCoins("1000000uscrt"),
  },
});

const secretjsGrantee = new SecretNetworkClient({
  url: "http://localhost:1317",
  chainId: "secretdev-1",
  wallet: newWallet,
  walletAddress: newWallet.address,
});

// Send a tx from newWallet with secretjs.address as the fee payer
const txGrantee = await secretjsGrantee.tx.gov.submitProposal(
  {
    proposer: secretjsGrantee.address,
    initial_deposit: stringToCoins("1uscrt"),
    messages: [],
    metadata: "some_metadata",
    summary: "Send a tx without any balance",
    title: "Thanks ${secretjsGranter.address}!",
    expedited: false,
  },
  {
    feeGranter: secretjsGranter.address,
  },
);

MsgRevokeAllowance removes any existing Allowance from Granter to Grantee.

const tx = await secretjs.tx.feegrant.revokeAllowance({
  granter: secretjs.address,
  grantee: newWallet.address,
});

MsgDeposit defines a message to submit a deposit to an existing proposal.

const tx = await secretjs.tx.gov.deposit(
  {
    depositor: myAddress,
    proposal_id: someProposalId,
    amount: stringToCoins("1uscrt"),
  },
  {
    gasLimit: 20_000,
  },
);

MsgSubmitProposal defines an sdk.Msg type that supports submitting arbitrary proposal Content.

const tx = await secretjs.tx.gov.submitProposal(
  {
    proposer: myAddress,
    initial_deposit: stringToCoins("1000000uscrt"),
    messages: [],
    metadata: "some_metadata",
    summary: "summary",
    title: "some proposal",
    expedited: false,
    },
  {
    broadcastCheckIntervalMs: 100,
    gasLimit: 5_000_000,
  },
);

const proposalId = Number(
  tx.arrayLog.find(
    (log) => log.type === "submit_proposal" && log.key === "proposal_id",
  ).value,
);

MsgVote defines a message to cast a vote.

const tx = await secretjs.tx.gov.vote(
  {
    voter: myAddress,
    proposal_id: someProposalId,
    option: VoteOption.VOTE_OPTION_YES,
  },
  {
    gasLimit: 50_000,
  },
);

MsgVoteWeighted defines a message to cast a vote, with an option to split the vote.

// vote yes with 70% of my power
const tx = await secretjs.tx.gov.voteWeighted(
  {
    voter: myAddress,
    proposal_id: someProposalId,
    options: [
      // weights must sum to 1.0
      { weight: "0.7", option: VoteOption.VOTE_OPTION_YES },
      { weight: "0.3", option: VoteOption.VOTE_OPTION_ABSTAIN },
    ],
    metadata: "",
  },
  {
    gasLimit: 50_000,
  },
);

MsgUnjail defines a message to release a validator from jail.

const tx = await secretjs.tx.slashing.unjail(
  {
    validator_addr: mValidatorsAddress,
  },
  {
    gasLimit: 50_000,
  },
);

MsgBeginRedelegate defines an SDK message for performing a redelegation of coins from a delegator and source validator to a destination validator.

const tx = await secretjs.tx.staking.beginRedelegate(
  {
    delegator_address: myAddress,
    validator_src_address: someValidator,
    validator_dst_address: someOtherValidator,
    amount: stringToCoin("1uscrt"),
  },
  {
    gasLimit: 50_000,
  },
);

MsgCreateValidator defines an SDK message for creating a new validator.

const tx = await secretjs.tx.staking.createValidator(
  {
    delegator_address: myAddress,
    commission: {
      max_change_rate: 0.01, // can change +-1% every 24h
      max_rate: 0.1, // 10%
      rate: 0.05, // 5%
    },
    description: {
      moniker: "My validator's display name",
      identity: "ID on keybase.io, to have a logo on explorer and stuff",
      website: "example.com",
      security_contact: "hi@example.com",
      details: "**We** are good",
    },
    pubkey: toBase64(new Uint8Array(32).fill(1)), // validator's pubkey, to sign on validated blocks
    min_self_delegation: "1", // uscrt
    initial_delegation: stringToCoin("1uscrt"),
  },
  {
    gasLimit: 100_000,
  },
);

MsgDelegate defines an SDK message for performing a delegation of coins from a delegator to a validator.

const tx = await secretjs.tx.staking.delegate(
  {
    delegator_address: myAddress,
    validator_address: someValidatorAddress,
    amount: stringToCoin("1uscrt"),
  },
  {
    gasLimit: 50_000,
  },
);

MsgEditValidator defines an SDK message for editing an existing validator.

const tx = await secretjs.tx.staking.editValidator(
  {
    validator_address: myValidatorAddress,
    description: {
      // To edit even one item in "description you have to re-input everything
      moniker: "papaya",
      identity: "banana",
      website: "watermelon.com",
      security_contact: "sec@watermelon.com",
      details: "We are the banana papaya validator yay!",
    },
    min_self_delegation: "2",
    commission_rate: 0.04, // 4%, commission cannot be changed more than once in 24h
  },
  {
    gasLimit: 5_000_000,
  },
);

MsgUndelegate defines an SDK message for performing an undelegation from a delegate and a validator

const tx = await secretjs.tx.staking.undelegate(
  {
    delegator_address: myAddress,
    validator_address: someValidatorAddress,
    amount: stringToCoin("1uscrt"),
  },
  {
    gasLimit: 50_000,
  },
);

Input:

Simulates execution without sending a transactions. Input is exactly like the parent function. For more info see .

Input:

Simulates execution without sending a transactions. Input is exactly like the parent function. For more info see .

Input:

Simulates execution without sending a transactions. Input is exactly like the parent function. For more info see .

Input:

Simulates execution without sending a transactions. Input is exactly like the parent function. For more info see .

Input:

Simulates execution without sending a transactions. Input is exactly like the parent function. For more info see .

Input:

Simulates execution without sending a transactions. Input is exactly like the parent function. For more info see .

Input: [MsgInstantiateContractParams](

Simulates execution without sending a transactions. Input is exactly like the parent function. For more info see .

Input:

Simulates execution without sending a transactions. Input is exactly like the parent function. For more info see .

Input:

Simulates execution without sending a transactions. Input is exactly like the parent function. For more info see .

Input:

Simulates execution without sending a transactions. Input is exactly like the parent function. For more info see .

Input:

Simulates execution without sending a transactions. Input is exactly like the parent function. For more info see .

Input:

Simulates execution without sending a transactions. Input is exactly like the parent function. For more info see .

Input:

Simulates execution without sending a transactions. Input is exactly like the parent function. For more info see .

Input:

Simulates execution without sending a transactions. Input is exactly like the parent function. For more info see .

Input:

Simulates execution without sending a transactions. Input is exactly like the parent function. For more info see .

Input:

Simulates execution without sending a transactions. Input is exactly like the parent function. For more info see .

Input:

Simulates execution without sending a transactions. Input is exactly like the parent function. For more info see .

Input:

Simulates execution without sending a transactions. Input is exactly like the parent function. For more info see .

Input:

Simulates execution without sending a transactions. Input is exactly like the parent function. For more info see .

Input:

Simulates execution without sending a transactions. Input is exactly like the parent function. For more info see .

Input:

Simulates execution without sending a transactions. Input is exactly like the parent function. For more info see .

Input:

Simulates execution without sending a transactions. Input is exactly like the parent function. For more info see .

Input:

Simulates execution without sending a transactions. Input is exactly like the parent function. For more info see .

MsgTransfer defines a msg to transfer fungible tokens (i.e Coins) between ICS20 enabled chains. See ICS Spec here:

Input:

Simulates execution without sending a transactions. Input is exactly like the parent function. For more info see .

Input:

Simulates execution without sending a transactions. Input is exactly like the parent function. For more info see .

Input:

Simulates execution without sending a transactions. Input is exactly like the parent function. For more info see .

Input:

Simulates execution without sending a transactions. Input is exactly like the parent function. For more info see .

Input:

Simulates execution without sending a transactions. Input is exactly like the parent function. For more info see .

Input:

Simulates execution without sending a transactions. Input is exactly like the parent function. For more info see .

Input:

Simulates execution without sending a transactions. Input is exactly like the parent function. For more info see .

💻
🖼️
TxOptions
Full API »
secretjs.tx.broadcast()
https://secretjs.scrt.network/interfaces/Msg
secretjs.tx.simulate()
secretjs.tx.signTx()
secretjs.tx.broadcastSignedTx()
secretjs.tx.authz.exec()
MsgExecParams
secretjs.tx.authz.exec.simulate()
secretjs.tx.simulate()
secretjs.tx.authz.grant()
MsgGrantParams
secretjs.tx.authz.grant.simulate()
secretjs.tx.simulate()
secretjs.tx.authz.revoke()
MsgRevokeParams
secretjs.tx.authz.revoke.simulate()
secretjs.tx.simulate()
secretjs.tx.bank.multiSend()
MsgMultiSendParams
secretjs.tx.simulate()
secretjs.tx.bank.send()
MsgSendParams
secretjs.tx.bank.send.simulate()
secretjs.tx.simulate()
secretjs.tx.compute.storeCode()
MsgStoreCodeParams
secretjs.tx.compute.storeCode.simulate()
secretjs.tx.simulate()
secretjs.tx.compute.instantiateContract()
https://secretjs.scrt.network/interfaces/MsgInstanti
secretjs.tx.compute.instantiateContract.simulate()
secretjs.tx.simulate()
secretjs.tx.compute.executeContract()
MsgExecuteContractParams
secretjs.tx.compute.executeContract.simulate()
secretjs.tx.simulate()
secretjs.tx.compute.migrateContract()
MsgMigrateContractParams
secretjs.tx.compute.migrateContract.simulate()
secretjs.tx.simulate()
secretjs.tx.compute.updateAdmin()
MsgUpdateAdminParams
secretjs.tx.compute.updateAdmin.simulate()
secretjs.tx.simulate()
secretjs.tx.compute.clearAdmin()
MsgClearAdminParams
secretjs.tx.compute.clearAdmin.simulate()
secretjs.tx.simulate()
secretjs.tx.crisis.verifyInvariant()
MsgVerifyInvariantParams
secretjs.tx.crisis.verifyInvariant.simulate()
secretjs.tx.simulate()
secretjs.tx.distribution.fundCommunityPool()
MsgFundCommunityPoolParams
secretjs.tx.distribution.fundCommunityPool.simulate()
secretjs.tx.simulate()
secretjs.tx.distribution.setWithdrawAddress()
MsgSetWithdrawAddressParams
secretjs.tx.distribution.setWithdrawAddress.simulate()
secretjs.tx.simulate()
secretjs.tx.distribution.withdrawDelegatorReward()
MsgWithdrawDelegatorRewardParams
secretjs.tx.distribution.withdrawDelegatorReward.simulate()
secretjs.tx.simulate()
secretjs.tx.distribution.withdrawValidatorCommission()
MsgWithdrawValidatorCommissionParams
secretjs.tx.distribution.withdrawValidatorCommission.simulate()
secretjs.tx.simulate()
secretjs.tx.evidence.submitEvidence()
MsgSubmitEvidenceParams
secretjs.tx.evidence.submitEvidence.simulate()
secretjs.tx.simulate()
secretjs.tx.feegrant.grantAllowance()
MsgGrantAllowanceParams
secretjs.tx.feegrant.grantAllowance.simulate()
secretjs.tx.simulate()
secretjs.tx.feegrant.revokeAllowance()
MsgRevokeAllowanceParams
secretjs.tx.feegrant.revokeAllowance.simulate()
secretjs.tx.simulate()
secretjs.tx.gov.deposit()
MsgDepositParams
secretjs.tx.gov.deposit.simulate()
secretjs.tx.simulate()
secretjs.tx.gov.submitProposal()
MsgSubmitProposalParams
secretjs.tx.gov.submitProposal.simulate()
secretjs.tx.simulate()
secretjs.tx.gov.vote()
MsgVoteParams
secretjs.tx.gov.vote.simulate()
secretjs.tx.simulate()
secretjs.tx.gov.voteWeighted()
MsgVoteWeightedParams
secretjs.tx.gov.voteWeighted.simulate()
secretjs.tx.simulate()
secretjs.tx.ibc.transfer()
https://github.com/cosmos/ics/tree/master/spec/ics-020-fungible-token-transfer#data-structures
MsgTransferParams
secretjs.tx.ibc.transfer.simulate()
secretjs.tx.simulate()
secretjs.tx.slashing.unjail()
MsgUnjailParams
secretjs.tx.slashing.unjail.simulate()
secretjs.tx.simulate()
secretjs.tx.staking.beginRedelegate()
MsgBeginRedelegateParams
secretjs.tx.staking.beginRedelegate.simulate()
secretjs.tx.simulate()
secretjs.tx.staking.createValidator()
MsgCreateValidatorParams
secretjs.tx.staking.createValidator.simulate()
secretjs.tx.simulate()
secretjs.tx.staking.delegate()
MsgDelegateParams
secretjs.tx.staking.delegate.simulate()
secretjs.tx.simulate()
secretjs.tx.staking.editValidator()
MsgEditValidatorParams
secretjs.tx.staking.editValidator.simulate()
secretjs.tx.simulate()
secretjs.tx.staking.undelegate()
MsgUndelegateParams
secretjs.tx.staking.undelegate.simulate()
secretjs.tx.simulate()