repositories {
maven {
url = "https://maven.pkg.github.com/medibloc/panacea-java"
// GitHub Packages credentials
credentials {
username = System.getenv("GPR_USER")
password = System.getenv("GPR_API_KEY")
}
}
mavenCentral()
}
dependencies {
implementation 'org.medibloc.panacea:panacea-java:2.3.0'
}Use JDK 17 to build the SDK. Published classes remain Java 8 compatible.
- Broadcast transactions
- Query accounts, balances, transactions, blocks, and nodes
- Query AOL topics and records
- Query DID documents
- Create, mint, transfer, revoke, burn, and query Panacea NFTs
The legacy PNFT query APIs remain available for source compatibility but are deprecated because Panacea Core v2.3.0 removed the PNFT module.
./gradlew buildThe default build runs local unit tests only. Testnet integration tests are explicit because some of them broadcast transactions and spend testnet tokens.
export OWNER_MNEMONIC
export RECIPIENT_MNEMONIC
./gradlew integrationTest- Create a
PanaceaGrpcClientobject.
ManagedChannel channel = ManagedChannelBuilder.forTarget("{ip or domain}:{port}")
.usePlaintext()
.build();
PanaceaGrpcClient client = new PanaceaGrpcClient(channel);- Create a
Walletand init. - Required your mnemonic.
Wallet wallet = Wallet.createWalletFromMnemonicCode(mnemonic, "panacea", 0);
wallet.ensureWalletIsReady(client);- Make msg.
- Create MsgSend here.
Coin sendCoin = Coins.createCoin("umed", "100000000");
MsgSend msg = MsgSend.newBuilder()
.addAmount(sendCoin)
.setFromAddress(ownerAddress)
.setToAddress(toAddress)
.build();- Create
BroadcastTxRequestwithFee
Fee fee = Transactions.createFee(Coins.createCoin("umed", "1000"), 200000);
BroadcastTxRequest request = Transactions.createBroadcastTxRequest(
wallet,
msg,
"send coin",
fee,
BroadcastMode.BROADCAST_MODE_SYNC);| BroadcastMode | Description |
|---|---|
| BROADCAST_MODE_SYNC | Waits for a CheckTx execution response only. |
| BROADCAST_MODE_ASYNC | Returns immediately (transaction might fail) |
BROADCAST_MODE_BLOCK is not supported by the Cosmos SDK used in Panacea Core v2.3.0. Poll the transaction after a successful SYNC response to wait for block inclusion.
- Now do broadcast.
TxResponse response = client.broadcast(request);
Assert.assertEquals(0, response.getCode());
TxResponse committed = TxUtils.pollTxResponse(client, response.getTxhash(), 10, 1000);
Assert.assertEquals(0, committed.getCode());- You simply need to call method.
BaseAccount account = client.getAccount(ownerAddress);
String publicKey = CryptoUtils.getPublicKeyFrom(account);Coin ownerCoin = client.getBalance(ownerAddress, "umed");DefaultNodeInfo nodeInfo = client.getNodeInfo();Tx tx = client.getTx(txHash);TxResponse txResponse = client.getTxResponse(txHash);List<Tx> txs = client.getTxsByHeight(height);List<TxResponse> txResponses = client.getTxResponsesByHeight(height);int offset = 0, limit = 2, total = 0;
while (true) {
PageRequest pagination = PageRequest.newBuilder().setOffset(offset).setLimit(limit).setCountTotal(true).build();
GetTxsEventResponse resp = client.getTxsByHeight(height, pagination);
List<Tx> txs = resp.getTxsList();
List<TxResponse> txResponses = resp.getTxResponsesList();
offset += resp.getTxsCount();
total += resp.getTxsCount();
if (total >= resp.getPagination().getTotal()) {
break;
}
}Block block = client.getBlockByHeight(height);Block block = client.getLatestBlock();Panacea NFT record list queries use key-based pagination. Use pagination.next_key as the next request's key; offset and count_total are not supported by this endpoint.
PageRequest firstPage = PageRequest.newBuilder()
.setLimit(100)
.build();
QueryClassesResponse classes = client.getNftClasses(firstPage);
ClassRecord classRecord = client.getNftClassRecord(classId);
NFTRecord nftRecord = client.getNftRecord(classId, nftId);
QueryNFTRecordsResponse records = client.getNftRecords(classId, ownerAddress, firstPage);
PageRequest nextPage = PageRequest.newBuilder()
.setKey(records.getPagination().getNextKey())
.setLimit(100)
.build();The existing Transactions helpers accept the new NFT messages without a separate signing API. Class creation, controller updates, mint, revoke, and burn use panacea.nft.v1 messages. Transfers use the standard Cosmos NFT MsgSend.
BasicNFTData data = BasicNFTData.newBuilder()
.setName("certificate")
.build();
MsgMintRequest mint = MsgMintRequest.newBuilder()
.setClassId(classId)
.setNftId(nftId)
.setController(wallet.getAddress())
.setRecipient(recipientAddress)
.setData(Any.pack(data, ""))
.build();
BroadcastTxRequest request = Transactions.createBroadcastTxRequest(
wallet,
mint,
"mint nft",
fee,
BroadcastMode.BROADCAST_MODE_SYNC);