Skip to main content

Your first transaction

Send 1 usaf to yourself on testnet. Same operation on every platform tab below.

Constants (all platforms):

NameValue
CHAIN_IDsafro-testnet-1
RPChttps://rpc.testnet.safrochain.com:443
RESThttps://rest.testnet.safrochain.com
DENOMusaf

Prerequisites: funded testnet address.

import { DirectSecp256k1HdWallet } from "@cosmjs/proto-signing";
import { SigningStargateClient, assertIsDeliverTxSuccess } from "@cosmjs/stargate";

const RPC = "https://rpc.testnet.safrochain.com:443";
const CHAIN_ID = "safro-testnet-1";
const DENOM = "usaf";

// Dev only: use Cosmos Kit offline signer in production browser apps.
const wallet = await DirectSecp256k1HdWallet.fromMnemonic(process.env.MNEMONIC!, {
prefix: "addr_safro",
});
const [{ address }] = await wallet.getAccounts();

const client = await SigningStargateClient.connectWithSigner(RPC, wallet, {
gasPrice: { denom: DENOM, amount: "0.05" },
});

const res = await client.sendTokens(address, address, [{ denom: DENOM, amount: "1" }], "auto", "first tx");
assertIsDeliverTxSuccess(res);
console.log(res.transactionHash);

Production web apps: connect via Cosmos Kit instead of a mnemonic.

Next steps