# trustlessjs

> package to interact with TrustlessHub

Latest version **0.7.4-alpha.5** (published 2024-02-27) · SEE LICENSE IN LICENSE license · 0 weekly downloads

## Install

```sh
npm install trustlessjs
pnpm add trustlessjs
yarn add trustlessjs
bun add trustlessjs
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.7.4-alpha.5 |
| Published | 2024-02-27 |
| First published | 2022-03-06 |
| Weekly downloads | 0 |
| License | SEE LICENSE IN LICENSE |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 4 |
| Unpacked size | 8.6 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | danieljdd |
| Maintainers | trstlabs |

## Links

- npm: https://www.npmjs.com/package/trustlessjs
- Repository: https://github.com/trstlabs/trustlessjs
- Homepage: https://github.com/trstlabs/trustlessjs#readme
- Issues: https://github.com/trstlabs/trustlessjs/issues
- npm.io page: https://npm.io/package/trustlessjs

## Dependencies (4)

- [@cosmjs/amino](https://npm.io/package/@cosmjs/amino.md) ^0.32.0
- [@cosmjs/stargate](https://npm.io/package/@cosmjs/stargate.md) ^0.32.0
- [@cosmjs/proto-signing](https://npm.io/package/@cosmjs/proto-signing.md) ^0.32.0
- [@cosmjs/tendermint-rpc](https://npm.io/package/@cosmjs/tendermint-rpc.md) ^0.32.0

## Recent versions

- 0.7.4-alpha.5 (latest) — 2024-02-27
- 1.2.4-alpha.12 (alpha) — 2023-04-02
- 1.2.3-beta.1 (beta) — 2023-01-28
- 0.7.4-alpha.4 — 2024-02-16
- 0.7.4-alpha.3 — 2024-02-16
- 0.7.4-alpha.2 — 2024-02-16
- 0.7.3-alpha.4 — 2024-01-28
- 0.7.3-alpha.3 — 2024-01-28
- 0.7.3-alpha.2 — 2024-01-28
- 0.7.3-alpha.1 — 2024-01-28
- 0.7.2-alpha.8 — 2024-01-13
- 0.7.2-alpha.6 — 2023-08-14
- 0.7.2-alpha.5 — 2023-08-03
- 0.7.2-alpha.4 — 2023-08-01
- 0.7.2-alpha.3 — 2023-08-01
- … 51 more at https://npm.io/package/trustlessjs/versions

## README

# trustlessjs

<img src="https://docs.trustlesshub.com/assets/img/banner.05ada057.png" width="400">

## install

```sh
npm install trustlessjs
```

## Connecting with Wallets and Signing Messages

⚡️ For web interfaces, we recommend using [cosmos-kit](https://github.com/cosmology-tech/cosmos-kit). To sign and broadcast messages, you can create signers with a variety of options:

- [cosmos-kit](https://github.com/cosmology-tech/cosmos-kit/tree/main/packages/react#signing-clients) (recommended)
- [keplr](https://docs.keplr.app/api/cosmjs.html)
- [cosmjs](https://gist.github.com/webmaster128/8444d42a7eceeda2544c8a59fbd7e1d9)

### Initializing the Stargate Client

We recommend manually making the `SigningStargateClient` instance yourself by using `getTrstSigningClientOptions`:

```ts
import { getTrstSigningClientOptions, trstAccountParser } from "@trustlessjs";

const { registry, aminoTypes } = getTrstSigningClientOptions();

const client = await SigningStargateClient.connectWithSigner(
  rpc,
  offlineSigner,
  {
    registry,
    aminoTypes,
    accountParser: trstAccountParser,
  }
);
```

## Usage

We strongly recommend that you check the generated files in `src/codegen/trst` and use it as source of truth for which functions you could use.

The rest of our documentation will cover only the tip of the iceberg &mdash; examples you can take ideas from.

### RPC Client

```ts
import { trst } from "trustlessjs";

const client = await trst.ClientFactory.createRPCQueryClient({
  rpcEndpoint: RPC_ENDPOINT,
});

const balance = await client.cosmos.bank.v1beta1.allBalances({
  address: "trst1addresshere",
});
```

### Composing & Broadcasting Trst Messages

```ts
import { trst } from "trustlessjs";

const msgClaimFreeAmount =
  trst.claim.MessageComposer.withTypeUrl.claimFreeAmount({
    user: "trst1addresshere",
  });

const fee = {
  amount: [
    {
      amount: "0",
      denom: "utrst",
    },
  ],
  gas: 250_000,
};

const tx = await trstAccount.client.signAndBroadcast(
  "trst1addresshere",
  [msgClaimFreeAmount],
  fee,
  ""
);

assertIsDeliverTxSuccess(tx);
```

If you're unfamiliar with Stargate, you can read their guide [here](https://gist.github.com/webmaster128/8444d42a7eceeda2544c8a59fbd7e1d9).

#### Composing IBC Messages

```js
import { ibc } from "trustlessjs";

const { transfer } =
  ibc.applications.transfer.v1.MessageComposer.withTypeUrl.transfer({
    // Redacted (check internal types for the message parameters)
  });
```

## Developing & Publishing

When first cloning the repo:

```bash
git submodule update --init
telescope install
telescope transpile
```

### Codegen

Update the generated ts files:

```bash
yarn codegen
```

Build the module and types:

```bash
yarn build
```

### Publishing

If you haven't logged to npm cli, run:

```bash
npm login
```

Afterwards, update package.json version.

```bash
# Example: <version> = v0.4.1
git tag <version>
git push origin <version>
git push origin main
npm publish
```

## Credits

🛠 Built by Cosmology — if you like our tools, please consider delegating to [their validator ⚛️](https://cosmology.tech/validator)

Code built with the help of these related projects:

- [@cosmwasm/ts-codegen](https://github.com/CosmWasm/ts-codegen) for generated CosmWasm contract Typescript classes
- [@cosmology/telescope](https://github.com/cosmology/telescope) a "babel for the Cosmos", Telescope is a TypeScript Transpiler for Cosmos Protobufs.
- [cosmos-kit](https://github.com/cosmology-tech/cosmos-kit) A wallet connector for the Cosmos ⚛️

---
_Source: https://npm.io/package/trustlessjs · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
