0.0.6-alpha • Published 6 months ago

@wepin/provider v0.0.6-alpha

Weekly downloads
-
License
MIT
Repository
github
Last release
6 months ago

@wepin/provider

Wepin Provider Widget SDK for Web.

This package is only available in the web environment. It cannot be used in Android and iOS apps(Webview).

Wipin supports providers that return JSON-RPC request responses to connect with blockchain networks in webs. With Wipin Provider, you can easily connect to various networks supported by Wipin.

The providers supported by Wipin are as follows.

  • EVM compatible Networks
  • Klaytn Network (Comming soon)

EVM compatible Networks

Ethers.js or Web3.js can be used with Wepin Provider to interoperate with EVM compatible blockchains.

Support Networks

Chain IDNetwork NameNetwork Variable
1Ethereum Mainnetethereum
5Ethereum Goerli Testnetevmeth-goerli
19Songbird Canary Networkevmsongbird
137Polygon Mainnetevmpolygon
1001Klaytn Testnetklaytn-testnet
8217Klaytn Mainnetklaytn
80001Polygon Mumbaievmpolygon-testnet

Install

First, import @wepin/widget-sdk and @wepin/provider into the project. You must import @wepin/widget-sdk widget-sdk first.

import '@wepin/widget-sdk'
import '@wepin/provider'

Method

  • Get Accounts You can receive account information through the initialized web3.
const accounts = await web3.eth.getAccounts()
  • Get Balance You can get account's balance using your account information.
const balance = await web3.eth.getBalance(accounts[0])

You can refer to the link below to check balance as well as fee information, block number, etc.

Document: web3.js 1.0.0 documentation

  • Send Transaction Transaction can be sent.
const accounts = await web3.eth.getAccounts()
const tx = {
    from: accounts[0],
    gasPrice: "2000000000",
    gas: "21000",
    to: '0x11f4d0A3c1......13F7E19D048276DAe',
    value: "10000000000000000",
}
const response = await web3.eth.sendTransaction(tx)
  • Contract Call A contract call can be performed.
const callObject = {
	to: '0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe', //contract address
	data: '0xc6888fa10000000000000000000000000000000000000000000000000000000000000003'
}
const response = await web3.eth.call(callObject)

For details of Ethereum compatible network providers, please refer to the link below.

EIP-1193: Ethereum Provider Javascript API