An interface for interacting with the blockchain wallet operation for android.
Step 1. Add it in your root build.gradle at the end of repositories:
repositories {
maven { url 'https://jitpack.io' }
}
Step 2. Add the dependency
dependencies {
implementation 'com.github.JCCDex:jcc-android-base-lib:0.1.8'
}
Interface for interacting with the node sdk of jingtum & jingtum alliance chains. Now supports SWTC & BIZAIN chain.
Create JingtumWallet with Context in your activity.
private JingtumWallet mJingtumWallet;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mJingtumWallet = JingtumWallet.getInstance();
mJingtumWallet.init(this);
}
String chain = JingtumWallet.SWTC_CHAIN;
// String chain = JingtumWallet.BIZAIN_CHAIN;
mJingtumWallet.createWallet(chain, new JCallback() {
@Override
public void completion(JCCJson jccJson) {
String secret = jccJson.getString("secret");
String address = jccJson.getString("address");
// the secret and address is not null if create wallet successfully
}
});
String secret = "";
String chain = JingtumWallet.SWTC_CHAIN;
// String chain = JingtumWallet.BIZAIN_CHAIN;
mJingtumWallet.importSecret(secret, chain, new JCallback() {
@Override
public void completion(JCCJson jccJson) {
String secret = jccJson.getString("secret");
String address = jccJson.getString("address");
// the secret and address is not null if import secret successfully
}
});
String address = "";
String chain = JingtumWallet.SWTC_CHAIN;
// String chain = JingtumWallet.BIZAIN_CHAIN;
mJingtumWallet.isValidAddress(address, chain, new JCallback() {
@Override
public void completion(JCCJson jccJson) {
Boolean isValid = jccJson.getBoolean("isValid");
// the isValid is true if the address is valid
}
});
String secret = "";
String chain = JingtumWallet.SWTC_CHAIN;
// String chain = JingtumWallet.BIZAIN_CHAIN;
mJingtumWallet.isValidSecret(secret, chain, new JCallback() {
@Override
public void completion(JCCJson jccJson) {
Boolean isValid = jccJson.getBoolean("isValid");
// the isValid is true if the secret is valid
}
});
JSONObject transaction = null;
String secret = "";
String chain = JingtumWallet.SWTC_CHAIN;
// String chain = JingtumWallet.BIZAIN_CHAIN;
mJingtumWallet.sign(transaction, secret, chain, new JCallback() {
@Override
public void completion(JCCJson jccJson) {
String signature = jccJson.getString("signature");
// the signature is not null if sign successfully
}
});
For more structure of transaction data, see jcc_exchange.
Interface for interacting with the node sdk of web3. Create EthereumWallet with Context in your activity.
private EthereumWallet mEthereumWallet;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mEthereumWallet = EthereumWallet.getInstance();
mEthereumWallet.init(this);
String ethereumNode = "";
mEthereumWallet.initWeb3Provider(ethereumNode);
}
mEthereumWallet.createWallet(new JCallback() {
@Override
public void completion(JCCJson jccJson) {
String secret = jccJson.getString("secret");
String address = jccJson.getString("address");
String words = jccJson.getString("words");
// the secret、address and words is not null if create wallet successfully
}
});
String address = "";
mEthereumWallet.isValidAddress(address, new JCallback() {
@Override
public void completion(JCCJson jccJson) {
Boolean isValid = jccJson.getBoolean("isValid");
// the isValid is true if the address is valid
}
});
String secret = "";
mEthereumWallet.isValidSecret(secret, new JCallback() {
@Override
public void completion(JCCJson jccJson) {
Boolean isValid = jccJson.getBoolean("isValid");
// the isValid is true if the secret is valid
}
});
String secret = "";
mEthereumWallet.importSecret(secret, new JCallback() {
@Override
public void completion(JCCJson jccJson) {
String secret = jccJson.getString("secret");
String address = jccJson.getString("address");
// the secret and address is not null if import secret successfully
}
});
String words = "";
mEthereumWallet.importWords(words, new JCallback() {
@Override
public void completion(JCCJson jccJson) {
String secret = jccJson.getString("secret");
String address = jccJson.getString("address");
// the secret and address is not null if import words successfully
}
});
String address = "";
mEthereumWallet.toIban(address, new JCallback() {
@Override
public void completion(JCCJson jccJson) {
String iban = json.getString("iban");
// the iban is not null if the address is valid
}
});
String iban = "";
mEthereumWallet.fromIban(iban, new JCallback() {
@Override
public void completion(JCCJson jccJson) {
String address = json.getString("address");
// the address is not null if the iban is valid
}
});
Only support eth except erc20 for now.
JSONObject transaction = new JSONObject();
transaction.put("from", "");
transaction.put("value", "");
transaction.put("to", "");
transaction.put("gas", "");
transaction.put("gasPrice", "");
String secret = "";
mEthereumWallet.sign(transaction, secret, new JCallback() {
@Override
public void completion(JCCJson jccJson) {
String rawTransaction = json.getString("rawTransaction");
// the rawTransaction is not null if sign successfully
}
});
String rawTransaction = "";
mEthereumWallet.sendSignedTransaction(rawTransaction, new JCallback() {
@Override
public void completion(JCCJson jccJson) {
String hash = json.getString("hash");
// the hash is not null if the send successfully.
}
});
mEthereumWallet.gasPrice(new JCallback() {
@Override
public void completion(JCCJson jccJson) {
String gas = json.getString("gasPrice");
// the gas is not null if request gas price successfully.
}
});
String address = "";
mEthereumWallet.getBalance(address, new JCallback() {
@Override
public void completion(JCCJson jccJson) {
String balance = json.getString("balance");
// the balance is not null if request balance successfully.
}
});
Interface for interacting with the node sdk of chain3. Create MoacWallet with Context in your activity.
private MoacWallet mMoacWallet;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mMoacWallet = MoacWallet.getInstance();
mMoacWallet.init(this);
String moacNode = "";
mMoacWallet.initChain3Provider(moacNode);
}
mMoacWallet.createWallet(new JCallback() {
@Override
public void completion(JCCJson jccJson) {
String secret = jccJson.getString("secret");
String address = jccJson.getString("address");
String words = jccJson.getString("words");
// the secret、address and words is not null if create wallet successfully
}
});
String address = "";
mMoacWallet.isValidAddress(address, new JCallback() {
@Override
public void completion(JCCJson jccJson) {
Boolean isValid = jccJson.getBoolean("isValid");
// the isValid is true if the address is valid
}
});
String secret = "";
mMoacWallet.isValidSecret(secret, new JCallback() {
@Override
public void completion(JCCJson jccJson) {
Boolean isValid = jccJson.getBoolean("isValid");
// the isValid is true if the secret is valid
}
});
String secret = "";
mMoacWallet.importSecret(secret, new JCallback() {
@Override
public void completion(JCCJson jccJson) {
String secret = jccJson.getString("secret");
String address = jccJson.getString("address");
// the secret and address is not null if import secret successfully
}
});
String words = "";
mMoacWallet.importWords(words, new JCallback() {
@Override
public void completion(JCCJson jccJson) {
String secret = jccJson.getString("secret");
String address = jccJson.getString("address");
// the secret and address is not null if import words successfully
}
});
String address = "";
mMoacWallet.toIban(address, new JCallback() {
@Override
public void completion(JCCJson jccJson) {
String iban = json.getString("iban");
// the iban is not null if the address is valid
}
});
String iban = "";
mMoacWallet.fromIban(iban, new JCallback() {
@Override
public void completion(JCCJson jccJson) {
String address = json.getString("address");
// the address is not null if the iban is valid
}
});
Only support moac except erc20 for now.
JSONObject transaction = new JSONObject();
transaction.put("from", "");
transaction.put("value", "");
transaction.put("to", "");
transaction.put("gas", "");
transaction.put("gasPrice", "");
String secret = "";
mMoacWallet.sign(transaction, secret, new JCallback() {
@Override
public void completion(JCCJson jccJson) {
String rawTransaction = json.getString("rawTransaction");
// the rawTransaction is not null if sign successfully
}
});
String rawTransaction = "";
mMoacWallet.sendSignedTransaction(rawTransaction, new JCallback() {
@Override
public void completion(JCCJson jccJson) {
String hash = json.getString("hash");
// the hash is not null if the send successfully.
}
});
mMoacWallet.gasPrice(new JCallback() {
@Override
public void completion(JCCJson jccJson) {
String gas = json.getString("gasPrice");
// the gas is not null if request gas price successfully.
}
});
String address = "";
mMoacWallet.getBalance(address, new JCallback() {
@Override
public void completion(JCCJson jccJson) {
String balance = json.getString("balance");
// the balance is not null if request balance successfully.
}
});
Interface for interacting with the node sdk of eos. Create EosWallet with Context in your activity.
private EosWallet mEosWallet;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mEosWallet = EosWallet.getInstance();
mEosWallet.init(this);
String eosChainId = "";
String eosHttpEndpoint = "";
mEosWallet.initEosProvider(eosChainId, eosHttpEndpoint);
}
String secret = "";
mEosWallet.importSecret(secret, new JCallback() {
@Override
public void completion(JCCJson jccJson) {
String secret = jccJson.getString("secret");
String address = jccJson.getString("address");
// the secret and address is not null if import secret successfully
}
});
JSONObject transaction = new JSONObject();
transaction.put("contract", "");
transaction.put("from", "");
transaction.put("value", "");
transaction.put("to", "");
transaction.put("memo", "");
String secret = "";
mEosWallet.sendTransaction(transaction, secret, new JCallback() {
@Override
public void completion(JCCJson jccJson) {
String hash = json.getString("hash");
// the hash is not null if the send successfully.
}
});
String account = "";
mEosWallet.getBalance(account, new JCallback() {
@Override
public void completion(JCCJson jccJson) {
String balance = json.getString("balance");
// the balance is not null if request balance successfully.
}
});