# Ethereum Providers

Using Ethers.js or Web3.js with the Wepin Provider allows you to interact with EVM-compatible blockchain networks.&#x20;

## Supported Networks

{% hint style="info" %}
Is the blockchain you need not listed? Please [contact the Wepin](https://wepinwallet.typeform.com/WEPIN-Wallet-EN) team for blockchain support.
{% endhint %}

<table><thead><tr><th width="172.33333333333331">Chain ID</th><th>Network Name</th><th>Network Variable</th></tr></thead><tbody><tr><td>1</td><td>Ethereum Mainnet</td><td>ethereum</td></tr><tr><td>5</td><td>Ethereum Goerli Testnet</td><td>evmeth-goerli</td></tr><tr><td>11155111</td><td>Ethereum Sepolia</td><td>evmeth-sepolia</td></tr><tr><td>19</td><td>Songbird Canary Network</td><td>evmsongbird</td></tr><tr><td>137</td><td>Polygon Mainnet</td><td>evmpolygon</td></tr><tr><td>80002</td><td>Polygon Amoy</td><td>evmpolygon-amoy</td></tr><tr><td>8217</td><td>Klaytn Mainnet</td><td>klaytn</td></tr><tr><td>1001</td><td>Klaytn Testnet</td><td>klaytn-testnet</td></tr><tr><td>2731</td><td>Ant-Time Testnet</td><td>evmanttime-testnet</td></tr></tbody></table>

## Initialize Web3

First, initialize <mark style="color:blue;">`Wepin`</mark>, then obtain the provider.

```jsx
const appId = 'app_id_eg12sf3491azgs520' // Test App ID
const appKey = 'ak_test_ghq1D5s1sfG234sbnhdsw24mnovk313' // Test App Key
const attributes = {
	type: 'show'
}
// Initialize Wepin
await Wepin.init(appId, appKey, attributes)
// Obtain the provider from the initialized Wepin.
const provider = Wepin.getProvider({ network: 'ethereum' });
```

### Initialize `Web3` using `web3.js`

```javascript
import Web3 from 'web3'
const provider = Wepin.getProvider({ network: 'ethereum' })
const web3 = new Web3(provider)
```

### Initialize `Web3` using `ethers.js`

Please refer to: [ethers.js for React native](https://docs.ethers.org/v5/cookbook/react-native/)

```javascript
import "react-native-get-random-values"
// Import the the ethers shims (**BEFORE** ethers)
import "@ethersproject/shims"
// Import the ethers library
import { ethers } from "ethers"
const provider = wepin.getProvider({ network: 'ethereum' })
const web3 = new ethers.providers.Web3Provider(provider)
```

## Methods

### Get Accounts

Through the initialized <mark style="color:blue;">`web3`</mark>, you can retrieve account information.

```jsx
const accounts = await web3.eth.getAccounts()
```

### Get Balance

Using the account information, you can query the balance.

```jsx
const balance = await web3.eth.getBalance(accounts[0])
```

You can refer to the link below to query not only the balance but also fee information, block number, etc.

{% embed url="<https://web3js-kr.readthedocs.io/ko/latest/getting-started.html>" %}

### Send Transaction

You can send transactions.

```jsx
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

You can perform contract calls.

```jsx
const callObject = {
	to: '0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe', //contract address
	data: '0xc6888fa10000000000000000000000000000000000000000000000000000000000000003'
}
const response = await web3.eth.call(callObject)
```

For more details on the Ethereum-compatible network provider, please refer to the link below.

{% embed url="<https://eips.ethereum.org/EIPS/eip-1193>" %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.wepin.io/en/deprecated/react-native-sdk/providers/evmcompatible.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
