![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
@amfi/connect-wallet
Advanced tools
Connect Crypto Wallet by using CoinbaseWallet (WalletLink), KardiaChain, MetaMask browser extentions or mobile application and WalletConnect service by scanning Wallet Qr-code.
This package provides the ability to connect wallets to website or application via MetaMask extension (through a browser or the mobile application), WalletConnect service using QR code scanner, CoinbaseWallet extension and KardiaChain.
Via NPM
npm install @amfi/connect-wallet
Via Yarn
yarn add @amfi/connect-wallet
import { ConnectWallet } from '@amfi/connect-wallet';
const connectWallet = new ConnectWallet();
If you need to add custom blockhain use addChains(...chain)
method before you create connect.
Usage example:
/**
* Description:
*
* name - blockchain name.
* chainID - blockchain id.
* hex - blockchain id in hex format.
*/
const chains: IChain[] = [
...
{
name: 'binance',
chainID: 56,
hex: '0x38',
},
{
name: 'binance-test',
chainID: 97,
hex: '0x61',
},
...
];
connectWallet.addChains(this.chains);
connect(provider, network, settings)
.Example configuration:
Want use Ethereum mainnet?
Set useProvider:infura
and provide mainnet Infura.
Remove rpc if it needed.
/**
* Description:
*
* name - blockchain name.
* chainID - blockchain id.
* hex - blockchain id in hex format.
*/
const config = {
wallets: ['MetaMask', 'WalletConnect', 'CoinbaseWallet', 'KardiaChain'],
network: {
name: 'Ropsten',
chainID: 3,
},
provider: {
MetaMask: {
name: 'MetaMask',
},
CoinbaseWallet: {
name: 'CoinbaseWallet',
},
KardiaChain: {
name: 'KardiaChain',
},
WalletConnect: {
name: 'WalletConnect',
useProvider: 'rpc', // Used to select the type of provider below
provider: {
infura: {
infuraID: 'PASS_HERE_INFURA_ID', // Your id from Infura
},
rpc: {
rpc: {
// If you use Ethereum rpc, pass full Infura URL
3: 'https://ropsten.infura.io/v3/PASS_HERE_BLOCKCHAIN_RPC',
// For use this rpc change chainId below to 56
56: 'https://bsc-dataseed.binance.org/',
},
chainId: 3, // Used to select a rpc above
},
},
},
},
settings: {
// Add provider type from wallets in this config
providerType: true,
},
};
connectWallet.connect(config);
RPC configuration:
/**
* Description
*
* BLOCKCHAIN_NUMBER - used to identify what kind of blockhain need to use, ex.: ropsten: 3, rinkeby: 4
* BLOCKCHAIN_RPC - blockhain rpc url
* chainId - used to select rpc (equal to rpc.BLOCKCHAIN_NUMBER)
*/
rpc: {
rpc: {
// if use Ethereum rpc, pass full Infura URL with Infura Id
[BLOCKCHAIN_NUMBER]: "BLOCKCHAIN_RPC",
[BLOCKCHAIN_NUMBER]: "BLOCKCHAIN_RPC",
...
[BLOCKCHAIN_NUMBER]: "BLOCKCHAIN_RPC"
},
// What Blockchain need to use
chainId: BLOCKCHAIN_NUMBER
},
You need to pass 3 configuration options: provider, network, settings in connect()
method.
For MetaMask:
{
name: string;
}
For Wallet Connect:
{
name: string;
useProvider?: string;
provider?: {
infura?: {
infuraID?: string;
}
rpc?: {
rpc: {
[index: number]: string;
};
chainId?: number;
};
};
}
/**
* Description
*
* name - blockchain name
* chainID - blockchain id
*
* All parameters required
*/
{
name: string;
chainID: number;
}
{
// show in response your provider type: MetaMask/WalletConnect/etc.
providerType?: boolean;
}
connectWallet.connect(provider, network, settings).then(
(connected: boolean) => console.log('connect wallet: ', connected),
(err: any) => console.log('connect wallet error: ', err)
);
Need to use 3 parameters in the addContract
: ContractName, address, abi.
interface:
/**
* Description
*
* name - used to identify your contract in Connect Wallet ex.: Staking/Token
* address - provide address ex.: 0x00000000000000000
* abi - ABI from contract ex.: [{method...},{method...},{method...}]
*/
{
name: string;
address: string;
abi: Array<any>;
}
connectWallet.addContract({'Staking1', '0x000...', ABI[]}).then((i) => {},(err) => {});
connectWallet.addContract({'Staking2', '0x000...', ABI[]}).then((i) => {},(err) => {});
connectWallet.addContract({'Token', '0x000...', ABI[]}).then((i) => {},(err) => {});
To use contracr methods use method contract(CONTRACT_NAME)
.
CONTRACT_NAME
- pass your contact name that was added in step 5.
const start = connectWallet
.contract('Staking1')
.stakeStart('123')
.send({ from: '0x000...' })
.then((tx: any) => console.log(tx));
const end = connectWallet
.contract('Staking2')
.stakeEnd('123')
.send({ from: '0x000...' })
.then((tx: any) => console.log(tx));
const balance = connectWallet
.contract('Token')
.methods.balanceOf('0x000...')
.call()
.then(
(balance: string) => console.log(balance),
(err: any) => console.log(err)
);
When the Connect established, you can get information about the account of the user wallet using the getaccounts ()
method.
connectWallet.getAccounts().then(
(user: any) => console.log('account: ', user),
(err: any) => console.log('error: ', err)
);
Provide transaction Hash to txCheck()
method for check if transaction are in blockchain or not.
connectWallet.txCheck('TX_HASH').then(
(info: any) => console.log('info: ', info),
(err: any) => console.log('tx error:', err)
);
Get current Web3 and access to all Web3 functions via currentWeb3()
method.
const currentWeb3 = connectWallet.currentWeb3();
Subscribe to events from current connection: connect, disconnect, chain change, account change and etc.
connectWallet.eventSubscriber().subscribe(
(event: IEvent) => console.log('event from subscribe', event),
(err: IEventError) => console.log('event error', err)
);
FAQs
Connect Crypto Wallet by using CoinbaseWallet (WalletLink), KardiaChain, MetaMask browser extentions or mobile application and WalletConnect service by scanning Wallet Qr-code.
The npm package @amfi/connect-wallet receives a total of 64 weekly downloads. As such, @amfi/connect-wallet popularity was classified as not popular.
We found that @amfi/connect-wallet demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.