0.2.13 • Published 1 year ago
@axelarjs/cosmos v0.2.13
@axelarjs/cosmos
type-safe clients for axelar's cosmos node
Install
pnpm add @axelarjs/cosmos
Usage
Simulate a link
transaction
import { AXELAR_RPC_URLS } from "@axelarjs/core";
import { STANDARD_FEE } from "@axelarjs/cosmos/constants";
import { createAxelarSigningClient } from "@axelarjs/cosmos/constants/stargateClient";
import { DirectSecp256k1HdWallet } from "@cosmjs/proto-signing";
import { toAccAddress } from "@cosmjs/stargate/build/queryclient/utils";
const offlineSigner = await DirectSecp256k1HdWallet.fromMnemonic(
process.env["COSMOS_WALLET_MNEMONIC"] as string,
{ prefix: "axelar" }
);
const client = await createAxelarSigningClient(
AXELAR_RPC_URLS.testnet,
offlineSigner
);
const [accData] = await offlineSigner.getAccounts();
if (!accData) {
throw new Error("Invalid response from offlineSigner.getAccounts()");
}
const estimateGas = await client.tx.evm.link.simulate(accData.address, {
sender: toAccAddress(String(accData.address)),
recipientAddr: "0xB8Cd93C83A974649D76B1c19f311f639e62272BC",
recipientChain: "avalanche",
asset: "wavax-wei",
chain: "fantom",
});
console.log({ estimateGas });
Broadcast a link
transaction
import { AXELAR_RPC_URLS } from "@axelarjs/core";
import { STANDARD_FEE } from "@axelarjs/cosmos/constants";
import { createAxelarSigningClient } from "@axelarjs/cosmos/constants/stargateClient";
import { DirectSecp256k1HdWallet } from "@cosmjs/proto-signing";
import { toAccAddress } from "@cosmjs/stargate/build/queryclient/utils";
const offlineSigner = await DirectSecp256k1HdWallet.fromMnemonic(
process.env["COSMOS_WALLET_MNEMONIC"] as string,
{ prefix: "axelar" }
);
const client = await createAxelarSigningClient(
AXELAR_RPC_URLS.testnet,
offlineSigner
);
const [accData] = await offlineSigner.getAccounts();
if (!accData) {
throw new Error("Invalid response from offlineSigner.getAccounts()");
}
const txResponse = await client.tx.evm.link.signAndBroadcast(
accData.address,
{
sender: toAccAddress(String(accData?.address)),
recipientAddr: "0xB8Cd93C83A974649D76B1c19f311f639e62272BC",
recipientChain: "avalanche",
asset: "wavax-wei",
chain: "fantom",
},
STANDARD_FEE
);
console.log({ txResponse });
0.2.13
1 year ago
0.0.0-snapshot.b521d08
1 year ago
0.0.0-snapshot.553d9bc
1 year ago
0.0.0-snapshot.2bd8314
1 year ago
0.0.0-snapshot.99c2f0a
1 year ago
0.0.0-snapshot.9c09e70
1 year ago
0.2.12
1 year ago
0.0.0-snapshot.0d85ef8
1 year ago
0.0.0-snapshot.2f6e7cb
1 year ago
0.0.0-snapshot.8af9be9
1 year ago
0.0.0-snapshot.023598c
1 year ago
0.0.0-snapshot.2897c97
2 years ago
0.2.11
2 years ago
0.2.10
2 years ago
0.2.9
2 years ago
0.2.8
2 years ago
0.2.7
2 years ago
0.2.6
2 years ago
0.2.5
2 years ago
0.2.4
2 years ago
0.2.3
2 years ago
0.2.2
2 years ago
0.2.1
2 years ago
0.2.0
2 years ago
0.1.6
2 years ago
0.1.5
2 years ago
0.0.0-snapshot.4d5c855
2 years ago
0.1.4
2 years ago
0.0.0-snapshot.7aa3516
2 years ago
0.0.0-snapshot.188644f
2 years ago
0.1.3
2 years ago
0.1.2
2 years ago