💸WalletConnect

One of the easiest ways to connect and deploy with WalletConnect is with their UniversalProvider.

The provider object returned can be used with Web3.js natively.

https://docs.walletconnect.com/2.0/web/providers/universal

import Web3 from "web3";
import UniversalProvider from "@walletconnect/universal-provider";


const provider = await UniversalProvider.init({
   logger: "error",
   projectId: "",
});
const session = await provider.connect({
  namespaces: {
  eip155: {
    methods: [
       "eth_sendTransaction",
   	"eth_signTransaction",
   	"eth_sign",
       "personal_sign",
   	"eth_signTypedData",
    ],
    chains: ["eip155:137"],
    events: ["chainChanged", "accountsChanged"],
   },
  },
});

const web3 = new Web3(provider);

const [from] = await provider
   			 .request({
   				 method: "eth_accounts",
   			 })

web3.eth.sendTransaction({
  to: "0x"
  from,
  gas: "300000",
  data: "0x"
})

Last updated