irita-sdk-java for opb
mvn install:install-file -Dfile=./src/main/resources/irita-sdk-java-0.1.jar -DgroupId=bianjie.ai -DartifactId=irita-sdk -Dversion=0.1-SNAPSHOT -Dpackaging=jar
FileInputStream input=new FileInputStream("src/test/resources/ca.JKS");
Key km=KeyManager.recoverFromCAKeystore(input,"xxx");
public interface Key {
/**
* export as keystore
*
* @param password password of keystore. The password is very important for recovery, so never forget it
*/
String export(String password) throws IOException;
}
public interface Key {
BigInteger getPrivKey();
String getAddr();
}
FileInputStream input=new FileInputStream("src/test/resources/ca.JKS");
Key km=KeyManager.recoverFromCAKeystore(input,"123456");
int gas=10;
int maxTxsBytes=1073741824;
String mode="";
double gasAdjustment=1.0;
IritaClientOption.Fee fee=new IritaClientOption.Fee("180000","uirita");
IritaClientOption option=new IritaClientOption(gas,fee,maxTxsBytes,mode,gasAdjustment,km);
String opbUri="xxx";
String projectId="xxx";
String projectKey="xxx";
String chainId="xxx";
OpbOption opbOption=new OpbOption(opbUri,projectId,projectKey);
client=new IritaClient(chainId,opbOption,option);
wasmClient=client.getWasmClient();
comGovClient=client.getCommunityGovClient();
baseTx=comGovClient.getComGovBaseTx();
ContractAddress.DEFAULT="xxx";
final String publicKey="xxx";
final String department="测试部门";
try{
comGovClient.addDepartment(department,publicKey,baseTx);
}catch(ContractException e){
// you can use log to record
e.printStackTrace();
}
String newAddr="xxx";
try{
comGovClient.addMember(newAddr,Role.HASH_ADMIN,baseTx);
}catch(ContractException|IOException e){
e.printStackTrace();
}
// 关于角色见 Role.java
详见KeyMangerTest.java, WasmTest.java, OpbTest.java