Utilize a provider that is supported for EVM Chains
This is a bridge between all Web3 libraries that are built for EVM chains. If you have a dApp with EthersJS, you can integrate Tweed with just 3 lines of code by initializing this Web3Provider and injecting it into EthersJS.
Tweed's Web3Provider allows developers to integrate Tweed into their platform as if they were integrating any other Web3 component complying with EIP1193 standard. Tweed's provider implements the chainChanged functionality to support the EVMs that are supported by the Tweed infrastructure.
You can find code examples in JavaScript and React below.
Usage Examples
JavaScript
import { TweedFrontendSDK } from'@paytweed/frontend-sdk'constfrontendSDK=TweedFrontendSDK.setup({...})// Get the relevant chain's providerconsttweedProvider=awaitfrontendSDK.blockchain.getProvider({ chainId:'ethereumSepolia',//ethereumSepolia as an example});// Get the provider wrapped up inside ethersconstweb3Provider=newethers.providers.Web3Provider(tweedProvider);// Use the providerconstsigner=web3Provider.getSigner();constcontract=newethers.Contract(CONTRACT_ADDRESS,CONTRACT_ABI, signer); //Add you contract address and ABI// Send transactionconst { hash } =awaitsigner.sendTransaction({to:"0x0...0"})
React
import { TweedFrontendSdkProvider } from'@paytweed/frontend-sdk-react'import { hooks } from'@paytweed/frontend-sdk-react'const { data: provider } =hooks.useBlockchainProvider({ chainId:'ethereumSepolia' })// Get the provider wrapped up inside ethersconstweb3Provider=newethers.providers.Web3Provider(provider)// Use the providerconstsigner=web3Provider.getSigner()constcontract=newethers.Contract(CONTRACT_ADDRESS,CONTRACT_ABI, signer) //Add you contract address and ABI// Send transactionconst { hash } =awaitsigner.sendTransaction({ to:'0x0...0' })