Sending Messages
Learn how to send messages with SecretJS.
Secret Network Client Setup
SecretJS Messages
On a signer secret.js, secretjs.tx
is used to broadcast transactions. Every function under secretjs.tx
can receive an optional TxOptions.
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: https://secretjs.scrt.network/interfaces/Msg
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.
Used to sign transactions independently from the broadcast process. This is useful when you want to keep your seed safe and sign transactions offline.
secretjs.tx.broadcastSignedTx()
Used to send offline signed transactions.
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.
Input: MsgExecParams
secretjs.tx.authz.exec.simulate()
Simulates execution without sending a transactions. Input is exactly like the parent function. For more info see secretjs.tx.simulate()
.
MsgGrant is a request type for Grant method. It declares authorization to the grantee on behalf of the granter with the provided expiration time.
Input: MsgGrantParams
secretjs.tx.authz.grant.simulate()
Simulates execution without sending a transactions. Input is exactly like the parent function. For more info see secretjs.tx.simulate()
.
MsgRevoke revokes any authorization with the provided sdk.Msg type on the granter's account with that has been granted to the grantee.
Input: MsgRevokeParams
secretjs.tx.authz.revoke.simulate()
Simulates execution without sending a transactions. Input is exactly like the parent function. For more info see secretjs.tx.simulate()
.
MsgMultiSend represents an arbitrary multi-in, multi-out send message.
Input: MsgMultiSendParams
Simulates execution without sending a transactions. Input is exactly like the parent function. For more info see secretjs.tx.simulate()
.
MsgSend represents a message to send coins from one account to another.
Input: MsgSendParams
secretjs.tx.bank.send.simulate()
Simulates execution without sending a transactions. Input is exactly like the parent function. For more info see secretjs.tx.simulate()
.
secretjs.tx.compute.storeCode()
Upload a compiled contract to Secret Network
Input: MsgStoreCodeParams
secretjs.tx.compute.storeCode.simulate()
Simulates execution without sending a transactions. Input is exactly like the parent function. For more info see secretjs.tx.simulate()
.
secretjs.tx.compute.instantiateContract()
Instantiate a contract from code id
Input: [MsgInstantiateContractParams](https://secretjs.scrt.network/interfaces/MsgInstanti
ateContractParams)
secretjs.tx.compute.instantiateContract.simulate()
Simulates execution without sending a transactions. Input is exactly like the parent function. For more info see secretjs.tx.simulate()
.
WARNING: secretjs.tx.compute
simulations are not supported for security reasons.
secretjs.tx.compute.executeContract()
Execute a function on a contract
Input: MsgExecuteContractParams
secretjs.tx.compute.executeContract.simulate()
Simulates execution without sending a transactions. Input is exactly like the parent function. For more info see secretjs.tx.simulate()
.
WARNING: secretjs.tx.compute
simulations are not supported for security reasons.
secretjs.tx.compute.migrateContract()
Migrate a contract's code while keeping the same address. Invokes the migrate()
function on the new code.
Input: MsgMigrateContractParams
secretjs.tx.compute.migrateContract.simulate()
Simulates execution without sending a transactions. Input is exactly like the parent function. For more info see secretjs.tx.simulate()
.
WARNING: secretjs.tx.compute
simulations are not supported for security reasons.
secretjs.tx.compute.updateAdmin()
Update a contract's admin.
Input: MsgUpdateAdminParams
secretjs.tx.compute.updateAdmin.simulate()
Simulates execution without sending a transactions. Input is exactly like the parent function. For more info see secretjs.tx.simulate()
.
WARNING: secretjs.tx.compute
simulations are not supported for security reasons.
secretjs.tx.compute.clearAdmin()
clear a contract's admin.
Input: MsgClearAdminParams
secretjs.tx.compute.clearAdmin.simulate()
Simulates execution without sending a transactions. Input is exactly like the parent function. For more info see secretjs.tx.simulate()
.
WARNING: secretjs.tx.compute
simulations are not supported for security reasons.
secretjs.tx.crisis.verifyInvariant()
MsgVerifyInvariant represents a message to verify a particular invariance.
Input: MsgVerifyInvariantParams
secretjs.tx.crisis.verifyInvariant.simulate()
Simulates execution without sending a transactions. Input is exactly like the parent function. For more info see secretjs.tx.simulate()
.
secretjs.tx.distribution.fundCommunityPool()
MsgFundCommunityPool allows an account to directly fund the community pool.
Input: MsgFundCommunityPoolParams
secretjs.tx.distribution.fundCommunityPool.simulate()
Simulates execution without sending a transactions. Input is exactly like the parent function. For more info see secretjs.tx.simulate()
.
secretjs.tx.distribution.setWithdrawAddress()
MsgSetWithdrawAddress sets the withdraw address for a delegator (or validator self-delegation).
Input: MsgSetWithdrawAddressParams
secretjs.tx.distribution.setWithdrawAddress.simulate()
Simulates execution without sending a transactions. Input is exactly like the parent function. For more info see secretjs.tx.simulate()
.
secretjs.tx.distribution.withdrawDelegatorReward()
MsgWithdrawDelegatorReward represents delegation withdrawal to a delegator from a single validator.
Input: MsgWithdrawDelegatorRewardParams
secretjs.tx.distribution.withdrawDelegatorReward.simulate()
Simulates execution without sending a transactions. Input is exactly like the parent function. For more info see secretjs.tx.simulate()
.
secretjs.tx.distribution.withdrawValidatorCommission()
MsgWithdrawValidatorCommission withdraws the full commission to the validator address.
Input: MsgWithdrawValidatorCommissionParams
Or a better one:
secretjs.tx.distribution.withdrawValidatorCommission.simulate()
Simulates execution without sending a transactions. Input is exactly like the parent function. For more info see secretjs.tx.simulate()
.
secretjs.tx.evidence.submitEvidence()
MsgSubmitEvidence represents a message that supports submitting arbitrary evidence of misbehavior such as equivocation or counterfactual signing.
Input: MsgSubmitEvidenceParams
secretjs.tx.evidence.submitEvidence.simulate()
Simulates execution without sending a transactions. Input is exactly like the parent function. For more info see secretjs.tx.simulate()
.
secretjs.tx.feegrant.grantAllowance()
MsgGrantAllowance adds permission for Grantee to spend up to Allowance of fees from the account of Granter.
Input: MsgGrantAllowanceParams
secretjs.tx.feegrant.grantAllowance.simulate()
Simulates execution without sending a transactions. Input is exactly like the parent function. For more info see secretjs.tx.simulate()
.
secretjs.tx.feegrant.revokeAllowance()
MsgRevokeAllowance removes any existing Allowance from Granter to Grantee.
Input: MsgRevokeAllowanceParams
secretjs.tx.feegrant.revokeAllowance.simulate()
Simulates execution without sending a transactions. Input is exactly like the parent function. For more info see secretjs.tx.simulate()
.
MsgDeposit defines a message to submit a deposit to an existing proposal.
Input: MsgDepositParams
secretjs.tx.gov.deposit.simulate()
Simulates execution without sending a transactions. Input is exactly like the parent function. For more info see secretjs.tx.simulate()
.
secretjs.tx.gov.submitProposal()
MsgSubmitProposal defines an sdk.Msg type that supports submitting arbitrary proposal Content.
Input: MsgSubmitProposalParams
secretjs.tx.gov.submitProposal.simulate()
Simulates execution without sending a transactions. Input is exactly like the parent function. For more info see secretjs.tx.simulate()
.
MsgVote defines a message to cast a vote.
Input: MsgVoteParams
secretjs.tx.gov.vote.simulate()
Simulates execution without sending a transactions. Input is exactly like the parent function. For more info see secretjs.tx.simulate()
.
secretjs.tx.gov.voteWeighted()
MsgVoteWeighted defines a message to cast a vote, with an option to split the vote.
Input: MsgVoteWeightedParams
secretjs.tx.gov.voteWeighted.simulate()
Simulates execution without sending a transactions. Input is exactly like the parent function. For more info see secretjs.tx.simulate()
.
MsgTransfer defines a msg to transfer fungible tokens (i.e Coins) between ICS20 enabled chains. See ICS Spec here: https://github.com/cosmos/ics/tree/master/spec/ics-020-fungible-token-transfer#data-structures
Input: MsgTransferParams
secretjs.tx.ibc.transfer.simulate()
Simulates execution without sending a transactions. Input is exactly like the parent function. For more info see secretjs.tx.simulate()
.
MsgUnjail defines a message to release a validator from jail.
Input: MsgUnjailParams
secretjs.tx.slashing.unjail.simulate()
Simulates execution without sending a transactions. Input is exactly like the parent function. For more info see secretjs.tx.simulate()
.
secretjs.tx.staking.beginRedelegate()
MsgBeginRedelegate defines an SDK message for performing a redelegation of coins from a delegator and source validator to a destination validator.
Input: MsgBeginRedelegateParams
secretjs.tx.staking.beginRedelegate.simulate()
Simulates execution without sending a transactions. Input is exactly like the parent function. For more info see secretjs.tx.simulate()
.
secretjs.tx.staking.createValidator()
MsgCreateValidator defines an SDK message for creating a new validator.
Input: MsgCreateValidatorParams
secretjs.tx.staking.createValidator.simulate()
Simulates execution without sending a transactions. Input is exactly like the parent function. For more info see secretjs.tx.simulate()
.
secretjs.tx.staking.delegate()
MsgDelegate defines an SDK message for performing a delegation of coins from a delegator to a validator.
Input: MsgDelegateParams
secretjs.tx.staking.delegate.simulate()
Simulates execution without sending a transactions. Input is exactly like the parent function. For more info see secretjs.tx.simulate()
.
secretjs.tx.staking.editValidator()
MsgEditValidator defines an SDK message for editing an existing validator.
Input: MsgEditValidatorParams
secretjs.tx.staking.editValidator.simulate()
Simulates execution without sending a transactions. Input is exactly like the parent function. For more info see secretjs.tx.simulate()
.
secretjs.tx.staking.undelegate()
MsgUndelegate defines an SDK message for performing an undelegation from a delegate and a validator
Input: MsgUndelegateParams
secretjs.tx.staking.undelegate.simulate()
Simulates execution without sending a transactions. Input is exactly like the parent function. For more info see secretjs.tx.simulate()
.
Last updated