Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
5909ad1
Update .gitbook/cn/developers-evm/index.mdx
mintlify[bot] Jan 9, 2026
a9a1573
Update .gitbook/cn/developers-evm/network-information.mdx
mintlify[bot] Jan 9, 2026
4d57240
Update .gitbook/cn/developers-evm/smart-contracts/index.mdx
mintlify[bot] Jan 9, 2026
52b9202
Update .gitbook/cn/developers-evm/smart-contracts/compile-hardhat.mdx
mintlify[bot] Jan 9, 2026
bfcba6c
Update .gitbook/cn/developers-evm/smart-contracts/test-hardhat.mdx
mintlify[bot] Jan 9, 2026
b78321f
Update .gitbook/cn/developers-evm/smart-contracts/deploy-hardhat.mdx
mintlify[bot] Jan 9, 2026
cf34186
Update .gitbook/cn/developers-evm/smart-contracts/verify-hardhat.mdx
mintlify[bot] Jan 9, 2026
1006b3e
Update .gitbook/cn/developers-evm/smart-contracts/interact-hardhat.mdx
mintlify[bot] Jan 9, 2026
bf9fa72
Update .gitbook/cn/developers-evm/smart-contracts/compile-foundry.mdx
mintlify[bot] Jan 9, 2026
5173760
Update .gitbook/cn/developers-evm/smart-contracts/test-foundry.mdx
mintlify[bot] Jan 9, 2026
a90da81
Update .gitbook/cn/developers-evm/smart-contracts/deploy-foundry.mdx
mintlify[bot] Jan 9, 2026
d087e59
Update .gitbook/cn/developers-evm/smart-contracts/verify-foundry.mdx
mintlify[bot] Jan 9, 2026
bfb8ecb
Update .gitbook/cn/developers-evm/smart-contracts/interact-foundry.mdx
mintlify[bot] Jan 9, 2026
4a1578e
Update .gitbook/cn/developers-evm/dapps/index.mdx
mintlify[bot] Jan 9, 2026
b21ee9a
Update .gitbook/cn/developers-evm/dapps/connect-with-metamask.mdx
mintlify[bot] Jan 9, 2026
c8f257e
Update .gitbook/cn/developers-evm/dapps/connect-with-walletconnect.mdx
mintlify[bot] Jan 9, 2026
1d0cb34
Update .gitbook/cn/developers-evm/evm-equivalence.mdx
mintlify[bot] Jan 9, 2026
6be749a
Update .gitbook/cn/developers-evm/multivm-token-standard.mdx
mintlify[bot] Jan 9, 2026
5acd569
Update .gitbook/cn/developers-evm/wrapped-inj.mdx
mintlify[bot] Jan 9, 2026
f606745
Update .gitbook/cn/developers-evm/precompiles.mdx
mintlify[bot] Jan 9, 2026
623abfe
Update .gitbook/cn/developers-evm/bank-precompile.mdx
mintlify[bot] Jan 9, 2026
45590a1
Update .gitbook/cn/developers-evm/exchange-precompile.mdx
mintlify[bot] Jan 9, 2026
2573d5c
Update .gitbook/cn/developers-evm/erc20-module.mdx
mintlify[bot] Jan 9, 2026
3512a51
Update .gitbook/cn/developers-evm/infrastructure-and-tooling.mdx
mintlify[bot] Jan 9, 2026
4d38924
Update .gitbook/cn/developers-evm/add-injective-to-your-dapp.mdx
mintlify[bot] Jan 9, 2026
49cb209
Update .gitbook/cn/developers-evm/evm-integrations-cheat-sheet.mdx
mintlify[bot] Jan 9, 2026
6fe7404
Update .gitbook/cn/developers-evm/evm-integrations-faq.mdx
mintlify[bot] Jan 9, 2026
d3a5572
Update .gitbook/docs.json
mintlify[bot] Jan 9, 2026
c18e1e7
Update .gitbook/docs.json
mintlify[bot] Jan 9, 2026
c002b86
Update .gitbook/docs.json
mintlify[bot] Jan 9, 2026
abadf2f
Update .gitbook/docs.json
mintlify[bot] Jan 9, 2026
df6e2dd
Update .gitbook/docs.json
mintlify[bot] Jan 9, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 65 additions & 0 deletions .gitbook/cn/developers-evm/add-injective-to-your-dapp.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
---
title: 将 Injective 添加到你的 dApp
---

# 将 Injective 添加到你的 dApp

让你的用户只需一键即可连接到 Injective 网络。

使用下面的代码片段向你的 dApp 添加"添加 Injective 网络"按钮,让用户可以轻松地将 Injective 添加到 MetaMask 或任何 EVM 兼容钱包。

1. 将代码片段复制并粘贴到你的前端代码库中。
2. 将 `addInjectiveNetwork` 函数连接到你首选的 UI 按钮。
3. 就是这样——你的用户现在可以在几秒钟内将 Injective 添加到他们的钱包

```tsx
// 网络配置
const INJECTIVE_MAINNET_CONFIG = {
chainId: '0x6f0', // 十进制 1776
chainName: 'Injective',
rpcUrls: ['https://evm-rpc.injective.network'],
nativeCurrency: {
name: 'Injective',
symbol: 'INJ',
decimals: 18
},
blockExplorerUrls: ['https://explorer.injective.network']
};

async function addInjectiveNetwork() {
// 检查是否安装了 MetaMask 或其他 Web3 钱包
if (!window.ethereum) {
alert('Please install MetaMask or another Web3 wallet!');
return;
}

try {
// 首先,尝试切换到 Injective 网络
await window.ethereum.request({
method: 'wallet_switchEthereumChain',
params: [{ chainId: INJECTIVE_MAINNET_CONFIG.chainId }],
});

console.log('Switched to Injective network successfully!');
} catch (switchError) {
// 错误代码 4902 表示网络尚未添加
if (switchError.code === 4902) {
try {
// 添加 Injective 网络
await window.ethereum.request({
method: 'wallet_addEthereumChain',
params: [INJECTIVE_MAINNET_CONFIG],
});

console.log('Injective network added successfully!');
} catch (addError) {
console.error('Failed to add Injective network:', addError);
alert('Failed to add Injective network. Please try again.');
}
} else {
console.error('Failed to switch network:', switchError);
alert('Failed to switch to Injective network.');
}
}
}
```
50 changes: 50 additions & 0 deletions .gitbook/cn/developers-evm/bank-precompile.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
---
title: Bank Precompile
---

# Bank Precompile

Bank Precompile 是一个位于固定地址 `0x0000000000000000000000000000000000000064` 的系统智能合约。

它为 EVM 开发者提供了一种高效且原生的方式来直接与 Injective 的 **bank 模块**(`x/bank`)交互。这有效地将 ERC-20 token 带到链上。任何使用 Bank precompile 的 ERC-20 合约将在链上表示为 `erc20:0x...` denom。从技术上讲,这意味着 token 仅存在于链上,EVM 提供链状态的视图而不是维护单独的副本。与传统桥接不同,传统桥接需要用户操作来切换两个 token 版本,Bank precompile 为使用链上 bank denom 或 ERC-20 `transfer()` 方法的任何转账提供实时、双环境反映。

一系列由 Bank precompile 支持的 ERC-20 实现,以及 precompile 接口和抽象合约,可在 [Injective 的 Solidity 合约仓库](https://github.com/InjectiveLabs/solidity-contracts) 中找到。关键合约包括:

* **Bank.sol** – precompile 接口
* **BankERC20.sol** – 由 Bank precompile 支持的抽象 ERC20 实现
* **FixedSupplyBankERC20.sol** – 固定供应量的去中心化 ERC20(无所有者,无铸造或销毁)
* **MintBurnBankERC20.sol** – 具有授权铸造和销毁 token 的所有者的 ERC20

这些实现基于 OpenZeppelin 的 ERC20 合约。开发者可以自由创建使用 Bank precompile 的自定义 ERC20 合约。

## ERC20 合约部署

**ℹ️ 注意:**

为防止 denom 垃圾信息,通过 ERC20 模块部署 ERC20 合约是**付费操作**,需要 **1 INJ** 的部署费用。确保你的 ERC20 合约部署交易包含此金额,否则操作将被拒绝。

## Bank Precompile 接口

```solidity
interface IBankModule {
function mint(address,uint256) external payable returns (bool);
function balanceOf(address,address) external view returns (uint256);
function burn(address,uint256) external payable returns (bool);
function transfer(address,address,uint256) external payable returns (bool);
function totalSupply(address) external view returns (uint256);
function metadata(address) external view returns (string memory,string memory,uint8);
function setMetadata(string memory,string memory,uint8) external payable returns (bool);
}
```

## 示例

[Wrapped INJ (wINJ)](/cn/developers-evm/wrapped-inj#is-winj-the-same-as-weth "wINJ 与 wETH 相同吗?")
使用 Bank EVM precompile 来实现
[MultiVM Token Standard (MTS)](/cn/developers-evm/multivm-token-standard)。

## 开始构建

我们准备了一些演示,展示如何使用 Bank、Exchange 和 Staking precompiles 构建合约。这些示例还演示了如何使用最常见的 Ethereum 开发框架 **Foundry** 与 Injective EVM 交互。

在[这里](https://github.com/InjectiveLabs/solidity-contracts/tree/master/demos/erc20)查看 bank precompile 演示并按照相应的 README 操作。
Loading