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 🙏

© 2026 – Pkg Stats / Ryan Hefner

metisdac-accessor

v0.0.2

Published

BlockchainAccessor is a frontend library that allows you to access the smart contracts of the Metis Governance. With a specified backend apiUrl, BlockchainAccessor can send transactions to Metis Governance smart contracts and decide to use gasless way acc

Readme

BlockchainAccessor

BlockchainAccessor is a frontend library that allows you to access the smart contracts of the Metis Governance. With a specified backend apiUrl, BlockchainAccessor can send transactions to Metis Governance smart contracts and decide to use gasless way according to backend settings.

Installation

npm install metisdac-accessor

Usage

Creating a BlockchainAccessor instance

To create a new instance of BlockchainAccessor, you need to provide the following parameters:

  • chainId: The ID of the blockchain network you want to connect to.
  • apiUrl: The URL of the backend API that provides access to the smart contracts.
  • signerOrProvider: An optional parameter that allows you to specify a signer or provider for the transactions.
import { BlockchainAccessor } from "metisdac-accessor";

const blockchain = await BlockchainAccessor.create({
  chainId: 599,
  apiUrl: "https://agw-dev.onrender.com/api/v2",
  signerOrProvider: provider.getSigner(),
});

Accessing Smart Contracts

Once you have created a BlockchainAccessor instance, you can access the smart contracts using the contracts property.

const dac = blockchain.contracts.DAC(dacAddress);

You can access the following smart contracts:

  • Configuration
  • DACFactory
  • DAC
  • DACHelper
  • Governance
  • Mining
  • Forwarder
  • PermitManager
  • RP

Sending Transactions

You can send transactions by calling the functions of the smart contracts.

const tx = await dac.join(0, []);

Gasless Transactions

BlockchainAccessor can decide to use gasless way according to backend settings. If gasless is enabled, the transaction will be sent without requiring the user to pay gas fees.

Full Example

import { BlockchainAccessor } from "metisdac-accessor";

async function join(blockchain: BlockchainAccessor, dacAddress: string) {
  console.log("join dac", dacAddress);
  const dac = blockchain.contracts.DAC(dacAddress);
  const tx = await dac.join(0, []);
  console.log("sent tx:", tx);
  const receipt = await tx.wait();
  console.log("receipt=", receipt);
  return tx.hash;
}

async function quit(blockchain: BlockchainAccessor, dacAddress: string) {
  console.log("quit dac", dacAddress);
  const dac = blockchain.contracts.DAC(dacAddress);
  const tx = await dac.quit();
  console.log("sent tx:", tx);
  const receipt = await tx.wait();
  console.log("receipt=", receipt);
  return tx.hash;
}

async function fetchBlockchainData() {
  //@ts-ignore
  const provider = new ethers.providers.Web3Provider(window.ethereum);
  await provider.send("eth_requestAccounts", []);
  console.log("create BlockchainAccessor");
  const blockchain = await BlockchainAccessor.create({
    chainId: 599,
    apiUrl: "https://agw-dev.onrender.com/api/v2",
    signerOrProvider: provider.getSigner(),
  });
  return blockchain;
}

function App() {
  const [blockchain, setBlockchain] = useState(null);

  useEffect(() => {
    async function fetchData() {
      const blockchainData = await fetchBlockchainData();
      setBlockchain(blockchainData);
    }

    fetchData();
  }, []);

  if (!blockchain) {
    return <div>Loading...</div>;
  }

  return (
    <div className="App">
      <DemoForm blockchain={blockchain} />
    </div>
  );
}

class DemoForm extends React.Component<{ blockchain: BlockchainAccessor }> {
  state = {
    dacAddress: "",
    tx: "-",
  };

  render() {
    return (
      <div>
        DAC:
        <input
          placeholder="dac address here"
          value={this.state.dacAddress}
          onChange={(evt) => this.updateInputValue(evt)}
        />
        <button
          onClick={async () =>
            this.setState({
              tx: await join(this.props.blockchain, this.state.dacAddress),
            })
          }
        >
          Join
        </button>
        <button
          onClick={async () =>
            this.setState({
              tx: await quit(this.props.blockchain, this.state.dacAddress),
            })
          }
        >
          Quit
        </button>
        <div>tx: {this.state.tx}</div>
      </div>
    );
  }

  updateInputValue(evt) {
    console.log("this.state.dacAddress=", this.state.dacAddress, "evt=", evt);
    this.setState({ dacAddress: evt.target.value });
  }
}

API Reference

BlockchainAccessor

create({ chainId, apiUrl, signerOrProvider }): Promise<BlockchainAccessor>

Creates a new instance of BlockchainAccessor with the specified parameters.

  • chainId: The ID of the blockchain network you want to connect to.
  • apiUrl: The URL of the backend API that provides access to the smart contracts.
  • signerOrProvider: An optional parameter that allows you to specify a signer or provider for the transactions.

Returns a Promise that resolves with a new instance of BlockchainAccessor.

Contracts

Configuration(signerOrProvider?: Signer | Provider)

Returns an instance of the Configuration smart contract.

  • signerOrProvider: An optional parameter that allows you to specify a signer or provider for the transactions.

Returns an instance of the Configuration smart contract.

DACFactory(signerOrProvider?: Signer | Provider)

Returns an instance of the DACFactory smart contract.

  • signerOrProvider: An optional parameter that allows you to specify a signer or provider for the transactions.

Returns an instance of the DACFactory smart contract.

DAC(dacAddress: string, signerOrProvider?: Signer | Provider)

Returns an instance of the DAC smart contract with the specified address.

  • dacAddress: The address of the DAC smart contract.
  • signerOrProvider: An optional parameter that allows you to specify a signer or provider for the transactions.

Returns an instance of the DAC smart contract.

DACHelper(signerOrProvider?: Signer | Provider)

Returns an instance of the DACHelper smart contract.

  • signerOrProvider: An optional parameter that allows you to specify a signer or provider for the transactions.

Returns an instance of the DACHelper smart contract.

Governance(signerOrProvider?: Signer | Provider)

Returns an instance of the Governance smart contract.

  • signerOrProvider: An optional parameter that allows you to specify a signer or provider for the transactions.

Mining(signerOrProvider?: Signer | Provider)

Returns an instance of the Mining smart contract.

  • signerOrProvider: An optional parameter that allows you to specify a signer or provider for the transactions.

Returns an instance of the EcoNode smart contract.

Forwarder(signerOrProvider?: Signer | Provider)

Returns an instance of the Forwarder smart contract.

  • signerOrProvider: An optional parameter that allows you to specify a signer or provider for the transactions.

Returns an instance of the Forwarder smart contract.

PermitManager(signerOrProvider?: Signer | Provider)

Returns an instance of the PermitManager smart contract.

  • signerOrProvider: An optional parameter that allows you to specify a signer or provider for the transactions.

Returns an instance of the PermitManager smart contract.

RP(signerOrProvider?: Signer | Provider)

Returns an instance of the RP smart contract.

  • signerOrProvider: An optional parameter that allows you to specify a signer or provider for the transactions.

Returns an instance of the RP smart contract.