EtherWalletKit

Swift Xcode License: MIT iOS

简介

EtherWalletKit 是一个用于 iOS 的 Ethereum 钱包工具包。

我希望加密货币和去中心化代币经济能够得到更广泛的应用。 然而,一些开发者由于区块链和加密货币的复杂性以及需要学习大量新知识而犹豫不决是否在应用中添加加密钱包。

不用担心。
使用 EtherWalletKit,您可以实现一个以太坊钱包,而无需服务器和区块链知识。

特性

已发布特性

计划特性

安装

CocoaPods

要使用 CocoaPods 将 EtherWalletKit 集成到您的 Xcode 项目中,请在您的 Podfile 中指定它

pod 'EtherWalletKit'

快速开始

0. 不要忘记导入它

import EtherWalletKit

1. 创建一个 Ethereum 钱包

// Generate a new account with its new password.
try? EtherWallet.account.generateAccount(password: "ABCDEFG")

// Import an existing account from its private key and set its new password.
try? EtherWallet.account.importAccount(privateKey: "1dcbc1d6e0a4587a3a9095984cf051a1bc6ed975f15380a0ac97f01c0c045062, password: "ABCDEFG")

注意:password 将被加密并保存到设备,并且访问钱包需要此密码。

2. 获取余额

// Get balance of Ether
EtherWallet.balance.etherBalance { balance in
    print(balance)
}

// Get balance of a token
EtherWallet.balance.tokenBalance(contractAddress: "0xd26114cd6EE289AccF82350c8d8487fedB8A0C07") { balance in
    print(balance)
}

3. 发送

// send Ether to an address.
EtherWallet.transaction.sendEther(to: "0x7777787C97a35d37Db8E5afb0C92BCfd4F6480bE", amount: "1.5", password: "ABCDEFG") { txHash in
    print(txHash)
}

// send a token to an address.
EtherWallet.transaction.sendToken(to: "0x7777787C97a35d37Db8E5afb0C92BCfd4F6480bE", contractAddress: "0xd26114cd6EE289AccF82350c8d8487fedB8A0C07", amount: "20", password: "ABCDEFG", decimal: 18) { txHash in
    print(txHash)
}

注意:password 应该与创建的钱包的密码相同。 您还可以将 gasPrice 作为额外的参数来设置交易的 gas 价格。

有关完整的文档,请参见此文档

注意事项

贡献

许可

EtherWalletKit 在 MIT 许可证下可用。 有关更多信息,请参见 LICENSE 文件。