#cosmos #signing #transaction #broadcasting #blockchain #facilitating #sdk-based

txf

A library facilitating the signing and broadcasting of transactions on Cosmos SDK-based blockchains

1 unstable release

0.1.0 Jun 27, 2023

#6 in #facilitating

Apache-2.0 OR MIT

16KB
335 lines

txf

Transaction factory - a library facilitating the signing and broadcasting of transactions (txs) on Cosmos SDK-based blockchains.

How to use

Example with ONLINE signing mode and SYNC broadcast mode:

use cosmos_sdk_proto::cosmos::{
    bank,
    base::v1beta1::{Coin, DecCoin},
    staking,
    tx::v1beta1::BroadcastMode,
};
use txf::{OnlineParams, TxBuilder};

let res = TxBuilder::new()
    .add_message(bank::v1beta1::MsgSend {
        from_address: "osmo1...",
        to_address:   "osmo1...",
        amount: vec![
            Coin {
                denom:  "...",
                amount: "...",
            },
        ],
    })?
    .add_message(staking::v1beta1::MsgDelegate {
        delegator_address: "cosmos1...",
        validator_address: "cosmos1...",
        amount: Coin {
            denom:  "...",
            amount: "...",
        },
    })?
    .set_gas_price(DecCoin {
        denom:  "uosmo".into()
        amount: "0.0025".into(),
    })
    .sign_online(OnlineParams {
        privkey:        &privkey,
        grpc_url:       grpc_url.clone(),
        bech_prefix:    "cosmos".into(),
        gas_adjustment: 1.4,
    })
    .await?
    .broadcast(grpc_url, BroadcastMode::Sync)
    .await?;

License

Either Apache-2.0 or MIT license, at your choice.

Dependencies

~16–23MB
~379K SLoC