Java
Get Started
Prerequisite and Requirements
$ java -version
java 17.0.1 2021-10-19 LTS
Java(TM) SE Runtime Environment (build 17.0.1+12-LTS-39)
Java HotSpot(TM) 64-Bit Server VM (build 17.0.1+12-LTS-39, mixed mode, sharing)
$ javac -version
javac 17.0.1
Installation
mitum-java-util-4.1.1-jdk17.jar
입니다.implementation files('./lib/mitum-java-util-4.1.1-jdk17.jar')
Make Your First Operation
create-account
operation을 생성하는 방법에 대해 설명합니다.Get Available Account
1. pairs of (public key, weight); aka `keys`
- public key has suffix `mpu`
- The range of each weight should be in 1 <= weight <= 100
- If an account have single public key, the account is called 'single-sig account', or it's called 'multi-sig account'
1. threshold
- The range of threshold should be in 1 <= threshold <= 100
- The sum of all weights of the account should be over or equal to threshold
sender
로 사용해야 하기 때문에 기억하고 있어야 합니다.Create Generator
Generator
로 생성합니다.Generator.currency
를 사용하세요.Generator
를 선언할 때, network id
가 필요합니다.network id
는 네트워크에 따라 다릅니다.mitum
을 네트워크 id로 가정합니다./*
import org.mitumc.sdk.Generator
*/
String id = "mitum";
Generator generator = Generator.get(id);
Generator
에 대한 더 자세한 내용은 Major Classes 로 이동하여 Generator를 참고하세요.Create Operation Item
sender
, token
등의 기본적인 정보를 담고 있습니다.1. The keys and threshold of the account will be,
- keys(public key, weight): (kpYjRwq6gQrjvzeqQ91MNiCcR9Beb9sD67SuhQ6frPGwmpu, 50), (pWoFhRP3C7ocebSRPxTPfeaJZpnyKpEkxQqi6fAD4SHompu, 50)
- threshold: 100
2. The initial balance of the account will be,
- balance(currency id, amount): (MCC, 10000), (PEN, 20000)
/*
import org.mitumc.sdk.key.*;
import org.mitumc.sdk.operation.Amount;
import org.mitumc.sdk.operation.currency.*;
*/
Key key1 = Key.get("kpYjRwq6gQrjvzeqQ91MNiCcR9Beb9sD67SuhQ6frPGwmpu", 50);
Key key2 = Key.get("pWoFhRP3C7ocebSRPxTPfeaJZpnyKpEkxQqi6fAD4SHompu", 50);
Keys keys = Keys.get(new Key[]{ key1, key2 }, 100);
Amount amount1 = Amount.get("MCC", "10000");
Amount amount2 = Amount.get("PEN", "20000");
CreateAccountsItem item = generator.currency.getCreateAccountsItem(keys, new Amount[]{ amount1, amount2 }); // newCreateAccountsItem(keys, amount list)
우선,
Key.get(public key, weight)
를 사용해 각 key를 생성합니다.다음으로 모든 키와 계정 threshold를
Keys.get(key list, threshold)
로 결합합니다.그리고,
Amount.get(currencyId, amount)
를 사용해 각 amount를 생성합니다.마지막으로,
Generator.currency.getCreateAccountsItem(keys, amount list)
를 사용해 item을 생성하세요.
- `keys`를 사용하여 생성하는 `Keys`는 key를 10개까지 포함할 수 있습니다.
- 각 amount가 `amounts`로 생성된 `Amount list`는 item 당 amount를 10개까지 포함할 수 있습니다.
- 게다가, `fact`는 item을 여러 개 포함할 수 있습니다. fact 당 item 개수는 최대 10 개입니다.
Create Operation Fact
items
, sender
, token
, fact hash
를 가져야 합니다.token
와 fact hash
는 SDK가 자동적으로 생성해주므로 걱정하지 않아도 됩니다.items
와 sender
에 대한 것입니다.sender
로 사용할 수 있다는 것을 명심하세요.1. 이미 생성되어 등록된 계정.
2. item의 각 amount에 대해 충분한 잔액을 보유한 계정.
3. 계정의 공개키에 상응하는 개인키(멀티 시그 계정인 경우 모든 개인키들 중 일부)를 알고 있는 계정.
/*
import org.mitumc.sdk.operation.currency.*;
*/
String senderAddress = "CY1pkxsqQK6XMbnK4ssDNbDR2K7mitSwdS27DwBjd3Gcmca"; // sender's account address; replace with your address
CreateAccountsFact fact = generator.currency.getCreateAccountsFact(senderAddress, new CreateAccountsItem[]{ item }); // newCreateAccountsFact(sender address, item list)
Generator.currency.getCreateAccountsFact(sender's address, item list)
의 item list에 item을 모두 넣으세요.Create Operation
fact_signs
에 추가됩니다.fact_signs
의 모든 signer의 weight들의 총합이 sender
의 threshold 이상이어야 합니다.sender
의 개인키의 서명만이 유효합니다.memo
값이 존재하지만 필수적이지는 않습니다. 필요한 내용을 넣어도 괜찮지만 memo
또한 operation hash
값에 영향을 미치기 때문에 주의해야 합니다.sender
가 single-sig 계정이라고 가정합니다. 즉, sender의 계정에는 오직 하나의 키 밖에 없습니다.sender
가 multi-sig 계정이라면 fact_signs
에 여러 개의 서명을 추가해야 할 수 있습니다./*
import org.mitumc.sdk.operation.Operation;
*/
String senderPrivateKey = "KxD8T82nfwsUmQu3iMXENm93YTTatGFp1AYDPqTo5e6ycvY1xNXpmpr";
Operation operation = generator.getOperation(fact);
operation.sign(senderPrivateKey);
Generator.currency.getOperation(fact, memo)
가 아닌 Generator.getOperation(fact, memo)
을 사용해야 한다는 점에 주의하세요.Create Seal
operation
자체로도 계정을 생성하는 데는 충분합니다.String signKey = "KzafpyGojcN44yme25UMGvZvKWdMuFv1SwEhsZn8iF8szUz16jskmpr";
HashMap<String, Object> seal = gn.getSeal(signKey, new Operation[]{ operation }); // getSeal(sign key, operation list)
getOperation
의 경우와 같이, 단순히 Generator.getSeal(signer, operation list)
를 사용하세요.Support Operations
Model |
Support Operations |
---|---|
Currency |
create account, key updater, transfer |
Currency Extension |
create contract account, withdraw |
Document |
create document, update document, (sign document) |
Feefi |
pool register, pool policy updater, pool deposit, pool withdraw |
NFT |
collection register, collection policy updater, mint, transfer, burn, sign, approve, delegate |
Currency
Create Account
create-account
의 예제는 이미 설명했으나 여기서 하나의 코드 블록으로 다시 한 번 소개합니다.새로운 계정의 정보: (public key, weight)쌍과 threshold로 이루어진 계정 keys, (currency id, amount) 쌍으로 이루어진 계정 초기 잔액
이미 존재하는 sender의 계정 - 특히 계정 주소와 개인키를 알아야 합니다.
/*
import org.mitumc.sdk.key.*;
import org.mitumc.sdk.Generator;
import org.mitumc.sdk.operation.*;
import org.mitumc.sdk.operation.currency.*;
*/
String senderPrivateKey = "KzafpyGojcN44yme25UMGvZvKWdMuFv1SwEhsZn8iF8szUz16jskmpr";
String senderAddress = "FcLfoPNCYjSMnxLPiQJQFGTV15ecHn3xY4J2HNCrqbCfmca";
Generator gn = Generator.get("mitum"); // network id: mitum
Key key = Key.get("knW2wVXH399P9Xg8aVjAGuMkk3uTBZwcSpcy4aR3UjiAmpu", 100);
Keys keys = Keys.get(new Key[]{ key }, 100); // becomes single-sig account
Amount amount = Amount.get("MCC", "1000");
CreateAccountsItem item = gn.currency.getCreateAccountsItem(keys, new Amount[]{ amount });
CreateAccountsFact fact = gn.currency.getCreateAccountsFact(senderAddress, new CreateAccountsItem[]{ item });
Operation createAccount = gn.getOperation(fact);
createAccount.sign(senderPrivateKey);
Key Updater
- I have an single sig account with keys: (kpYjRwq6gQrjvzeqQ91MNiCcR9Beb9sD67SuhQ6frPGwmpu, 100), threshold: 100
- But I want to replace keys of the account with keys: (22ndFZw57ax28ydC3ZxzLJMNX9oMSqAfgauyWhC17pxDpmpu, 50), (22wD5RWsRFAr8mHkYmmyUDzKf6VBNgjHcgc3YhKxCvrZDmpu, 50), threshold: 100
- Then you can use key-updater operation to reach the goal!
키를 교체하고자 하는 계정(target)의 정보 - 계정 주소와 개인키; 어떤 개인키가 필요한지는 threshold와 키 weight들에 따라 다를 수 있습니다.
새로운 keys: (public key, weights)쌍들과 threshold
수수료를 지불하려는 currency의 충분한 잔액
create-account
와 transfer
는 item
operation 생성을 위해 item을 만들어야 하지만 key-updater
는 item이 필요하지 않습니다./*
import org.mitumc.sdk.key.*;
import org.mitumc.sdk.Generator;
import org.mitumc.sdk.operation.*;
import org.mitumc.sdk.operation.currency.*;
*/
Generator gn = Generator.get("mitum"); // network id: mitum
String targetPrivateKey = "KzejtzpPZFdLUXo2hHouamwLoYoPtoffKo5zwoJXsBakKzSvTdbzmpr";
String targetAddress = "JDhSSB3CpRjwM8aF2XX23nTpauv9fLhxTjWsQRm9cJ7umca";
Key key1 = Key.get("22ndFZw57ax28ydC3ZxzLJMNX9oMSqAfgauyWhC17pxDpmpu", 50);
Key key2 = Key.get("22wD5RWsRFAr8mHkYmmyUDzKf6VBNgjHcgc3YhKxCvrZDmpu", 50);
Keys newKeys = Keys.get(new Key[]{ key1, key2 }, 100);
KeyUpdaterFact fact = gn.currency.getKeyUpdaterFact(targetAddress, "MCC", newKeys);
Operation keyUpdater = gn.getOperation(fact);
keyUpdater.sign(targetPrivateKey);
계정의 키를 업데이트한 후에는 이전의 키를 사용할 수 없게 됩니다. 계정의 새로운 키페어의 개인키로 서명해야 합니다.
따라서 네트워크에 key-updater operation을 전송하기 전, 새로운 키들을 기록해두세요.
Transfer
sender의 계정 정보 - 계정 주소와 개인키
송금할 (currency id, amount) 쌍
create-account
처럼 fact 생성 전 item을 먼저 만들어야 합니다.1000000 MCC token
15000 PEN token
CY1pkxsqQK6XMbnK4ssDNbDR2K7mitSwdS27DwBjd3Gcmca
/*
import org.mitumc.sdk.Generator;
import org.mitumc.sdk.operation.*;
import org.mitumc.sdk.operation.currency.*;
*/
Generator gn = Generator.get("mitum"); // network id: mitum
String senderPrivateKey = "KzdeJMr8e2fbquuZwr9SEd9e1ZWGmZEj96NuAwHnz7jnfJ7FqHQBmpr";
String senderAddress = "2D5vAb2X3Rs6ZKPjVsK6UHcnGxGfUuXDR1ED1hcvUHqsmca";
String receiverAddress = "CY1pkxsqQK6XMbnK4ssDNbDR2K7mitSwdS27DwBjd3Gcmca";
Amount amount1 = Amount.get("MCC", "100000")
Amount amount2 = Amount.get("PEN", "15000")
TransfersItem item = gn.currency.getTransfersItem(receiverAddress, new Amount[]{ amount1, amount2 }); // getTransfersItem(receiver address, amount list)
TransfersFact fact = gn.currency.getTransfersFact(senderAddress, new TransfersItem[]{ item }); // getTransfersFact(sender address, item list)
Operation transfer = gn.getOperation(fact);
transfer.sign(senderPrivateKey); // suppose sender is single-sig
Currency Extension
Create Contract Account
/*
import org.mitumc.sdk.key.*;
import org.mitumc.sdk.Generator;
import org.mitumc.sdk.operation.*;
import org.mitumc.sdk.operation.currency.*;
import org.mitumc.sdk.operation.currency.extension.*;
*/
String senderPrivateKey = "KzafpyGojcN44yme25UMGvZvKWdMuFv1SwEhsZn8iF8szUz16jskmpr";
String senderAddress = "FcLfoPNCYjSMnxLPiQJQFGTV15ecHn3xY4J2HNCrqbCfmca";
Generator gn = Generator.get("mitum"); // network id: mitum
Key key = Key.get("knW2wVXH399P9Xg8aVjAGuMkk3uTBZwcSpcy4aR3UjiAmpu", 100);
Keys keys = Keys.get(new Key[]{ key }, 100); // becomes single-sig account
Amount amount = Amount.get("MCC", "1000");
CreateContractAccountsItem item = gn.currency.extension.getCreateContractAccountsItem(keys, new Amount[]{ amount });
CreateContractAccountsFact fact = gn.currency.extension.getCreateContractAccountsFact(senderAddress, new CreateContractAccountsItem[]{ item });
Operation createContractAccount = gn.getOperation(fact);
createContractAccount.sign(senderPrivateKey);
Withdraw
/*
import org.mitumc.sdk.Generator;
import org.mitumc.sdk.operation.*;
import org.mitumc.sdk.operation.currency.*;
import org.mitumc.sdk.operation.currency.extension.*;
*/
Generator gn = Generator.get("mitum"); // network id: mitum
String senderPrivateKey = "KzdeJMr8e2fbquuZwr9SEd9e1ZWGmZEj96NuAwHnz7jnfJ7FqHQBmpr";
String senderAddress = "2D5vAb2X3Rs6ZKPjVsK6UHcnGxGfUuXDR1ED1hcvUHqsmca";
String targetAddress = "CY1pkxsqQK6XMbnK4ssDNbDR2K7mitSwdS27DwBjd3Gcmca";
Amount amount1 = Amount.get("MCC", "1000000");
Amount amount2 = Amount.get("PEN", "15000");
WithdrawsItem item = gn.currency.extension.getWithdrawsItem(targetAddress, new Amount[]{ amount1, amount2 }); // getTransfersItem(receiver address, amount list)
WithdrawsFact fact = gn.currency.extension.getWithdrawsFact(senderAddress, new WithdrawsItem[]{ item }); // getTransfersFact(sender address, item list)
Operation withdraws = gn.getOperation(fact);
withdraws.sign(senderPrivateKey);
Sign
모든 서명이 계정의 개인키의 서명인가요?
각 signer의 weight들을 모두 합한 값이 계정의 threshold 이상인가요?
(pub1, 30)
(pub2, 30)
(pub3, 30)
threshold: 50
CASE1: fact signatures signed by pub1’s private key and pub2’s private key
the sum of pub1’s weight and pub2’s weight: 60
the sum of weights = 60 > threshold = 50
So the operation with these two fact signatures is available
CASE2: fact signatures signed by pub2’s private key and pub3’s private key
the sum of pub2’s weight and pub3’s weight: 60
the sum of weights = 60 > threshold = 50
So the operation with these two fact signatures is available
CASE3: fact signatures signed by pub1’s private key and pub3’s private key
the sum of pub1’s weight and pub3’s weight: 60
the sum of weights = 60 > threshold = 50
So the operation with these two fact signatures is available
CASE4: fact signatures signed by pub1’s private key, pub2’s private key, pub3’s private key
the sum of pub1’s weight, pub2’s weight and pub3’s weight: 90
the sum of weights = 90 > threshold = 50
So the operation with these two fact signatures is available
Operation.sign(private key)
를 사용하세요.)Add Fact Sign to Operation
서명할 개인키 - 이 개인키는 계정의 키여야 합니다.
JsonObject 혹은 외부 JSON 파일 형태의 operation
Network ID
Generator
처럼 network id
와 함께 Signer
를 생성합니다./*
import org.mitumc.sdk.Signer;
import org.mitumc.sdk.JSONParser;
*/
String id = "mitum";
String key = "KzafpyGojcN44yme25UMGvZvKWdMuFv1SwEhsZn8iF8szUz16jskmpr";
Signer signer = Signer.get(id, key);
HashMap<String, Object> signed = signer.addSignToOperation("operation.json"); // or JsonObject from Operation JSON instead
Operation
객체가 아닙니다. 단지 HashMap 객체입니다.Signer
클래스로 서명해야 합니다.Details
Get Mitum Keypair
Account Address:
mca
Private Key:
mpr
Public Key:
mpu
Account Address:
9XyYKpjad2MSPxR4wfQHvdWrZnk9f5s2zc9Rkdy2KT1gmca
Private Key:
L11mKUECzKouwvXwh3eyECsCnvQx5REureuujGBjRuYXbMswFkMxmpr
Public Key:
28Hhy6jwkEHx75bNLmG66RQu1LWiZ1vodwRTURtBJhtPWmpu
Just Create New Keypair
Keypar.create()
를 사용하세요./*
import org.mitumc.sdk.key.Keypair;
*/
Keypair kp = Keypair.random();
kp.getPrivateKey(); // returns private key of the keypair
kp.getPublicKey(); // returns public key of the keypair
Get Keypair From Your Private Key
/*
import org.mitumc.sdk.key.Keypair;
*/
String key = "KzafpyGojcN44yme25UMGvZvKWdMuFv1SwEhsZn8iF8szUz16jskmpr";
Keypair pkp = Keypair.fromPrivateKey(key);
Get Keypair From Your Seed
/*
import org.mitumc.sdk.key.Keypair;
*/
String seed = "Thisisaseedfortheexample;Keypair.fromSeed()";
Keypair skp = Keypair.fromSeed(seed);
// or... -----------------------------//
// byte[] bseed = seed.getBytes();
// Keypair skp = Keypair.fromSeed(bseed);
Get Account Address with Keys
key1: (vmk1iprMrs8V1NkA9DsSL3XQNnUW9SmFL5RCVJC24oFYmpu, 40)
key2: (29BQ8gcVfJd5hPZCKj335WSe4cyDe7TGrjam7fTrkYNunmpu, 30)
key3: (uJKiGLBeXF3BdaDMzKSqJ4g7L5kAukJJtW3uuMaP1NLumpu, 30)
threshold: 100
/*
import org.mitumc.key.Key
import org.mitumc.key.Keys
*/
Key key1 = Key.get("vmk1iprMrs8V1NkA9DsSL3XQNnUW9SmFL5RCVJC24oFYmpu", 40);
Key key2 = Key.get("29BQ8gcVfJd5hPZCKj335WSe4cyDe7TGrjam7fTrkYNunmpu", 30);
Key key3 = Key.get("uJKiGLBeXF3BdaDMzKSqJ4g7L5kAukJJtW3uuMaP1NLumpu", 30);
Keys keys = Keys.get(new Key[]{ key1, key2, key3 }, 100);
String address = keys.getAddress(); // This is the goal!
Major Classes
Generator
Generator
는 Mitum Currency operation 생성을 도와줍니다.Generator
를 사용하기 전 network id
를 설정해야 합니다.Mitum Currency:
Generator.currency
Mitum Currency Extension:
Generator.currency.extension
Mitum Document:
Generator.document
Mitum Feefi:
Generator.feefi
Mitum NFT:
Generator.nft
/*
import org.mitumc.sdk.Generator;
*/
String id = "mitum";
Generator generator = Generator.get(id);
CurrencyGenerator cgn = generator.currency; // org.mitumc.sdk.operation.currency.CurrencyGenerator;
ExtensionGenerator egn = generator.currency.extension; // org.mitumc.sdk.operation.currency.extension.ExtensionGenerator;
DocumentGenerator dgn = generator.document; // org.mitumc.sdk.operation.document.DocumentGenerator;
FeefiGenerator fgn = generator.feefi; // org.mitumc.sdk.operation.feefi.FeefiGenerator;
NFTGenerator ngn = generator.nft; // org.mitumc.sdk.operation.nft.NFTGenerator;
Generator
가 제공하는 모든 메서드는 다음과 같습니다. /* For Mitum Currency */
CreateAccountsItem getCreateAccountsItem(Keys keys, Amount[] amounts);
TransfersItem getTransfersItem(String receiver, Amount[] amounts);
CreateAccountsFact getCreateAccountsFact(String sender, CreateAccountsItem[] items);
KeyUpdaterFact getKeyUpdaterFact(String target, String currency, Keys keys);
TransfersFact getTransfersFact(String sender, TransfersItem[] items);
/* For Mitum Currency Extension */
CreateContractAccountsItem getCreateContractAccountsItem(Keys keys, Amount[] amounts);
WithdrawsItem getWithdrawsItem(String target, Amount[] amounts);
CreateContractAccountsFact getCreateContractAccountsFact(String sender, CreateContractAccountsItem[] items);
WithdrawsFact getWithdrawsFact(String sender, WithdrawsItem[] items);
/* For Mitum Document */
Generator.document.getCreateDocumentsItem(Document document, String currencyId);
Generator.document.getUpdateDocumentsItem(Document document, String currencyId);
Generator.document.getCreateDocumentsFact(String sender, CreateDocumentsItem[] items);
Generator.document.getUpdateDocumentsFact(String sender, UpdateDocumentsItem[] items);
/* For Blocksign */
Generator.document.blocksign.user(String address, String signCode, boolean signed);
Generator.document.blocksign.document(String documentId, String owner, String fileHash, BlockSignUser creator, String title, String size, BlockSignUser[] signers);
Generator.document.blocksign.getSignDocumentsItem(String documentId, String owner, String currencyId);
Generator.document.blocksign.getSignDocumentsFact(String sender, SignDocumentsItem[] items);DocumentsFact(String sender, BlockCityItem<T>[] items);
/* For Blockcity */
Candidate candidate(String address, String nickname, String manifest, int count);
UserStatistics userStatistics(int hp, int strength, int agility, int dexterity, int charisma, int intelligence, int vital);
Document userDocument(String documentId, String owner, int gold, int bankGold, UserStatistics statistics);
Document landDocument(String documentId, String owner, String address, String area, String renter, String account, String rentDate, int period);
Document voteDocument(String documentId, String owner, int round, String endTime, Candidate[] candidates, String bossName, String account, String office);
Document historyDocument(String documentId, String owner, String name, String account, String date, String usage, String app);
/* For Mitum Feefi */
PoolRegisterFact getPoolRegisterFact(String sender, String target, Amount initialFee, String incomingCid, String outgoingCid, String currency);
PoolPolicyUpdaterFact getPoolPolicyUpdaterFact(String sender, String target, Amount fee, String poolId, String currency);
PoolDepositsFact getPoolDepositsFact(String sender, String pool, String poolId, Amount amount);
PoolWithdrawFact getPoolWithdrawFact(String sender, String pool, String poolId, Amount[] amounts);
/* For Mitum NFT */
NFTSigner signer(String account, int share, boolean signed);
NFTSigners signers(int total, NFTSigner[] signers);
CollectionRegisterForm collectionRegisterForm(String target, String symbol, String name, int royalty, String uri, String[] whites);
CollectionPolicy collectionPolicy(String name, int royalty, String uri, String[] whites);
MintForm mintForm(String hash, String uri, NFTSigners creators, NFTSigners copyrighters);
MintItem getMintItem(String collection, MintForm form, String currency);
NFTTransferItem getTransferItem(String receiver, NFTID nid, String currency);
BurnItem getBurnItem(NFTID nid, String currency);
NFTSignItem getSignItem(String qualification, NFTID nid, String currency);
ApproveItem getApproveItem(String approved, NFTID nid, String currency);
DelegateItem getDelegateItem(String collection, String agent, String mode, String currency);
CollectionRegisterFact getCollectionRegisterFact(String sender, CollectionRegisterForm form, String currency);
CollectionPolicyUpdaterFact getCollectionPolicyUpdaterFact(String sender, String collection, CollectionPolicy policy, String currency);
MintFact getMintFact(String sender, MintItem[] items);
NFTTransferFact getTransferFact(String sender, NFTTransferItem[] items);
BurnFact getBurnFact(String sender, BurnItem[] items);
NFTSignFact getSignFact(String sender, NFTSignItem[] items);
ApproveFact getApproveFact(String sender, ApproveItem[] items);
DelegateFact getDelegateFact(String sender, DelegateItem[] items);
/* Common */
Operation getOperation(OperationFact fact);
Operation getOperation(OperationFact fact, String memo);
HashMap<String, Object> getSeal(String signKey, Operation[] operations);
HashMap<String, Object> getSeal(String signKey, JsonObject[] operations);
HashMap<String, Object> randomKeys();
HashMap<String, Object> randomKeys(int numOfKeys);
Signer
Signer
는 이미 생성된 operation에 새로운 fact 서명을 추가할 때 사용합니다.Generator
와 같이 network id
가 설정되어야 합니다.Signer
는 오직 하나의 메서드를 제공합니다.HashMap<String, Object> addSignToOperation(JsonObject operation);
HashMap<String, Object> addSignToOperation(String operationPath);
Signer
의 정확한 사용 방법은 ‘Make Your First Operation - Sign’로 돌아가서 확인하세요.JSONParser
Operation
을 내보내거나 JSON 형식으로 출력하기 위해 다른 패키지를 사용하길 원한다면 굳이 mitum-java-util의 JSONParser
를 사용할 필요는 없습니다.JsonObject getObjectFromJsonFile(String fpName);
JsonObject getObjectFromHashMap(HashMap<String, Object> target);
void writeJsonFileFromJsonObject(JsonObject target, String fpName);
void writeJsonFileFromHashMap(HashMap target, String fpName);
HashMap<String, Object> mergeOperations(JsonObject[] operations);
HashMap<String, Object> mergeOperations(HashMap<String, Object>[] operations);
/*
import org.mitumc.sdk.JSONParser;
*/
// ... omitted
// ... create operations
// ... refer to above `Make Your First Operation`
// ... suppose you have already made operations - createAccount, keyUpdater, transfer and a seal - seal
JSONParser.writeJsonFileFromHashMap(createAccount.toDict(), 'createAccount.json'); // writeJsonFileFromHashMap(HashMap, filePath)
JSONParser.writeJsonFileFromHashMap(keyUpdater.toDict(), 'keyUpdater.json');
JSONParser.writeJsonFileFromHashMap(transfer.toDict(), 'transfer.json');
JSONParser.writeJsonFileFromHashMap(seal, 'seal.json');