@tronweb3/tronwallet-adapter-metamask
v1.0.2
Published
Wallet adapter for Metamask wallet extension and app.
Downloads
579
Readme
@tronweb3/tronwallet-adapter-metamask
This package provides an adapter to enable DApps to connect to the MetaMask Wallet extension and MetaMask Wallet App.
Demo
import { MetaMaskAdapter } from '@tronweb3/tronwallet-adapter-metamask';
const adapter = new MetaMaskAdapter();
// connect
await adapter.connect();
// then you can get address
console.log(adapter.address);
// just use the sendTransaction method to send a transfer transaction.
const transaction = {
value: '0x' + Number(0.01 * Math.pow(10, 18)).toString(16), // 0.01 is 0.01ETH
to: 'your target address',
from: adapter.address,
};
await adapter.sendTransaction(transaction);
Documentation
API
Constructor(config: MetaMaskAdapterOptions)
import { MetaMaskAdapter } from '@tronweb3/tronwallet-adapter-metamask'; interface MetaMaskAdapterOptions { /** * Set if open MetaMask app when in mobile device. * Default is true. */ useDeeplink?: boolean; } const metaMaskAdapter = new MetaMaskAdapter({ useDeeplink: false });
More detailed API can be found in Abstract Adapter.