基于区块链的毕业设计CenterPrime Ethereum Client SDK – CenterPrime以太坊客户端SDK

本文提供基于区块链的毕业设计国外最新区块链项目源码下载,包括solidity,eth,fabric等blockchain区块链,基于区块链的毕业设计CenterPrime Ethereum Client SDK – CenterPrime以太坊客户端SDK 是一篇很好的国外资料

CenterPrime Ethereum Client SDK

Table of Contents

  • Getting Started
    • Adding Ethereum SDK as a Maven Dependency
    • Basic Usage
  • Features at a Glance
    • Create Wallet
    • Import Wallet By Keystore
    • Import Wallet By Private Key
    • Export Keystore
    • Export Private Key
    • Ethereum Balance
    • ERC20 token balance
    • Send Ether
    • Send ERC20 Token

Getting Started

Add jitpack to your root gradle file at the end of repositories:

allprojects {     repositories { 	...         maven { url 'https://jitpack.io'}     } }

Adding Ethereum SDK as a Maven Dependency

Maven:

<dependency> 	    <groupId>com.github.centerprime</groupId> 	    <artifactId>ethereum-client</artifactId> 	    <version>1.0.4</version> </dependency>

Gradle:

dependencies {     implementation 'com.github.centerprime:ethereum-client:1.0.4' }

Basic Usage

Once you have the dependencies set up you can start using CenterPrime by creating a Ethereum Wallet:

import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.widget.Toast; import com.centerprime.ethereum_sdk.EthManager; import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.schedulers.Schedulers;  public class MainActivity extends AppCompatActivity {      @Override     protected void onCreate(Bundle savedInstanceState) {         super.onCreate(savedInstanceState);         setContentView(R.layout.activity_main);          EthManager ethManager = EthManager.getInstance();          String password = "xxxx12345";          ethManager.createWallet(password, this)                 .subscribeOn(Schedulers.io())                 .observeOn(AndroidSchedulers.mainThread())                 .subscribe(walletAddress -> {                      Toast.makeText(this, "Wallet Address : " + walletAddress, Toast.LENGTH_SHORT).show();                  }, error -> {                  });     } }

Congratulations! Now you are a CenterPrime user.

Features at a Glance

Create Wallet

You can create Ethereum Wallet.

EthManager ethManager = EthManager.getInstance(); String password = "xxxx12345"; ethManager.createWallet(password, this)                 .subscribeOn(Schedulers.io())                 .observeOn(AndroidSchedulers.mainThread())                 .subscribe(walletAddress -> {                      Toast.makeText(this, "Wallet Address : " + walletAddress, Toast.LENGTH_SHORT).show();                  }, error -> {                  });

Import Wallet By Keystore

Import Ethereum Walley by Keystore.

EthManager ethManager = EthManager.getInstance(); String password = "xxxx12345"; String keystore = "JSON_FORMAT"; ethManager.importFromKeystore(keystore, password, this)                 .subscribeOn(Schedulers.io())                 .observeOn(AndroidSchedulers.mainThread())                 .subscribe(walletAddress -> {                      Toast.makeText(this, "Wallet Address : " + walletAddress, Toast.LENGTH_SHORT).show();                  }, error -> {                  });

Import Wallet By Private Key

Import Wallet By Private Key.

EthManager ethManager = EthManager.getInstance(); String privateKey = "PRIVATE_KEY"; ethManager.importFromPrivateKey(privateKey, this)                 .subscribeOn(Schedulers.io())                 .observeOn(AndroidSchedulers.mainThread())                 .subscribe(walletAddress -> {                      Toast.makeText(this, "Wallet Address : " + walletAddress, Toast.LENGTH_SHORT).show();                  }, error -> {                  });

Export Keystore

Export Keystore.

EthManager ethManager = EthManager.getInstance(); String walletAddress = "WALLET_ADDRESS"; ethManager.getKeyStore(walletAddress, this)                 .subscribeOn(Schedulers.io())                 .observeOn(AndroidSchedulers.mainThread())                 .subscribe(keystore -> {                      Toast.makeText(this, "Keystore : " + keystore, Toast.LENGTH_SHORT).show();                  }, error -> {                  });

Export Private Key

Export Private Key.

EthManager ethManager = EthManager.getInstance(); String walletAddress = "WALLET_ADDRESS"; String password = "WALLET_PASSWORD"; ethManager.exportPrivateKey(walletAddress, password,this)                 .subscribeOn(Schedulers.io())                 .observeOn(AndroidSchedulers.mainThread())                 .subscribe(privatekey -> {                      Toast.makeText(this, "Private Key : " + privatekey, Toast.LENGTH_SHORT).show();                  }, error -> {                  });

Ethereum Balance

Ethereum Balance.

EthManager ethManager = EthManager.getInstance(); String walletAddress = "WALLET_ADDRESS"; ethManager.balanceInEth(walletAddress)                 .subscribeOn(Schedulers.io())                 .observeOn(AndroidSchedulers.mainThread())                 .subscribe(balance -> {                      Toast.makeText(this, "Eth Balance : " + balance, Toast.LENGTH_SHORT).show();                  }, error -> {                  });

ERC20 token balance

ERC20 token balance.

EthManager ethManager = EthManager.getInstance(); String walletAddress = "WALLET_ADDRESS"; String password = "WALLET_PASSWORD"; String erc20TokenContractAddress = "ERC_20_TOKEN_CONTRACT_ADDRESS"; ethManager.getTokenBalance(walletAddress, password, erc20TokenContractAddress, this)                 .subscribeOn(Schedulers.io())                 .observeOn(AndroidSchedulers.mainThread())                 .subscribe(balance -> {                      Toast.makeText(this, "Token Balance : " + balance, Toast.LENGTH_SHORT).show();                  }, error -> {                  });

Send Ether

Send Ether.

EthManager ethManager = EthManager.getInstance(); String walletAddress = "WALLET_ADDRESS"; String password = "WALLET_PASSWORD"; BigInteger gasPrice = new BigInteger("GAS_PRICE"); BigInteger gasLimit = new BigInteger("GAS_LIMIT"); BigDecimal etherAmount = new BigDecimal("ETHER_AMOUNT"); String receiverAddress = "RECEIVER_WALLET_ADDRESS"; ethManager.sendEther(walletAddress, password,gasPrice,gasLimit,etherAmount, receiverAddress, this)                 .subscribeOn(Schedulers.io())                 .observeOn(AndroidSchedulers.mainThread())                 .subscribe(tx -> {                      Toast.makeText(this, "TX : " + tx, Toast.LENGTH_SHORT).show();                  }, error -> {                  });

Send ERC20 token

Send ERC20 token.

EthManager ethManager = EthManager.getInstance(); String walletAddress = "WALLET_ADDRESS"; String password = "WALLET_PASSWORD"; BigInteger gasPrice = new BigInteger("GAS_PRICE"); BigInteger gasLimit = new BigInteger("GAS_LIMIT"); BigDecimal tokenAmount = new BigDecimal("TOKEN_AMOUNT"); String receiverAddress = "RECEIVER_WALLET_ADDRESS"; String erc20TokenContractAddress = "ERC20_TOKEN_CONTRACT_ADDRESS"; ethManager.sendToken(walletAddress, password, gasPrice, gasLimit, tokenAmount, receiverAddress, erc20TokenContractAddress, this)                 .subscribeOn(Schedulers.io())                 .observeOn(AndroidSchedulers.mainThread())                 .subscribe(tx -> {                      Toast.makeText(this, "TX : " + tx, Toast.LENGTH_SHORT).show();                  }, error -> {                  });

We use optional third-party analytics cookies to understand how you use GitHub.com so we can build better products. Learn more.


按密钥库导入钱包

通过私钥导入钱包

  • 获取已开始将以太坊ethSDK添加为Maven依赖项基本用法
  • 功能一目了然创建Wallet Import Wallet By Keystore Import Wallet By Private Key Export Keystore Export Private Key Ethereum Balance ERC20 token Balance发送以太发送ERC20令牌

导出密钥库

导出私钥

allprojects {     repositories { 	...         maven { url 'https://jitpack.io'}     } }

以太坊eth余额

Maven:

<dependency> 	    <groupId>com.github.centerprime</groupId> 	    <artifactId>ethereum-client</artifactId> 	    <version>1.0.4</version> </dependency>

Gradle:

dependencies {     implementation 'com.github.centerprime:ethereum-client:1.0.4' }

ERC20代币余额

一旦设置了依赖关系,就可以通过创建以太坊eth钱包开始使用CenterPrime:

import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.widget.Toast; import com.centerprime.ethereum_sdk.EthManager; import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.schedulers.Schedulers;  public class MainActivity extends AppCompatActivity {      @Override     protected void onCreate(Bundle savedInstanceState) {         super.onCreate(savedInstanceState);         setContentView(R.layout.activity_main);          EthManager ethManager = EthManager.getInstance();          String password = "xxxx12345";          ethManager.createWallet(password, this)                 .subscribeOn(Schedulers.io())                 .observeOn(AndroidSchedulers.mainThread())                 .subscribe(walletAddress -> {                      Toast.makeText(this, "Wallet Address : " + walletAddress, Toast.LENGTH_SHORT).show();                  }, error -> {                  });     } }

恭喜你!现在您是CenterPrime用户。

发送ERC20代币

基本cookies

您可以创建以太坊eth钱包。

EthManager ethManager = EthManager.getInstance(); String password = "xxxx12345"; ethManager.createWallet(password, this)                 .subscribeOn(Schedulers.io())                 .observeOn(AndroidSchedulers.mainThread())                 .subscribe(walletAddress -> {                      Toast.makeText(this, "Wallet Address : " + walletAddress, Toast.LENGTH_SHORT).show();                  }, error -> {                  });

始终处于活动状态

通过密钥库导入以太坊ethWalley。

EthManager ethManager = EthManager.getInstance(); String password = "xxxx12345"; String keystore = "JSON_FORMAT"; ethManager.importFromKeystore(keystore, password, this)                 .subscribeOn(Schedulers.io())                 .observeOn(AndroidSchedulers.mainThread())                 .subscribe(walletAddress -> {                      Toast.makeText(this, "Wallet Address : " + walletAddress, Toast.LENGTH_SHORT).show();                  }, error -> {                  });

分析cookies

使用私钥导入电子钱包。

EthManager ethManager = EthManager.getInstance(); String privateKey = "PRIVATE_KEY"; ethManager.importFromPrivateKey(privateKey, this)                 .subscribeOn(Schedulers.io())                 .observeOn(AndroidSchedulers.mainThread())                 .subscribe(walletAddress -> {                      Toast.makeText(this, "Wallet Address : " + walletAddress, Toast.LENGTH_SHORT).show();                  }, error -> {                  });

Export Keystore

导出密钥库。

EthManager ethManager = EthManager.getInstance(); String walletAddress = "WALLET_ADDRESS"; ethManager.getKeyStore(walletAddress, this)                 .subscribeOn(Schedulers.io())                 .observeOn(AndroidSchedulers.mainThread())                 .subscribe(keystore -> {                      Toast.makeText(this, "Keystore : " + keystore, Toast.LENGTH_SHORT).show();                  }, error -> {                  });

Export Private Key

导出私钥。

EthManager ethManager = EthManager.getInstance(); String walletAddress = "WALLET_ADDRESS"; String password = "WALLET_PASSWORD"; ethManager.exportPrivateKey(walletAddress, password,this)                 .subscribeOn(Schedulers.io())                 .observeOn(AndroidSchedulers.mainThread())                 .subscribe(privatekey -> {                      Toast.makeText(this, "Private Key : " + privatekey, Toast.LENGTH_SHORT).show();                  }, error -> {                  });

Ethereum Balance

以太坊eth平衡。

EthManager ethManager = EthManager.getInstance(); String walletAddress = "WALLET_ADDRESS"; ethManager.balanceInEth(walletAddress)                 .subscribeOn(Schedulers.io())                 .observeOn(AndroidSchedulers.mainThread())                 .subscribe(balance -> {                      Toast.makeText(this, "Eth Balance : " + balance, Toast.LENGTH_SHORT).show();                  }, error -> {                  });

ERC20 token balance

ERC20代币余额。

EthManager ethManager = EthManager.getInstance(); String walletAddress = "WALLET_ADDRESS"; String password = "WALLET_PASSWORD"; String erc20TokenContractAddress = "ERC_20_TOKEN_CONTRACT_ADDRESS"; ethManager.getTokenBalance(walletAddress, password, erc20TokenContractAddress, this)                 .subscribeOn(Schedulers.io())                 .observeOn(AndroidSchedulers.mainThread())                 .subscribe(balance -> {                      Toast.makeText(this, "Token Balance : " + balance, Toast.LENGTH_SHORT).show();                  }, error -> {                  });

Send Ether

发送乙醚。

EthManager ethManager = EthManager.getInstance(); String walletAddress = "WALLET_ADDRESS"; String password = "WALLET_PASSWORD"; BigInteger gasPrice = new BigInteger("GAS_PRICE"); BigInteger gasLimit = new BigInteger("GAS_LIMIT"); BigDecimal etherAmount = new BigDecimal("ETHER_AMOUNT"); String receiverAddress = "RECEIVER_WALLET_ADDRESS"; ethManager.sendEther(walletAddress, password,gasPrice,gasLimit,etherAmount, receiverAddress, this)                 .subscribeOn(Schedulers.io())                 .observeOn(AndroidSchedulers.mainThread())                 .subscribe(tx -> {                      Toast.makeText(this, "TX : " + tx, Toast.LENGTH_SHORT).show();                  }, error -> {                  });

Send ERC20 token

发送ERC20令牌。

EthManager ethManager = EthManager.getInstance(); String walletAddress = "WALLET_ADDRESS"; String password = "WALLET_PASSWORD"; BigInteger gasPrice = new BigInteger("GAS_PRICE"); BigInteger gasLimit = new BigInteger("GAS_LIMIT"); BigDecimal tokenAmount = new BigDecimal("TOKEN_AMOUNT"); String receiverAddress = "RECEIVER_WALLET_ADDRESS"; String erc20TokenContractAddress = "ERC20_TOKEN_CONTRACT_ADDRESS"; ethManager.sendToken(walletAddress, password, gasPrice, gasLimit, tokenAmount, receiverAddress, erc20TokenContractAddress, this)                 .subscribeOn(Schedulers.io())                 .observeOn(AndroidSchedulers.mainThread())                 .subscribe(tx -> {                      Toast.makeText(this, "TX : " + tx, Toast.LENGTH_SHORT).show();                  }, error -> {                  });

我们使用可选的第三方分析cookies来了解您如何使用GitHub.com网站所以我们可以制造更好的产品。了解更多。

部分转自网络,侵权联系删除区块链源码网

www.interchains.cc

https://www.interchains.cc/18345.html

区块链毕设网(www.interchains.cc)全网最靠谱的原创区块链毕设代做网站 部分资料来自网络,侵权联系删除! 最全最大的区块链源码站 !
区块链知识分享网, 以太坊dapp资源网, 区块链教程, fabric教程下载, 区块链书籍下载, 区块链资料下载, 区块链视频教程下载, 区块链基础教程, 区块链入门教程, 区块链资源 » 基于区块链的毕业设计CenterPrime Ethereum Client SDK – CenterPrime以太坊客户端SDK

提供最优质的资源集合

立即查看 了解详情