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

@celo/gas-snap

v0.5.6

Published

A MetaMask snap for sending Celo transactions with alternate gas currencies

Downloads

56

Readme

Gas Snap

A MetaMask snap for sending Celo transactions with alternate gas currencies

Open Source Love svg1

Usage

Connect to the Snap

To interact with this Snap, you will need to install MetaMask Flask, a canary distribution for developers that provides access to upcoming features.

Then use Snap ID to connect to this Snap:

const snapId = 'npm:@celo/gas-snap';

async function connect() {
  let requestParams = {};
  requestParams[snapId] = {};
  const result = await ethereum.request({
    method: 'wallet_requestSnaps',
    params: requestParams,
  });

  if (result) {
    // user is now connected
    console.log("connected")
  }
}
  

Simple Transfer Example

Once connected, you can call the RPC method exposed in this snap as follows:


 import { CeloTransactionRequest } from '@celo-tools/celo-ethers-wrapper';

 const tx: CeloTransactionRequest = {
        to: <address>,
        value: ethers.utils.parseUnits("1", "wei")
    }
 const result = await ethereum.request({
  method: 'wallet_invokeSnap',
  params: {
    snapId: snapId,
    request: {
      method: 'celo_sendTransaction',
      params: {
          tx
      }
    },
  },
});

console.log(result);
  

MetaMask will automatically fetch the Snap from the npm registry.

Please refer to the documentation for more about the parameters field https://docs.metamask.io/snaps/reference/rpc-api/#example-1

More Generic Transaction Example

This example shows how one can use the snap to send a more generic transaction.


  import { CeloTransactionRequest } from '@celo-tools/celo-ethers-wrapper';

  const abi = ['function deposit() external payable']
  const iface = new ethers.utils.Interface(abi)
  const data = iface.encodeFunctionData("deposit")

  let tx: CeloTransactionRequest = {
      from: <wallet_address>,
      to: <destination_contract_address>,
      data
      value: ethers.utils.parseUnits("1", "wei")
  }

  const result = await ethereum.request({
    method: 'wallet_invokeSnap',
    params: {
      snapId: snapId,
      request: {
        method: 'celo_sendTransaction',
        params: {
            tx
        }
      },
    },
  });
  

Publishing a new version of the Snap.

In other to update the snap to publish a new change, Update the version tag in both packages/snap/snap.config.js and packages/snap/pakcage.json to the same. Then from you console run the following commands.

Note: You must be logged into NPM on your terminal as well as added to the celo organization on npm.

cd packages/snap

npm publish --access public

Register a new coin type.

To Register a new coin type, add a new entry snap_getBip44Entropy with the desired coin type. See list for reference. https://github.com/satoshilabs/slips/blob/master/slip-0044.md