Porting from web3j
We made caver-java as similar as possible to web3j for portability. The below code snippets show how to port an application written in web3j to caver-java.
/* start a client */Web3j web3 = Web3j.build(new HttpService(<endpoint>)); // Web3jCaver caver = Caver.build(new HttpService(<endpoint>)); // caver-java/* get nonce */BigInteger nonce = web3j.ethGetTransactionCount(<address>, <blockParam>).send().getTransactionCount(); // Web3jQuantity nonce = caver.klay().getTransactionCount(<address>, <blockParam>).send().getValue(); // caver-java/* convert unit */Convert.toWei("1.0", Convert.Unit.ETHER).toBigInteger(); // Web3jConvert.toPeb("1.0", Convert.Unit.KLAY).toBigInteger(); // caver-java/* generate wallet file */WalletUtils.generateNewWalletFile(<password>, <filepath>); // Web3jKlayWalletUtils.generateNewWalletFile(<address>, <password>, <filepath>); // caver-java/* load credentials */Credentials credentials = WalletUtils.loadCrendetials(<password>, <filepath>"); // Web3jKlayCredentials credentials = KlayWalletUtils.loadCredentials(<password>, <filepath>); // caver-java/* Value Transfer */TransactionReceipt transactionReceipt = Transfer.sendFunds(...),send(); // Web3jKlayTransactionReceipt.TransactionReceipt transactionReceipt = ValueTransfer.sendFunds().send(); // caver-java