0.3.2 • Published 10 months ago

@apophis-sdk/cosmos v0.3.2

Weekly downloads
-
License
-
Repository
github
Last release
10 months ago

@apophis-sdk/cosmos

Cosmos ecosystem support for the Apophis SDK. Apophis is a strongly opinionated SDK for building web3 applications in different ecosystems.

Installation

Install with your favorite package manager's equivalent of:

npm install @apophis-sdk/core @apophis-sdk/cosmos @apophis-sdk/cosmwasm

The cosmwasm module is of course not required if the chain doesn't support CosmWasm, but most chains do. EVM support for chains like Injective, Sei or Canto is not yet implemented.

Usage

import { Apophis, Bank, Cosmos, DefaultCosmosMiddlewares, LocalSigner } from '@apophis-sdk/cosmos';

Apophis.use(DefaultCosmosMiddlewares);

const network = await Cosmos.getNetworkFromRegistry('neutrontestnet');
const signer = LocalSigner.fromMnemonic('...');

await Cosmos.ws(network).ready();

const { block } = await Cosmos.ws(network).getBlock();
console.log(block.header.hash, block.header.height, block.header.timestamp);

const tx = Cosmos.tx([
  new Bank.Send({
    fromAddress: signer.address(network),
    toAddress: signer.address(network),
    amount: [Cosmos.coin(1_000000n, 'untrn')],
  }),
]);

// true populates the `gas` field of the `tx` object
await tx.estimateGas(network, signer, true);
await signer.sign(network, tx);
const txhash = await tx.broadcast();
console.log(tx.status);

if (tx.status === 'success') {
  const result = await Cosmos.ws(network).expectTx(tx);
  console.log(result);
}

Check out the Apophis SDK GitBook for more information.

License

LGPL-3.0

0.3.2

10 months ago

0.3.1

10 months ago

0.3.0

10 months ago

0.3.0-rc.6

11 months ago

0.3.0-rc.5

11 months ago

0.3.0-rc.4

12 months ago

0.3.0-rc.3

12 months ago

0.3.0-rc.2

12 months ago

0.3.0-rc.1

12 months ago

0.2.1

12 months ago

0.2.0-fix.1

1 year ago

0.2.0

1 year ago

0.1.0-alpha.4

1 year ago

0.1.0-alpha.3

1 year ago

0.1.0-alpha.2

1 year ago