AndromedaClient
Import
import AndromedaClient from "@andromedaprotocol/andromeda.js"Class
A helper class for interacting with the Andromeda ecosystem
export default class AndromedaClient {
public chainClient?: ChainClient;
/**
* Instantiate all provided APIs
*/
public ado = new ADOAPI(this);
public schema = new ADOSchemaAPI(this);
public os = new OperatingSystemAPI(this);
/**
* A pre-message hook to check that the client is connected and functioning
* @param signed Whether the message is signed
*/
private preMessage() {
if (!this.isConnected) throw new Error("Client not connected");
}
chainClient
Client used to interact with the chain, includes a query client when connected and a signing client when connected with a signer.
Methods
connect
Connects to a new chain by endpoint.
endpoint
string
The endpoint of the chain to connect to.
kernelAddress
string
The contract address of the kernel contract.
addressPrefix
string
The prefixo of the connecting address.
assignKeyAddresses
Assigns the kernel address and fetches the VFS and ADODB addresses.
kernelAddress
string
The address of the kernel contract to assign.
disconnect
Disconnects the assigned clients.
isConnected
Getter method to indicate whether the client is currently connected.
signAndBroadcast
Wrapper function for CosmWasm sign and broadcast. Creates a transaction with the given messages, fee and memo and then signs and broadcasts the transaction.
memo
string
optional memo to the transaction.
Fee
Check StdFee.
EncodeObject
upload
Wrapper function for CosmWasm upload. Uploads code and returns a receipt, including the code ID.
code
Uint8Array
The code to upload.
memo
string
Optional memo to attatch.
execute
Wrapper function for CosmWasm execute. Execute the defined message.
instantiate
Wrapper function for CosmWasm instantiate. Instantiates the defined message.
codeId
number
The code ID of the contract to instantiate.
label
string
The label attached to instantiation.
fee
string
The fee to pay. Defaults to auto if not specified.
options
Options for the instantiate call. Includes optional admin, funds, and memo.
queryContract
Makes a smart query on the contract, returns the parsed JSON document. Promise is rejected when contract does not exist, for invalid query format, and for invalid response format.
Wrapper function for CosmWasm query.
address
string
The address of the contract to query.
Msg
migrate
Wrapper function to ComsWasm migrate.
simulateMigrate
Estimates the gas cost of sending a migrate transaction.
estimateMigrateFee
Estimates the fee cost of sending a migrate transaction.
address
string
The contract address to migrate.
codeId
number
The code Id to migrate to.
simulateExecute
Estimates the gas cost of sending an execute transaction.
simulateMsgs
Simulates provided messages returning an estimated gas cost.
simulateInstantiate
Estimates the gas cost of sending an instantiate transaction and returns it.
simulateUpload
Estimates the gas cost of sending an upload transaction.
wasmByteCode
Uint8Array
The wasm code to simulate uploading.
estimateUploadFee
Estimates the fee cost of sending an upload transaction.
wasmByteCode
Uint8Array
The wasm code to simulate uploading.
calculateFee
Wrapped around cosmjs calculateFee using client's set gasPrice. Errors if no gas price provided.
gas
number
The amount of gas.
estimateFee
Simulates provided messages and calculates an estimated fee.
msgs
EncodeObject[]
The messages to estimate the fee for.
memo
string
Optional memo to attach.
estimateExecuteFee
Estimates the fee cost of sending an execute transaction.
The fields are the same as in execute but will return an estimate of the fees instead of executing the message.
estimateInstantiationFee
Estimates the fee cost of sending an instantiate transaction and returns it.
codeId
number
The code ID of the contract to instantiate.
label
string
The label attached to instantiation
memo
string
Optional memo to attach.
getBalance
Gets the balance for a given address and denom. Defaults to the signing wallet address if none provided.
denom
string
The denom to check the balance for.
address
string
The address to check the balance for. If not specified, the address of the connected signer is used.
getSentTxsByAddress
Gets all send transactions for a given address.
addr
string
The address to get the send transactions for.
getTx
Wrapper around the cosm.js client's getTx function.
hash
string
The tx hash.
getTxsByContract
Gets all transactions sent to a contract.
addr
string
The contract address to check transactions for.
getBankTxsByAddress
Gets all bank messages sent to or from an address.
addr
string
The address to check the bank messages for.
getAllTxsByAddress
Queries all possible transactions for a given address.
addr
string
The address to get all the transactions for.
sendTokens
wrapper around the cosm.js client's sendTokens function. Send tokens to another address.
Helper Function
JsonToArray
Helper function to convert JSON to Uint8Array
json
Record<string, any>
JSON object to convert to Uint8Array
Returns the Uint8Array.
Last updated