CosmClient
Class
A client to interact with the cosmos hub chain.
Methods
connect
Connects to the given chain. Assigns all clients used within the chain client, if a signer is provided a signing client is assigned.
Name | Type | Description |
---|---|---|
| string | The endpoint of the chain to connect to. |
| Optional signer used to sign the messages. | |
| Optional field to set the client options. |
disconnect
Disconnects the assigned clients.
sign
Signs a given message with the connected signer.
Name | Type | Description |
---|---|---|
| EncodeObject[] | The messages to sign. |
| The fee to pay for signing. | |
| string | Optional memo to attach. Defaults to an empty string. |
broadcast
Broadcasts a given transaction to the connected client.
Name | Type | Description |
---|---|---|
| the transaction to broadcast. |
TxRaw
TxRaw is a variant of Tx that pins the signer's exact binary representationof body and auth_info. This is used for signing, broadcasting and verification. The binary serialize(tx: TxRaw)
is stored in Tendermint and the hash sha256(serialize(tx: TxRaw))
becomes the "txhash", commonly used as the transaction ID.
signAndBroadcast
Signs a given message before broadcasting it to the connected chain.
Name | Type | Description |
---|---|---|
| The messages to sign and broadcast. | |
| The fee to pay for signing and broadcasting the message. Defaults to auto if not specified. | |
| string or undefined | An optional memo to attach to the transaction. |
EncodeObject
Fee
simulateMulti
Simulates all given messages and returns a gas fee estimate.
Name | Type | Description |
---|---|---|
| The messages to simulate. | |
| The fee to pay. Defaults to auto if not specified. | |
| string or undefined | Optional memo to attach to the transaction. |
simulate
Simulates the given message and returns a gas fee estimate.
Name | Type | Description |
---|---|---|
| The message to simulate. | |
| Optional fee attached to the message. | |
| string or undefined | Optional memo to attach to the transaction. |
execute
Executes a message on the specified contract.
Name | Type | Description |
---|---|---|
| string | The contract address to execute on. |
| The execute message. | |
| string or undefined | Optional memo to attach to the transaction. |
| Coin[] or udefined | Optional funds to attach along with the message. |
Msg
simulateExecute
Simulates an execute message and returns a gas fee estimate.
Name | Type | Description |
---|---|---|
| string | The contract address you are executing on. |
| The execute message to simulate. | |
| Coin[] | The funds attached along with the message. |
| Optional fee for executing the message. | |
| string or undefined | Optional memo to add to the transaction. |
upload
Uploads given contract code (Uint8Array) to the chain.
Name | Type | Description |
---|---|---|
| Uint8Array | The wasm binary code to upload to the connected client. |
| Fee | Fee to pay for uploading. |
| string or undefined | Optional memo to add to the transaction. |
simulateUpload
Simulate an upload message and returns a gas fee estimate.
Name | Type | Description |
---|---|---|
| Uint8Array | The wasm binary code to simulate uploading. |
| Fee to pay for uploading. | |
| string or undefined | Optional memo to add to the transaction. |
instantiate
Instantiates a contract with the given code id using the provided instantiate message.
Name | Type | Description |
---|---|---|
| number | The code Id of the contract to instantiate. |
| The instantiation message. | |
| string | A label for the instantiation. Can be any string such as " instantiating a CW721" or "my_label" ect... |
| Fee to pay for instantiation. Defaults to auto. | |
| The options of an .instantiate() call. All properties are optional. |
simulateInstantiate
Simulates an instantiation message and returns a gas fee estimate.
Name | Type | Description |
---|---|---|
| number | The code Id of the contract to simulate instantiating. |
| The instantiation message. | |
| string | A label for the instantiation. Can be any string such as " instantiating a CW721" or "my_label" ect... |
| Fee to pay for instantiation. Defaults to auto. | |
| The options of an .instantiate() call. All properties are optional. |
migrate
Migrates a contract to a given code id.
Name | Type | Description |
---|---|---|
| string | The address of the contract that you want to migrate. |
| number | The code Id to migrate to. |
| The migrate message. | |
| The fee to pay for the migration. | |
| string or undefined | Optional memo to attach to the transaction. |
simulateMigrate
Simulates a migrate message for a given contract address, code id and migrate message and returns a gas estimate.
Name | Type | Description |
---|---|---|
| string | The contract address that you want to migrate. |
| number | The code Id to migrate to. |
| Msg | The migrate message. |
| Optional fee to pay to send the funds. | |
| string | Optional memo to attach to the transaction. |
sendTokens
Sends tokens from the signing address to the provided receiving address.
Last updated