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

aometamask

v0.1.8

Published

the metamask plugin on vuejs

Downloads

14

Readme

aometamask

Install

npm install aometamask -S

Quick Start

main.js

import Vue from "vue";
import aometamask from "aometamask";
import "aometamask/lib/aometamask.css";
Vue.use(aometamask);

template

<aometamask />

Properties

tokenInfo: Object {symbol, decimals} 公链默认币种信息

browserurl: String 区块浏览器地址

Example
<aometamask browserurl="https://hecoinfo.com" :tokenInfo="{
	symbol: "HT",
	decimals: "18"
}" />

Contents

API

1. isMetaMaskInstalled

是否安装了 MetaMask

Returns

Boolean

Example
this.$metamask.isMetaMaskInstalled();

2. isMetaMask

是否 MetaMask

Returns

Boolean

Example
this.$metamask.isMetaMask();

3. connect

连接插件

Returns

Array<string>

Example
this.$metamask.connect().then(console.log);
> ["0x40e5A542087FA4b966209707177b103d158Fd3A4"];

4. getAccount

获取账户

Returns

Array<string>

Example
this.$metamask.getAccount().then(console.log);
> ["0x40e5A542087FA4b966209707177b103d158Fd3A4"];

5. getChainId

获取当前公链 ID

Returns

String

Example
this.$metamask.getChainId().then(console.log);
> '1'

6. getBalance

获取余额

Returns

String

Example
this.$metamask.getBalance().then(console.log);
> '1000000000000000000'

7. onChainChanged

监听公链变化

Parameters

Function

Example
this.$metamask.onChainChanged((chainId) => {
  console.log(chainId);
});

8. onAccountsChanged

监听账户变化

Parameters

Function

Example
this.$metamask.onAccountsChanged((accounts) => {
  console.log(accounts);
});
> ["0x40e5A542087FA4b966209707177b103d158Fd3A4"];

9. onMessage

监听消息

Parameters

Function

Example
this.$metamask.onMessage((message) => {
  console.log(message);
});

10. sendTx

发送交易

Parameters

transactionParameters- Object:

  • chainId: String
  • nonce: String
  • gasPrice: String
  • gas: String
  • from: String
  • to: String
  • value: String
  • data: String
Returns

String

Example
this.$metamask.sendTx({
	from: "0x6c999dbc796102774E7CF2b45eD9097a8C0F4d7A",
	to: "0x867f1469356D37313406b75c461fA057c829c749",
	value: "0xfffffff",
}).then(console.log);
> '0xddf72a5196e9464194a7377fb94831d36875f2d8ebb6f9b4829838b8bcd780ca'

11. callContract

调用合约读的方法

Parameters

contractAddress-String: 合约地址

abi-JSON|Array: 合约ABI

name-String: 调用的合约方法名

params-Array调用的合约方法需要传的参数

Example
this.$metamask.callContract("0x0298c2b32eae4da002a15f36fdf7615bea3da047", abi, 'symbol').then(console.log)

12. sendContract

调用合约写的方法

Parameters

contractAddress-String: 合约地址

abi-JSON|Array: 合约ABI

name-String: 调用的合约方法名

params-Array调用的合约方法需要传的参数

Example
this.$metamask.sendContract("0x0298c2b32eae4da002a15f36fdf7615bea3da047", abi, 'transfer', ["0x867f1469356D37313406b75c461fA057c829c749", "0x1232889"]).then(console.log)

13. onTxHash

监听交易

Parameters

txHash- String: 交易 hash

Example
this.$metamask.onTxHash('0xddf72a5196e9464194a7377fb94831d36875f2d8ebb6f9b4829838b8bcd780ca').then(console.log)
> {
	from: "0x...",
	to: "0x...",
	tansactionHash: "0x...",
	status: 1,
	blockHash: "0x...",
	blockNumber: 5388714,
	.....
}

14. getTxRecord

获取交易记录

Returns

Array:

  • address: String 地址
  • chainId: String 公链 ID
  • txHash: String 交易 hash
  • status: String 交易状态 pending | success | failed
Example
this.$metamask.getTxRecord().then(console.log) >
  [{ from, to, chainId, txHash, status }];

15. getPendingTxRecord

获取 pending 状态交易记录

Returns

Array:

  • address: String 地址
  • chainId: String 公链 ID
  • txHash: String 交易 hash
  • status: String 交易状态 pending
Example
this.$metamask.getPendingTxRecord().then(console.log) >
  [{ from, to, chainId, txHash, status: "pending" }];

16. clearTxRecord

获取 pending 状态交易记录

Example
this.$metamask.clearTxRecord();

17. onTxStatusChange

监听交易状态的变化

Parameters

Function

Example
this.$metamask.onTxStatusChange((list) => {
  console.log(list); // 交易记录
});