1.6.14-dev.2 • Published 2 years ago
deficonnect v1.6.14-dev.2
DeFiConnect
Installation
use npm package manager
npm install "deficonnect"
use script tag
<script type="module" src="https://unpkg.com/deficonnect/dist/index.umd.js"></script>
the global variable is: window.DeFiConnect
const connector = new window.DeFiConnect.DeFiWeb3Connector({
supportedChainIds: [1],
rpc: { 1: 'https://mainnet.infura.io/v3/INFURA_API_KEY' },
pollingInterval: 15000
})
Usage
connect wallet
if you use
web3-react
, it is easy to integrate:DeFiWeb3Connector
has implementAbstractConnector
fromweb3-react
import { DeFiWeb3Connector } from 'deficonnect'
const connector = new DeFiWeb3Connector({
supportedChainIds: [1],
rpc: { 1: 'https://mainnet.infura.io/v3/INFURA_API_KEY' },
pollingInterval: 15000
})
connector.activate()
methods for DeFiWeb3Connector
// connect to the Wallet
await connector.activate()
// disconnect the Wallet
await connector.deactivate()
events for Provider (EIP-1193)
// Subscribe to accounts change
provider.on('accountsChanged', (accounts: string[]) => {
console.log(accounts)
})
// Subscribe to chainId change
provider.on('chainChanged', (chainId: number) => {
console.log(chainId)
})
// Subscribe to session connection
provider.on('connect', () => {
console.log('connect')
})
// Subscribe to session disconnection
provider.on('disconnect', (code: number, reason: string) => {
console.log(code, reason)
})
methods for Provider
interface RequestArguments {
method: string;
params?: unknown[] | object;
}
// Send JSON RPC requests
const result = await provider.request(payload: RequestArguments);
// Close provider session
await provider.disconnect()
methods for Web3
// Get Accounts
const accounts = await web3.eth.getAccounts()
// Get Chain Id
const chainId = await web3.eth.chainId()
// Get Network Id
const networkId = await web3.eth.net.getId()
// Send Transaction
const txHash = await web3.eth.sendTransaction(tx)
// Sign Transaction
const signedTx = await web3.eth.signTransaction(tx)
// Sign Message
const signedMessage = await web3.eth.sign(msg)
// Sign Typed Data
const signedTypedData = await web3.eth.signTypedData(msg)
release package step
- change the package.json version, and create PR to master.
- approved release on CI control
- create a new tag on Github
1.6.14-dev.2
2 years ago
1.6.14-dev.0
2 years ago
1.6.14-dev.1
2 years ago
1.1.14
2 years ago
1.1.13
2 years ago
1.1.11
2 years ago
1.1.9
2 years ago
1.1.7
2 years ago
1.1.6
2 years ago
1.1.5
2 years ago
1.1.4
2 years ago
1.1.3
2 years ago
1.1.2
2 years ago
1.1.1
2 years ago
1.1.0-alpha.33
2 years ago
1.1.0-alpha.32
2 years ago
1.1.0-alpha.31
2 years ago
1.1.0-alpha.37
2 years ago
1.1.0-alpha.36
2 years ago
1.1.0-alpha.35
2 years ago
1.1.0-alpha.34
2 years ago
1.1.0-alpha.38
2 years ago
1.1.0-alpha.30
3 years ago
1.1.0-alpha.26
3 years ago
1.1.0-alpha.25
3 years ago
1.1.0-alpha.24
3 years ago
1.1.0-alpha.23
3 years ago
1.1.0-alpha.29
3 years ago
1.1.0-alpha.28
3 years ago
1.1.0-alpha.27
3 years ago
1.1.0-alpha.22
3 years ago
1.1.0-alpha.21
3 years ago
1.1.0-alpha.20
3 years ago
1.1.0-alpha.19
3 years ago
1.1.0-alpha.18
3 years ago
1.1.0-alpha.17
3 years ago
1.1.0-alpha.16
3 years ago
1.1.0-alpha.15
3 years ago
1.1.0-alpha.14
3 years ago
1.1.0-alpha.13
3 years ago
1.1.0-alpha.12
3 years ago
1.1.0-alpha.11
3 years ago
1.1.0-alpha.9
3 years ago
1.1.0-alpha.8
3 years ago