npm i @trustwallet/web3-provider-core
Let's use for example, ethereum
npm i @trustwallet/web3-provider-ethereum
import { Web3Provider } from '@trustwallet/web3-provider-core';
import { EthereumProvider } from '@trustwallet/web3-provider-ethereum';
const ethereum = new EthereumProvider();
new Web3Provider({
strategy: AdapterStrategy.PROMISES,
handler: (params: IHandlerParams) => {},
}).registerProvider(ethereum);
// Register the ethereum provider
window.ethereum = ethereum;
dApps that use EIP-1193 will be able to connect to your wallet now.
const provider = new Web3Provider({
strategy: AdapterStrategy.CALLBACK,
}).registerProvider(ethereum);
const handler = (params: IHandlerParams) => {
provider.sendResponse(params.id, ['0x0....']);
};
provider.setHandler(handler);