Options
All
  • Public
  • Public/Protected
  • All
Menu

Secret.js Docs

Index

References

Namespaces

Enumerations

Classes

Interfaces

Type aliases

Variables

Functions

References

Renames and re-exports MsgSetWithdrawAddress
Renames and re-exports MsgWithdrawDelegationReward

Type aliases

Account: { @type: "/cosmos.auth.v1beta1.BaseAccount" | "/cosmos.auth.v1beta1.ModuleAccount" | "/cosmos.vesting.v1beta1.BaseVestingAccount" } & (BaseAccount | ModuleAccount | BaseVestingAccount)
AminoMsg: { type: string; value: any }

Type declaration

  • type: string
  • value: any
AnyJson: { @type: string } & any
ArrayLog: { key: string; msg: number; type: string; value: string }[]
Coin: { amount: string; denom: string }

Coin defines a token with a denomination and an amount.

NOTE: The amount field is an Int which implements the custom method signatures required by gogoproto.

Type declaration

  • amount: string
  • denom: string
CommissionRates: { max_change_rate: number; max_rate: number; rate: number }

CommissionRates defines the initial commission rates to be used for creating a validator.

Type declaration

  • max_change_rate: number

    max_change_rate defines the maximum daily increase of the validator commission, as a fraction.

  • max_rate: number

    max_rate defines the maximum commission rate which validator can ever charge, as a fraction.

  • rate: number

    rate is the commission rate charged to delegators, as a fraction.

CreateClientOptions: { chainId: string; encryptionSeed?: Uint8Array; encryptionUtils?: EncryptionUtils; url: string; wallet?: Signer; walletAddress?: string }

Type declaration

  • chainId: string

    The chain-id is used in encryption code & when signing txs.

  • Optional encryptionSeed?: Uint8Array

    Passing encryptionSeed will allow tx decryption at a later time. Ignored if encryptionUtils is supplied. Must be 32 bytes.

  • Optional encryptionUtils?: EncryptionUtils

    encryptionUtils overrides the default EncryptionUtilsImpl.

  • url: string

    A URL to the API service, also known as LCD, REST API or gRPC-gateway, by default on port 1317

  • Optional wallet?: Signer

    A wallet for signing transactions & permits. When wallet is supplied, walletAddress & chainId must be supplied too.

  • Optional walletAddress?: string

    walletAddress is the specific account address in the wallet that is permitted to sign transactions & permits.

GenericAuthorization: { msg: MsgGrantAuthorization }

GenericAuthorization gives the grantee unrestricted permissions to execute the provided Msg on behalf of the granter's account. The provided Msg must implement the Authorization interface: https://github.com/cosmos/cosmos-sdk/blob/c44309bc694ea8b6069ae147743f0b25dc8b52c0/x/authz/authorizations.go#L9-L25

Type declaration

Height: { revision_height: string; revision_number: string }

Height is a monotonically increasing data type that can be compared against another Height for the purposes of updating and freezing clients

Normally the RevisionHeight is incremented at each height while keeping RevisionNumber the same. However some consensus algorithms may choose to reset the height in certain conditions e.g. hard forks, state-machine breaking changes In these cases, the RevisionNumber is incremented so that height continues to be monitonically increasing even as the RevisionHeight gets reset

Type declaration

  • revision_height: string

    the height within the given revision

  • revision_number: string

    the revision that the client is currently on

Input: { address: string; coins: Coin[] }

Input models transaction input for MsgMultiSend.

Type declaration

  • address: string
  • coins: Coin[]
JsonLog: { events: { attributes: { key: string; value: string }[]; type: string }[]; msg_index: number }[]
MsgData: { data: Uint8Array; msgType: string }

MsgData defines the data returned in a Result object during message execution.

Type declaration

  • data: Uint8Array
  • msgType: string
MsgDecoder: { decode: any }

Type declaration

  • decode:function
    • decode(input: Uint8Array): any
Output: { address: string; coins: Coin[] }

Output models transaction outputs for MsgMultiSend.

Type declaration

  • address: string
  • coins: Coin[]
ParamChange: { key: string; subspace: string; value: string }

ParamChange defines an individual parameter change, for use in ParameterChangeProposal.

Type declaration

  • key: string
  • subspace: string
  • value: string
Permission: "owner" | "history" | "balance" | "allowance"
Querier: { auth: AuthQuerier; authz: AuthzQuerier; bank: BankQuerier; compute: ComputeQuerier; distribution: DistributionQuerier; evidence: EvidenceQuerier; feegrant: FeegrantQuerier; gov: GovQuerier; ibc_channel: IbcChannelQuerier; ibc_client: IbcClientQuerier; ibc_connection: IbcConnectionQuerier; ibc_transfer: IbcTransferQuerier; mauth: MauthQuerier; mint: MintQuerier; node: NodeQuerier; params: ParamsQuerier; registration: RegistrationQuerier; slashing: SlashingQuerier; snip20: Snip20Querier; snip721: Snip721Querier; staking: StakingQuerier; tendermint: TendermintQuerier; upgrade: UpgradeQuerier; getTx: any; txsQuery: any }

Type declaration

QueryContractRequest<T>: { code_hash?: string; contract_address: string; query: T }

Type parameters

  • T

Type declaration

  • Optional code_hash?: string

    The SHA256 hash value of the contract's WASM bytecode, represented as case-insensitive 64 character hex string. This is used to make sure only the contract that's being invoked can decrypt the query data.

    code_hash is an optional parameter but using it will result in way faster execution time.

    Valid examples:

    • "af74387e276be8874f07bec3a87023ee49b0e7ebe08178c49d0a49c3c98ed60e"
    • "0xaf74387e276be8874f07bec3a87023ee49b0e7ebe08178c49d0a49c3c98ed60e"
    • "AF74387E276BE8874F07BEC3A87023EE49B0E7EBE08178C49D0A49C3C98ED60E"
    • "0xAF74387E276BE8874F07BEC3A87023EE49B0E7EBE08178C49D0A49C3C98ED60E"
  • contract_address: string

    The address of the contract

  • query: T

    A JSON object that will be passed to the contract as a query

SingleMsgTx<T>: { simulate: any }

Type parameters

  • T

Type declaration

StakeAuthorization: { allow_list: string[]; authorization_type: StakeAuthorizationType; deny_list: string[]; max_tokens: Coin }

StakeAuthorization defines authorization for delegate/undelegate/redelegate.

Type declaration

  • allow_list: string[]

    allow_list specifies list of validator addresses to whom grantee can delegate tokens on behalf of granter's account.

  • authorization_type: StakeAuthorizationType

    authorization_type defines one of AuthorizationType.

  • deny_list: string[]

    deny_list specifies list of validator addresses to whom grantee can not delegate tokens.

  • max_tokens: Coin

    max_tokens specifies the maximum amount of tokens can be delegate to a validator. If it is empty, there is no spend limit and any amount of coins can be delegated.

TxOptions: { broadcastCheckIntervalMs?: number; broadcastMode?: BroadcastMode; broadcastTimeoutMs?: number; explicitSignerData?: SignerData; feeDenom?: string; feeGranter?: string; gasLimit?: number; gasPriceInFeeDenom?: number; memo?: string; waitForCommit?: boolean }

Type declaration

  • Optional broadcastCheckIntervalMs?: number

    When waiting for the tx to commit on-chain, how much time (in milliseconds) to wait between checks.

    Smaller intervals will cause more load on your node provider. Keep in mind that blocks on Secret Network take about 6 seconds to finalize.

    Defaults to 6_000. Ignored if waitForCommit = false.

  • Optional broadcastMode?: BroadcastMode

    If BroadcastMode.Sync - Broadcast transaction to mempool and wait for CheckTx response.

    see

    https://docs.tendermint.com/master/rpc/#/Tx/broadcast_tx_sync

    If BroadcastMode.Async Broadcast transaction to mempool and do not wait for CheckTx response.

    see

    https://docs.tendermint.com/master/rpc/#/Tx/broadcast_tx_async

  • Optional broadcastTimeoutMs?: number

    How much time (in milliseconds) to wait for tx to commit on-chain.

    Defaults to 60_000. Ignored if waitForCommit = false.

  • Optional explicitSignerData?: SignerData

    explicitSignerData can be used to override chainId, accountNumber & accountSequence. This is useful when using BroadcastMode.Async or when you don't want secretjs to query for accountNumber & accountSequence from the chain. (smoother in UIs, less load on your node provider).

  • Optional feeDenom?: string

    Defaults to "uscrt".

  • Optional feeGranter?: string

    Address of the fee granter from which to charge gas fees.

  • Optional gasLimit?: number

    Defaults to 25_000.

  • Optional gasPriceInFeeDenom?: number

    E.g. gasPriceInFeeDenom=0.1 & feeDenom="uscrt" => Total fee for tx is 0.1 * gasLimituscrt. Defaults to 0.1.

  • Optional memo?: string

    Defaults to "".

  • Optional waitForCommit?: boolean

    If false returns immediately with only the transactionHash field set. Defaults to true.

TxResponse: { arrayLog?: ArrayLog; code: TxResultCode; codespace: string; data: Uint8Array[]; events: "/opt/buildhome/repo/src/grpc_gateway/tendermint/abci/types.pb"[]; gasUsed: number; gasWanted: number; height: number; info: string; jsonLog?: JsonLog; rawLog: string; timestamp: string; transactionHash: string; tx: <internal>.Tx }

A transaction that is indexed as part of the transaction history

Type declaration

  • Optional Readonly arrayLog?: ArrayLog

    If code = 0, arrayLog is a flattened jsonLog. Values are decrypted if possible.

  • Readonly code: TxResultCode

    Transaction execution error code. 0 on success. See TxResultCode.

  • Readonly codespace: string

    Namespace for the Code

  • Readonly data: Uint8Array[]

    Return value (if there's any) for each input message

  • Readonly events: "/opt/buildhome/repo/src/grpc_gateway/tendermint/abci/types.pb"[]

    Events defines all the events emitted by processing a transaction. Note, these events include those emitted by processing all the messages and those emitted from the ante handler. Whereas Logs contains the events, with additional metadata, emitted only by processing the messages.

    Note: events are not decrypted.

  • Readonly gasUsed: number

    Amount of gas that was actually used by the transaction.

  • Readonly gasWanted: number

    Gas limit that was originaly set by the transaction.

  • Readonly height: number

    Block height in which the tx was committed on-chain

  • Readonly info: string

    Additional information. May be non-deterministic.

  • Optional Readonly jsonLog?: JsonLog

    If code = 0, jsonLog = JSON.parse(rawLow). Values are decrypted if possible.

  • Readonly rawLog: string

    If code != 0, rawLog contains the error.

    If code = 0 you'll probably want to use jsonLog or arrayLog. Values are not decrypted.

  • Readonly timestamp: string

    An RFC 3339 timestamp of when the tx was committed on-chain. The format is {year}-{month}-{day}T{hour}:{min}:{sec}[.{frac_sec}]Z.

  • Readonly transactionHash: string

    Transaction hash (might be used as transaction ID). Guaranteed to be non-empty upper-case hex

  • Readonly tx: <internal>.Tx

    Decoded transaction input.

TxSender: { authz: { exec: SingleMsgTx<MsgExecParams>; grant: SingleMsgTx<MsgGrantParams>; revoke: SingleMsgTx<MsgRevokeParams> }; bank: { multiSend: SingleMsgTx<MsgMultiSendParams>; send: SingleMsgTx<MsgSendParams> }; compute: { executeContract: SingleMsgTx<MsgExecuteContractParams<object>>; instantiateContract: SingleMsgTx<MsgInstantiateContractParams>; storeCode: SingleMsgTx<MsgStoreCodeParams> }; crisis: { verifyInvariant: SingleMsgTx<MsgVerifyInvariantParams> }; distribution: { fundCommunityPool: SingleMsgTx<MsgFundCommunityPoolParams>; setWithdrawAddress: SingleMsgTx<MsgSetWithdrawAddressParams>; withdrawDelegatorReward: SingleMsgTx<MsgWithdrawDelegatorRewardParams>; withdrawValidatorCommission: SingleMsgTx<MsgWithdrawValidatorCommissionParams> }; evidence: { submitEvidence: SingleMsgTx<MsgSubmitEvidenceParams> }; feegrant: { grantAllowance: SingleMsgTx<MsgGrantAllowanceParams>; revokeAllowance: SingleMsgTx<MsgRevokeAllowanceParams> }; gov: { deposit: SingleMsgTx<MsgDepositParams>; submitProposal: SingleMsgTx<MsgSubmitProposalParams>; vote: SingleMsgTx<MsgVoteParams>; voteWeighted: SingleMsgTx<MsgVoteWeightedParams> }; ibc: { transfer: SingleMsgTx<MsgTransferParams> }; registration: { register: SingleMsgTx<RaAuthenticate> }; slashing: { unjail: SingleMsgTx<MsgUnjailParams> }; snip20: { createViewingKey: SingleMsgTx<CreateViewingKeyContractParams>; decreaseAllowance: SingleMsgTx<MsgExecuteContractParams<Snip20DecreaseAllowanceOptions>>; increaseAllowance: SingleMsgTx<MsgExecuteContractParams<Snip20IncreaseAllowanceOptions>>; send: SingleMsgTx<MsgExecuteContractParams<Snip20SendOptions>>; setViewingKey: SingleMsgTx<SetViewingKeyContractParams>; transfer: SingleMsgTx<MsgExecuteContractParams<Snip20TransferOptions>> }; snip721: { addMinter: SingleMsgTx<MsgExecuteContractParams<Snip721AddMinterOptions>>; createViewingKey: SingleMsgTx<CreateViewingKeyContractParams>; mint: SingleMsgTx<MsgExecuteContractParams<Snip721MintOptions>>; send: SingleMsgTx<MsgExecuteContractParams<Snip721SendOptions>>; setViewingKey: SingleMsgTx<SetViewingKeyContractParams> }; staking: { beginRedelegate: SingleMsgTx<MsgBeginRedelegateParams>; createValidator: SingleMsgTx<MsgCreateValidatorParams>; delegate: SingleMsgTx<MsgDelegateParams>; editValidator: SingleMsgTx<MsgEditValidatorParams>; undelegate: SingleMsgTx<MsgUndelegateParams> }; vesting: { createVestingAccount: SingleMsgTx<MsgCreateVestingAccount> }; broadcast: any; broadcastSignedTx: any; signTx: any; simulate: any }

Type declaration

ValidatorDescription: { details: string; identity: string; moniker: string; security_contact: string; website: string }

Description defines a validator description.

Type declaration

  • details: string

    details define other optional details.

  • identity: string

    identity defines an optional identity signature (ex. UPort or Keybase).

  • moniker: string

    moniker defines a human-readable name for the validator.

  • security_contact: string

    security_contact defines an optional email for security contact.

  • website: string

    website defines an optional website link.

ViewingKey: string
WalletOptions: { bech32Prefix?: string; coinType?: number; hdAccountIndex?: number }

Type declaration

  • Optional bech32Prefix?: string
  • Optional coinType?: number
  • Optional hdAccountIndex?: number

Variables

MsgExecuteContractResponse: { decode: any; encode: any; fromJSON: any; fromPartial: any; toJSON: any }

Type declaration

MsgInstantiateContractResponse: { decode: any; encode: any; fromJSON: any; fromPartial: any; toJSON: any }

Type declaration

MsgRegistry: Map<string, MsgDecoder> = ...
MsgStoreCodeResponse: { decode: any; encode: any; fromJSON: any; fromPartial: any; toJSON: any }

Type declaration

Functions

  • addressToBytes(address: string): Uint8Array
  • base64PubkeyToAddress(pubkey: string, prefix?: string): string
  • Convert a secp256k1 compressed public key to a address

    Parameters

    • pubkey: string

      The account's pubkey as base64 string, should be 33 bytes (compressed secp256k1)

    • prefix: string = "secret"

    Returns string

    the account's address

  • base64TendermintPubkeyToValconsAddress(pubkey: string, prefix?: string): string
  • Convert a secp256k1 compressed public key to a address

    Parameters

    • pubkey: string

      The account's pubkey as base64 string, should be 33 bytes (compressed secp256k1)

    • prefix: string = "secret"

    Returns string

    the account's address

  • bytesToAddress(bytes: Uint8Array, prefix?: string): string
  • extractConsensusIoPubkey(cert: Uint8Array): Uint8Array
  • fromAscii(data: Uint8Array): string
  • Parameters

    • data: Uint8Array

    Returns string

  • fromBase64(base64String: string): Uint8Array
  • Parameters

    • base64String: string

    Returns Uint8Array

  • fromHex(hexstring: string): Uint8Array
  • Parameters

    • hexstring: string

    Returns Uint8Array

  • fromRfc3339(str: string): Date
  • Parameters

    • str: string

    Returns Date

  • fromUtf8(data: Uint8Array): string
  • Parameters

    • data: Uint8Array

    Returns string

  • gasToFee(gasLimit: number, gasPrice: number): number
  • getMissingCodeHashWarning(method: string): string
  • Copied here to avoid unnecessary deps

    MIT License

    Copyright (c) Kevin MÃ¥rtensson kevinmartensson@gmail.com (github.com/kevva)

    Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

    The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

    Parameters

    Returns boolean

  • newPermit(signer: AminoSigner, owner: string, chainId: string, permitName: string, allowedTokens: string[], permissions: Permission[], keplr: boolean): Promise<Permit>
  • newSignDoc(chainId: string, permit_name: string, allowed_tokens: string[], permissions: Permission[]): StdSignDoc
  • pubkeyToAddress(pubkey: Uint8Array, prefix?: string): string
  • Convert a secp256k1 compressed public key to a address

    Parameters

    • pubkey: Uint8Array

      The account's pubkey, should be 33 bytes (compressed secp256k1)

    • prefix: string = "secret"

    Returns string

    the account's address

  • selfDelegatorAddressToValidatorAddress(selfDelegator: string, prefix?: string): string
  • Convert self delegator address to validator address

    Parameters

    • selfDelegator: string

      The self delegator bech32 encoded address

    • prefix: string = "secret"

    Returns string

    the account's address

  • tendermintPubkeyToValconsAddress(pubkey: Uint8Array, prefix?: string): string
  • Convert a Tendermint ed25519 public key to a consensus address

    Parameters

    • pubkey: Uint8Array

      The tendermint pubkey, should be 32 bytes (ed25519)

    • prefix: string = "secret"

    Returns string

    the valcons account's address

  • toAscii(input: string): Uint8Array
  • Parameters

    • input: string

    Returns Uint8Array

  • toBase64(data: Uint8Array): string
  • Parameters

    • data: Uint8Array

    Returns string

  • toHex(data: Uint8Array): string
  • Parameters

    • data: Uint8Array

    Returns string

  • Parameters

    Returns string

  • toUtf8(str: string): Uint8Array
  • Parameters

    • str: string

    Returns Uint8Array

  • validatePermit(permit: Permit, address: string, contract: string, permissions: Permission[], exceptions?: boolean): boolean
  • validatorAddressToSelfDelegatorAddress(validator: string, prefix?: string): string
  • Convert self delegator address to validator address

    Parameters

    • validator: string

      The validator bech32 encoded address

    • prefix: string = "secret"

    Returns string

    the account's address