@nymproject/contract-clients
TypeScript icon, indicating that this package has built-in type declarations

1.2.4-rc.1 • Public • Published

Nym Smart Contract Clients

This package contains read-only query and signing clients for all Nym's smart contracts.

Usage

First install the package and its dependencies from Cosmos Stargate:

npm install @nymproject/contract-clients @cosmjs/cosmwasm-stargate @cosmjs/proto-signing

Then execute some methods, signing them with a mnemonic:

import { contracts } from '@nymproject/contract-clients';
import { SigningCosmWasmClient } from "@cosmjs/cosmwasm-stargate";
import { DirectSecp256k1HdWallet } from "@cosmjs/proto-signing";

async function main() {
  // generate a signer from a mnemonic
  const signer = await DirectSecp256k1HdWallet.fromMnemonic("...");
  const accounts = await signer.getAccounts();

  // make a signing client for the Nym Mixnet contract on mainnet
  const cosmWasmSigningClient = await SigningCosmWasmClient.connectWithSigner("https://rpc.nymtech.net:443", signer);
  const client = new contracts.Mixnet.MixnetClient(cosmWasmSigningClient, accounts[0].address, 'n17srjznxl9dvzdkpwpw24gg668wc73val88a6m5ajg6ankwvz9wtst0cznr');

  // delegate 1 NYM to mixnode with id 100
  const result = await client.delegateToMixnode({ mixId: 100 }, 'auto', undefined, [{ amount: `${1_000_000}`, denom: 'unym' }]);

  console.log(`Tx Hash = ${result.transactionHash}`);
}

Readme

Keywords

none

Package Sidebar

Install

npm i @nymproject/contract-clients

Weekly Downloads

28

Version

1.2.4-rc.1

License

Apache-2.0

Unpacked Size

202 kB

Total Files

38

Last publish

Collaborators

  • nymbot
  • mmsinclair
  • nymtech
  • jstuczyn