WalletConnect
Library to connect Dapps to mobile wallets using WalletConnect
You can read more about WalletConnect standard here: http://walletconnect.org/
Install package
yarn add walletconnect
npm install --save walletconnect
Getting Started
import WalletConnect from 'walletconnect'
const webConnector = new WalletConnect(
{
bridgeUrl: 'https://bridge.walletconnect.org',
dappName: 'INSERT_DAPP_NAME',
}
)
await webConnector.initSession()
if (webConnector.isConnected) {
const accounts = webConnector.accounts
} else {
const uri = webConnector.uri;
await webConnector.listenSessionStatus()
accounts = webConnector.accounts
}
const tx = {from: '0xab12...1cd', to: '0x0', nonce: 1, gas: 100000, value: 0, data: '0x0'}
try {
const result = await webConnector.sendTransaction(tx)
} catch (error) {
console.error(error)
}
const msg = 'My email is john@doe.com - 1537836206101'
try {
const result = await webConnector.signMessage(msg)
} catch (error) {
console.error(error)
}
const msgParams = [
{
type: 'string',
name: 'Message',
value: 'My email is john@doe.com'
},
{
type: 'uint32',
name: 'A number',
value: '1537836206101'
}
]
try {
const result = await webConnector.signTypedData(msgParams)
} catch (error) {
console.error(error)
}