npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@daohaus/tx-builder

v0.5.3

Published

This feature allows your React application to easily make transactions with all the JavaScript app lifecycle functions baked-in to trigger error and success messages, along with other cool features. Transactions are at the core of our platform, so we desi

Downloads

318

Readme

@daohaus/tx-builder

This feature allows your React application to easily make transactions with all the JavaScript app lifecycle functions baked-in to trigger error and success messages, along with other cool features. Transactions are at the core of our platform, so we designed this library to provide helper utilities for this purpose.

The core element is a React Context that bundles together generic transaction calls with subgraph polling within the function. This provides lifecycle methods that we can use to control UI based on synchronized events from within the React component.

The package uses Viem.

Related packages

View on NPM

Usage

Installation

yarn add @daohaus/tx-builder

Requirements

Graph API Keys If you are trying to query for data on Etheruem Mainnet or Gnosis Chain (and more to come) you will need to provide an API key from TheGraph. Learn to get those here and here.

RPC endpoints This package makes transaction to the blockchain so you will also need to provide RPC endpoints for the chains you are targeting.

Blockchain Explorer API keys This package fetches ABIs in some instances if you are not providing the ABI in the txLego. You can provide those keys from etherscan flavored explorers if needed.

<TXBuilder
  ...
  //all other props
  chainId={'0x1'}
  graphApiKeys={{'0x1': 'some api key'}}
  rpcs={{'0x1': 'some rpc url'}}
  explorerKeys={{'0x1': 'some explorer api key'}}
>
  {children}
</TXBuilder>

How to add to you application Tx-builder uses Viem and requires you to pass a publicClient as a prop. This example shows a component wrapped in our DHConnectProvider from the @daohaus/connect package that set up a publicClient upon wallet connection.

import { TXBuilder } from '@daohaus/tx-builder';

export const SomePage = () => {
  const { publicClient } = useDHConnect();

  return (
    <TXBuilder publicClient={publicClient} chainId={'0x1'} daoId={'0xsomedaoaddress'} safeId={'0x0somedaosafeaddress'}>
      {children}
    </TXBuilder>
  );
};

| Prop Name | | | -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | chainId | target network chain id | | daoId | target dao contract addresss | | safeId | target dao's main treasury safe contract addresss | | publicClient | viem public client | | appState | object of arbitrary state data passed to the tx-builder | | txLifeCycleFns | custom functions to be run on tx lifecycle moments - view here | | localABIs | custom abis you might want to pass to the tx-builder, these can be added in your txLego as well | | rpcs | list of rpc endpoints by chain id | | graphApiKeys | list of graph api keys by chain id (required for mainnet and gnosis chain) | | explorerKeys | list of etherscan explorer keys by chain id |

Examples

TODO: link to these when the new docs app is ready.

Here is a tutorial on form and transaction building.

[Here are some examples]( of contract and transaction legos used in tx-builder.

How to fire a transaction

Tx Builder exposes several handy functions that can be used throughout your app. These can be accessed by importing useTxBuilder from Tx Builder:

// Anywhere in your app

import { useTxBuilder } from '@daohaus/tx-builder-feature';

...

const { fireTransaction } = useTxBuilder();

...

  fireTransaction({
    tx: ACTION_TX.SOME_TX_LEGO,
    lifeCycleFns:{
      onTxSuccess: () => {
        console.log('do something on success');
      },
    };

For a detailed example, refer to the CancelProposal.tsx our Admin App.

Building

Run nx tx-builder:build to build the library.