Web3 Provider Integration (Ethereum/BSC/Polygon/Avalanche)

Getting Encrypted User IDs From your Web App

Blocto injects a global API into websites at window.bloctoProvider and window.ethereum at the same time. Currently, Blocto supports networks:
  • Ethereum
  • BSC
  • Polygon
  • Avalanche (C-Chain)
Please contact Blocto team to get your app ID.

Register Push Notification

1
let web3 = new Web3(window.ethereum) // or window.tangerine or window.bloctoProvider
2
if (web3.currentProvider.isBlocto) {
3
try {
4
let encryptedUserId = await web3.currentProvider.request({
5
method: 'blocto_registerPushNotification',
6
params: ["{appId}"]
7
})
8
// send encryptedUserId to your backend
9
} catch(e) {
10
// error handling
11
// e.mesage: see the below
12
}
13
}
Copied!
Error Handling
  • blocked: user clicked the block button.
  • cancelled: user clicked the cancel button.
  • noNetworkConnection: no network connection.
  • appIdNotExist: your app id doesn't exist.
  • internal: wallet app internal error. Please contact us.