Ethereum
Because some connectors such as the Elastos Essentials connector implement not only the Elastos connectivity methods, but also standard EVM-compatible Web3 operations (crypto operations, inherited from ethereum), applications also need a way to easily access EVM features.
In the case of the Elastos Essentials connector, the third party Wallet Connect library is used to let applications communicate with the wallet seamlessly. In the future, we believe Wallet Connect will be used by most decentralised applications, as it represents a convenient way to let 2 remote applications talk to each other, and fulfills desktop-mobile as well as mobile-mobile use cases.
The connectivity SDK provides access to possibly existing web3 providers used by connectors, so that applications can share those providers. For instance, if a connector uses Wallet Connect for DID operations, users have to scan a QR code to initiate the connection to the identity wallet first. But then, we don't want applications to also handle there own Wallet Connect instance just for Web3 EVM operations, as this would require dealing with 2 instances of Wallet Connect, and users to scan QR codes twice. In that regard, the connectivity SDK lets connectors simply share their existing web3 provider (if they have one) and applications can reuse them.
Typescript
1
import { connectivity } from "@elastosfoundation/elastos-connectivity-sdk-js";
2
import Web3 from "web3";
3
4
const provider = connectivity.getActiveConnector().getWeb3Provider();
5
if (provider) {
6
const web3 = new Web3(provider);
7
const gasPrice = await web3.eth.getGasPrice();
8
}
Copied!
Copy link