@wepin/provider
v0.0.6-alpha
Published
Wepin Provider Widget SDK for Web
Downloads
9
Readme
@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 ID | Network Name | Network Variable | | -------- | ----------------------- | ------------------ | | 1 | Ethereum Mainnet | ethereum | | 5 | Ethereum Goerli Testnet | evmeth-goerli | | 19 | Songbird Canary Network | evmsongbird | | 137 | Polygon Mainnet | evmpolygon | | 1001 | Klaytn Testnet | klaytn-testnet | | 8217 | Klaytn Mainnet | klaytn | | 80001 | Polygon Mumbai | evmpolygon-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.